Verovio
Source code documentation
layer.h
1 // Name: layer.h
3 // Author: Laurent Pugin
4 // Created: 2011
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_LAYER_H__
9 #define __VRV_LAYER_H__
10 
11 #include "atts_shared.h"
12 #include "drawinginterface.h"
13 #include "object.h"
14 
15 namespace vrv {
16 
17 class Clef;
18 class DeviceContext;
19 class LayerElement;
20 class Measure;
21 class Note;
22 class StaffDef;
23 
24 //----------------------------------------------------------------------------
25 // Layer
26 //----------------------------------------------------------------------------
27 
33 class Layer : public Object,
34  public DrawingListInterface,
35  public ObjectListInterface,
36  public AttCue,
37  public AttNInteger,
38  public AttTyped,
39  public AttVisibility {
40 public:
46  Layer();
47  virtual ~Layer();
48  Object *Clone() const override { return new Layer(*this); }
49  void Reset() override;
50  std::string GetClassName() const override { return "layer"; }
52 
56  void CloneReset() override;
57 
62  bool IsSupportedChild(ClassId classId) override;
64 
69  int GetLayerIdx() const { return Object::GetIdx(); }
70 
71  LayerElement *GetPreviousInLayer(const LayerElement *element);
72  const LayerElement *GetPreviousInLayer(const LayerElement *element) const;
73  LayerElement *GetNextInLayer(const LayerElement *element);
74  const LayerElement *GetNextInLayer(const LayerElement *element) const;
75  LayerElement *GetAtPos(int x);
76  const LayerElement *GetAtPos(int x) const;
77 
85  Clef *GetClef(const LayerElement *test);
86  const Clef *GetClef(const LayerElement *test) const;
88 
95  Clef *GetClefFacs(const LayerElement *test);
96  const Clef *GetClefFacs(const LayerElement *test) const;
98 
103  int GetClefLocOffset(const LayerElement *test) const;
104 
108  int GetCrossStaffClefLocOffset(const LayerElement *element, int locOffset) const;
109 
115  void SetDrawingStemDir(data_STEMDIRECTION stemDirection) { m_drawingStemDir = stemDirection; }
116  data_STEMDIRECTION GetDrawingStemDir(const LayerElement *element) const;
117  data_STEMDIRECTION GetDrawingStemDir(const ArrayOfBeamElementCoords *coords) const;
118  data_STEMDIRECTION GetDrawingStemDir() const { return m_drawingStemDir; }
120 
126  std::set<int> GetLayersNForTimeSpanOf(const LayerElement *element) const;
127  int GetLayerCountForTimeSpanOf(const LayerElement *element) const;
129 
135  std::set<int> GetLayersNInTimeSpan(
136  const Fraction &time, const Fraction &duration, const Measure *measure, int staff) const;
137  int GetLayerCountInTimeSpan(
138  const Fraction &time, const Fraction &duration, const Measure *measure, int staff) const;
140 
147  ListOfObjects GetLayerElementsForTimeSpanOf(const LayerElement *element, bool excludeCurrent = false);
148  ListOfConstObjects GetLayerElementsForTimeSpanOf(const LayerElement *element, bool excludeCurrent = false) const;
150 
157  const Fraction &time, const Fraction &duration, const Measure *measure, int staff, bool excludeCurrent);
158  ListOfConstObjects GetLayerElementsInTimeSpan(
159  const Fraction &time, const Fraction &duration, const Measure *measure, int staff, bool excludeCurrent) const;
161 
167  const Clef *GetCurrentClef() const;
168  KeySig *GetCurrentKeySig();
169  const KeySig *GetCurrentKeySig() const;
170  Mensur *GetCurrentMensur();
171  const Mensur *GetCurrentMensur() const;
172  MeterSig *GetCurrentMeterSig();
173  const MeterSig *GetCurrentMeterSig() const;
174  Proport *GetCurrentProport();
175  const Proport *GetCurrentProport() const;
177 
178  void ResetStaffDefObjects();
179 
184  void SetDrawingStaffDefValues(StaffDef *currentStaffDef);
185  bool GetDrawingStaffDefValues(StaffDef *staffDef) const;
186 
187  bool DrawKeySigCancellation() const { return m_drawKeySigCancellation; }
188  void SetDrawKeySigCancellation(bool drawKeySigCancellation) { m_drawKeySigCancellation = drawKeySigCancellation; }
189 
190  Clef *GetStaffDefClef() { return m_staffDefClef; }
191  const Clef *GetStaffDefClef() const { return m_staffDefClef; }
192  KeySig *GetStaffDefKeySig() { return m_staffDefKeySig; }
193  const KeySig *GetStaffDefKeySig() const { return m_staffDefKeySig; }
194  Mensur *GetStaffDefMensur() { return m_staffDefMensur; }
195  const Mensur *GetStaffDefMensur() const { return m_staffDefMensur; }
196  MeterSig *GetStaffDefMeterSig() { return m_staffDefMeterSig; }
197  const MeterSig *GetStaffDefMeterSig() const { return m_staffDefMeterSig; }
198  MeterSigGrp *GetStaffDefMeterSigGrp() { return m_staffDefMeterSigGrp; }
199  const MeterSigGrp *GetStaffDefMeterSigGrp() const { return m_staffDefMeterSigGrp; }
200 
201  bool HasStaffDef() const
202  {
203  return (m_staffDefClef || m_staffDefKeySig || m_staffDefMensur || m_staffDefMeterSig || m_staffDefMeterSigGrp);
204  }
205 
206  bool DrawOssiaStaffDef() const { return m_drawOssiaStaffDef; }
207  void SetDrawOssiaStaffDef(bool drawOssiaStaffDef) { m_drawOssiaStaffDef = drawOssiaStaffDef; }
209 
214  void SetDrawingCautionValues(StaffDef *currentStaffDef);
215 
216  bool DrawCautionKeySigCancel() const { return m_drawCautionKeySigCancel; }
217  void SetDrawCautionKeySigCancel(bool drawCautionKeySig) { m_drawCautionKeySigCancel = drawCautionKeySig; }
218 
219  Clef *GetCautionStaffDefClef() { return m_cautionStaffDefClef; }
220  const Clef *GetCautionStaffDefClef() const { return m_cautionStaffDefClef; }
221  KeySig *GetCautionStaffDefKeySig() { return m_cautionStaffDefKeySig; }
222  const KeySig *GetCautionStaffDefKeySig() const { return m_cautionStaffDefKeySig; }
223  Mensur *GetCautionStaffDefMensur() { return m_cautionStaffDefMensur; }
224  const Mensur *GetCautionStaffDefMensur() const { return m_cautionStaffDefMensur; }
225  MeterSig *GetCautionStaffDefMeterSig() { return m_cautionStaffDefMeterSig; }
226  const MeterSig *GetCautionStaffDefMeterSig() const { return m_cautionStaffDefMeterSig; }
227 
228  bool HasCautionStaffDef() const
229  {
230  return (
231  m_cautionStaffDefClef || m_cautionStaffDefKeySig || m_cautionStaffDefMensur || m_cautionStaffDefMeterSig);
232  }
234 
239  void SetCrossStaffFromAbove(bool crossStaff) { m_crossStaffFromAbove = crossStaff; }
240  bool HasCrossStaffFromAbove() const { return m_crossStaffFromAbove; }
241  void SetCrossStaffFromBelow(bool crossStaff) { m_crossStaffFromBelow = crossStaff; }
242  bool HasCrossStaffFromBelow() const { return m_crossStaffFromBelow; }
244 
245  //----------//
246  // Functors //
247  //----------//
248 
253  FunctorCode Accept(Functor &functor) override;
254  FunctorCode Accept(ConstFunctor &functor) const override;
255  FunctorCode AcceptEnd(Functor &functor) override;
256  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
258 
259 private:
260  //
261 public:
262  //
263 private:
267  data_STEMDIRECTION m_drawingStemDir;
268 
272  bool m_crossStaffFromBelow;
273  bool m_crossStaffFromAbove;
274 
276  Clef *m_staffDefClef;
277  KeySig *m_staffDefKeySig;
278  Mensur *m_staffDefMensur;
279  MeterSig *m_staffDefMeterSig;
280  MeterSigGrp *m_staffDefMeterSigGrp;
281  bool m_drawKeySigCancellation;
282  bool m_drawOssiaStaffDef;
283 
285  Clef *m_cautionStaffDefClef;
286  KeySig *m_cautionStaffDefKeySig;
287  Mensur *m_cautionStaffDefMensur;
288  MeterSig *m_cautionStaffDefMeterSig;
289  bool m_drawCautionKeySigCancel;
290 };
291 
292 } // namespace vrv
293 
294 #endif
This class models the MEI <clef> element.
Definition: clef.h:41
This abstract class is the base class for all const functors.
Definition: functor.h:126
This class is an interface for elements with duration, such as notes and rests.
Definition: drawinginterface.h:34
Definition: fraction.h:19
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class models the MEI <keySig> element.
Definition: keysig.h:51
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a layer in a laid-out score (Doc).
Definition: layer.h:39
int GetCrossStaffClefLocOffset(const LayerElement *element, int locOffset) const
Return the clef offset for the position if there are cross-staff clefs on the same layer.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
Clef * GetClef(const LayerElement *test)
Get the current clef for the test element.
void SetDrawingStaffDefValues(StaffDef *currentStaffDef)
Set drawing clef, keysig, mensur, metersig, metersiggrp if necessary and if available.
void SetDrawingCautionValues(StaffDef *currentStaffDef)
Set drawing caution clef, keysig, mensur, metersig if necessary and if available.
int GetClefLocOffset(const LayerElement *test) const
Return the clef offset for the position x.
bool IsSupportedChild(ClassId classId) override
Base method for checking if a child can be added.
Object * Clone() const override
Method call for copying child classes.
Definition: layer.h:48
ListOfObjects GetLayerElementsForTimeSpanOf(const LayerElement *element, bool excludeCurrent=false)
Get the list of the layer elements for the duration of an element Takes into account cross-staff situ...
void CloneReset() override
Overriding CloneReset() method to be called after copy / assignment calls.
Clef * GetCurrentClef()
Get the current clef, keysig, mensur and meterSig.
Clef * GetClefFacs(const LayerElement *test)
Get the current clef based on facsimile for the test element.
int GetLayerIdx() const
Return the index position of the layer in its staff parent.
Definition: layer.h:69
ListOfObjects GetLayerElementsInTimeSpan(const Fraction &time, const Fraction &duration, const Measure *measure, int staff, bool excludeCurrent)
Get the list of the layer elements used within a time span.
This class represents a measure in a page-based score (Doc).
Definition: measure.h:46
This class models the MEI <mensur> element.
Definition: mensur.h:34
This class represents a MEI meterSigGrp.
Definition: metersiggrp.h:32
This class models the MEI <meterSig> element.
Definition: metersig.h:34
This class represents a basic object.
Definition: object.h:64
int GetIdx() const
Return the index position of the object in its parent (-1 if not found)
This class is an pseudo interface for elements maintaining a flat list of children LayerElement for p...
Definition: object.h:921
This class models the MEI <proport> element.
Definition: proport.h:23
This class represents a MEI staffDef.
Definition: staffdef.h:37