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 Cursor;
19 class DeviceContext;
20 class LayerElement;
21 class Measure;
22 class Note;
23 class StaffDef;
24 
25 //----------------------------------------------------------------------------
26 // Layer
27 //----------------------------------------------------------------------------
28 
34 class Layer : public Object,
35  public DrawingListInterface,
36  public ObjectListInterface,
37  public AttCue,
38  public AttNInteger,
39  public AttTyped,
40  public AttVisibility {
41 public:
47  Layer();
48  virtual ~Layer();
49  Object *Clone() const override { return new Layer(*this); }
50  void Reset() override;
51  std::string GetClassName() const override { return "layer"; }
53 
57  void CloneReset() override;
58 
63  bool IsSupportedChild(ClassId classId) override;
65 
69  void ResetCachedDrawingY() const override;
70 
75  int GetLayerIdx() const { return Object::GetIdx(); }
76 
77  LayerElement *GetPreviousInLayer(const LayerElement *element);
78  const LayerElement *GetPreviousInLayer(const LayerElement *element) const;
79  LayerElement *GetNextInLayer(const LayerElement *element);
80  const LayerElement *GetNextInLayer(const LayerElement *element) const;
81  LayerElement *GetAtPos(int x);
82  const LayerElement *GetAtPos(int x) const;
83 
91  Clef *GetClef(const LayerElement *test);
92  const Clef *GetClef(const LayerElement *test) const;
94 
99  int GetClefLocOffset(const LayerElement *test) const;
100 
104  int GetCrossStaffClefLocOffset(const LayerElement *element, int locOffset) const;
105 
111  void SetDrawingStemDir(data_STEMDIRECTION stemDirection) { m_drawingStemDir = stemDirection; }
112  data_STEMDIRECTION GetDrawingStemDir(const LayerElement *element) const;
113  data_STEMDIRECTION GetDrawingStemDir(const ArrayOfBeamElementCoords *coords) const;
114  data_STEMDIRECTION GetDrawingStemDir() const { return m_drawingStemDir; }
116 
122  std::set<int> GetLayersNForTimeSpanOf(const LayerElement *element) const;
123  int GetLayerCountForTimeSpanOf(const LayerElement *element) const;
125 
131  std::set<int> GetLayersNInTimeSpan(
132  const Fraction &time, const Fraction &duration, const Measure *measure, int staff) const;
133  int GetLayerCountInTimeSpan(
134  const Fraction &time, const Fraction &duration, const Measure *measure, int staff) const;
136 
143  ListOfObjects GetLayerElementsForTimeSpanOf(const LayerElement *element, bool excludeCurrent = false);
144  ListOfConstObjects GetLayerElementsForTimeSpanOf(const LayerElement *element, bool excludeCurrent = false) const;
146 
153  const Fraction &time, const Fraction &duration, const Measure *measure, int staff, bool excludeCurrent);
154  ListOfConstObjects GetLayerElementsInTimeSpan(
155  const Fraction &time, const Fraction &duration, const Measure *measure, int staff, bool excludeCurrent) const;
157 
163  const Clef *GetCurrentClef() const;
164  KeySig *GetCurrentKeySig();
165  const KeySig *GetCurrentKeySig() const;
166  Mensur *GetCurrentMensur();
167  const Mensur *GetCurrentMensur() const;
168  MeterSig *GetCurrentMeterSig();
169  const MeterSig *GetCurrentMeterSig() const;
170  Proport *GetCurrentProport();
171  const Proport *GetCurrentProport() const;
172  std::pair<int, int> GetCurrentNumAndNumbase();
173  const std::pair<int, int> GetCurrentNumAndNumbase() const;
175 
176  void ResetStaffDefObjects();
177 
182  void SetDrawingStaffDefValues(StaffDef *currentStaffDef);
183  bool GetDrawingStaffDefValues(StaffDef *staffDef) const;
184 
185  bool DrawKeySigCancellation() const { return m_drawKeySigCancellation; }
186  void SetDrawKeySigCancellation(bool drawKeySigCancellation) { m_drawKeySigCancellation = drawKeySigCancellation; }
187 
188  Clef *GetStaffDefClef() { return m_staffDefClef; }
189  const Clef *GetStaffDefClef() const { return m_staffDefClef; }
190  KeySig *GetStaffDefKeySig() { return m_staffDefKeySig; }
191  const KeySig *GetStaffDefKeySig() const { return m_staffDefKeySig; }
192  Mensur *GetStaffDefMensur() { return m_staffDefMensur; }
193  const Mensur *GetStaffDefMensur() const { return m_staffDefMensur; }
194  MeterSig *GetStaffDefMeterSig() { return m_staffDefMeterSig; }
195  const MeterSig *GetStaffDefMeterSig() const { return m_staffDefMeterSig; }
196  MeterSigGrp *GetStaffDefMeterSigGrp() { return m_staffDefMeterSigGrp; }
197  const MeterSigGrp *GetStaffDefMeterSigGrp() const { return m_staffDefMeterSigGrp; }
198 
199  bool HasStaffDef() const
200  {
201  return (m_staffDefClef || m_staffDefKeySig || m_staffDefMensur || m_staffDefMeterSig || m_staffDefMeterSigGrp);
202  }
203 
204  bool DrawOssiaStaffDef() const { return m_drawOssiaStaffDef; }
205  void SetDrawOssiaStaffDef(bool drawOssiaStaffDef) { m_drawOssiaStaffDef = drawOssiaStaffDef; }
207 
212  void SetDrawingCautionValues(StaffDef *currentStaffDef);
213 
214  bool DrawCautionKeySigCancel() const { return m_drawCautionKeySigCancel; }
215  void SetDrawCautionKeySigCancel(bool drawCautionKeySig) { m_drawCautionKeySigCancel = drawCautionKeySig; }
216 
217  Clef *GetCautionStaffDefClef() { return m_cautionStaffDefClef; }
218  const Clef *GetCautionStaffDefClef() const { return m_cautionStaffDefClef; }
219  KeySig *GetCautionStaffDefKeySig() { return m_cautionStaffDefKeySig; }
220  const KeySig *GetCautionStaffDefKeySig() const { return m_cautionStaffDefKeySig; }
221  Mensur *GetCautionStaffDefMensur() { return m_cautionStaffDefMensur; }
222  const Mensur *GetCautionStaffDefMensur() const { return m_cautionStaffDefMensur; }
223  MeterSig *GetCautionStaffDefMeterSig() { return m_cautionStaffDefMeterSig; }
224  const MeterSig *GetCautionStaffDefMeterSig() const { return m_cautionStaffDefMeterSig; }
225 
226  bool HasCautionStaffDef() const
227  {
228  return (
229  m_cautionStaffDefClef || m_cautionStaffDefKeySig || m_cautionStaffDefMensur || m_cautionStaffDefMeterSig);
230  }
232 
237  void SetCrossStaffFromAbove(bool crossStaff) { m_crossStaffFromAbove = crossStaff; }
238  bool HasCrossStaffFromAbove() const { return m_crossStaffFromAbove; }
239  void SetCrossStaffFromBelow(bool crossStaff) { m_crossStaffFromBelow = crossStaff; }
240  bool HasCrossStaffFromBelow() const { return m_crossStaffFromBelow; }
242 
247  bool HasCursor() const { return (m_cursor); }
248  Cursor *GetCursor() const { return m_cursor; }
249  void SetCursor(Cursor *cursor);
250  void ResetCursor();
252 
253  //----------//
254  // Functors //
255  //----------//
256 
261  FunctorCode Accept(Functor &functor) override;
262  FunctorCode Accept(ConstFunctor &functor) const override;
263  FunctorCode AcceptEnd(Functor &functor) override;
264  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
266 
267 private:
268  //
269 public:
270  //
271 private:
275  data_STEMDIRECTION m_drawingStemDir;
276 
280  bool m_crossStaffFromBelow;
281  bool m_crossStaffFromAbove;
282 
284  Clef *m_staffDefClef;
285  KeySig *m_staffDefKeySig;
286  Mensur *m_staffDefMensur;
287  MeterSig *m_staffDefMeterSig;
288  MeterSigGrp *m_staffDefMeterSigGrp;
289  bool m_drawKeySigCancellation;
290  bool m_drawOssiaStaffDef;
291 
293  Clef *m_cautionStaffDefClef;
294  KeySig *m_cautionStaffDefKeySig;
295  Mensur *m_cautionStaffDefMensur;
296  MeterSig *m_cautionStaffDefMeterSig;
297  bool m_drawCautionKeySigCancel;
298 
300  Cursor *m_cursor;
301 };
302 
303 } // namespace vrv
304 
305 #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 implements a curor for the editor.
Definition: cursor.h:27
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:40
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:49
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.
void ResetCachedDrawingY() const override
Reset cursor drawing Y.
int GetLayerIdx() const
Return the index position of the layer in its staff parent.
Definition: layer.h:75
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:66
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:932
This class models the MEI <proport> element.
Definition: proport.h:23
This class represents a MEI staffDef.
Definition: staffdef.h:37