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 
102  const Clef *GetClefFacs(const LayerElement *test) const;
104 
109  int GetClefLocOffset(const LayerElement *test) const;
110 
114  int GetCrossStaffClefLocOffset(const LayerElement *element, int locOffset) const;
115 
121  void SetDrawingStemDir(data_STEMDIRECTION stemDirection) { m_drawingStemDir = stemDirection; }
122  data_STEMDIRECTION GetDrawingStemDir(const LayerElement *element) const;
123  data_STEMDIRECTION GetDrawingStemDir(const ArrayOfBeamElementCoords *coords) const;
124  data_STEMDIRECTION GetDrawingStemDir() const { return m_drawingStemDir; }
126 
132  std::set<int> GetLayersNForTimeSpanOf(const LayerElement *element) const;
133  int GetLayerCountForTimeSpanOf(const LayerElement *element) const;
135 
141  std::set<int> GetLayersNInTimeSpan(
142  const Fraction &time, const Fraction &duration, const Measure *measure, int staff) const;
143  int GetLayerCountInTimeSpan(
144  const Fraction &time, const Fraction &duration, const Measure *measure, int staff) const;
146 
153  ListOfObjects GetLayerElementsForTimeSpanOf(const LayerElement *element, bool excludeCurrent = false);
154  ListOfConstObjects GetLayerElementsForTimeSpanOf(const LayerElement *element, bool excludeCurrent = false) const;
156 
163  const Fraction &time, const Fraction &duration, const Measure *measure, int staff, bool excludeCurrent);
164  ListOfConstObjects GetLayerElementsInTimeSpan(
165  const Fraction &time, const Fraction &duration, const Measure *measure, int staff, bool excludeCurrent) const;
167 
173  const Clef *GetCurrentClef() const;
174  KeySig *GetCurrentKeySig();
175  const KeySig *GetCurrentKeySig() const;
176  Mensur *GetCurrentMensur();
177  const Mensur *GetCurrentMensur() const;
178  MeterSig *GetCurrentMeterSig();
179  const MeterSig *GetCurrentMeterSig() const;
180  Proport *GetCurrentProport();
181  const Proport *GetCurrentProport() const;
183 
184  void ResetStaffDefObjects();
185 
190  void SetDrawingStaffDefValues(StaffDef *currentStaffDef);
191  bool GetDrawingStaffDefValues(StaffDef *staffDef) const;
192 
193  bool DrawKeySigCancellation() const { return m_drawKeySigCancellation; }
194  void SetDrawKeySigCancellation(bool drawKeySigCancellation) { m_drawKeySigCancellation = drawKeySigCancellation; }
195 
196  Clef *GetStaffDefClef() { return m_staffDefClef; }
197  const Clef *GetStaffDefClef() const { return m_staffDefClef; }
198  KeySig *GetStaffDefKeySig() { return m_staffDefKeySig; }
199  const KeySig *GetStaffDefKeySig() const { return m_staffDefKeySig; }
200  Mensur *GetStaffDefMensur() { return m_staffDefMensur; }
201  const Mensur *GetStaffDefMensur() const { return m_staffDefMensur; }
202  MeterSig *GetStaffDefMeterSig() { return m_staffDefMeterSig; }
203  const MeterSig *GetStaffDefMeterSig() const { return m_staffDefMeterSig; }
204  MeterSigGrp *GetStaffDefMeterSigGrp() { return m_staffDefMeterSigGrp; }
205  const MeterSigGrp *GetStaffDefMeterSigGrp() const { return m_staffDefMeterSigGrp; }
206 
207  bool HasStaffDef() const
208  {
209  return (m_staffDefClef || m_staffDefKeySig || m_staffDefMensur || m_staffDefMeterSig || m_staffDefMeterSigGrp);
210  }
211 
212  bool DrawOssiaStaffDef() const { return m_drawOssiaStaffDef; }
213  void SetDrawOssiaStaffDef(bool drawOssiaStaffDef) { m_drawOssiaStaffDef = drawOssiaStaffDef; }
215 
220  void SetDrawingCautionValues(StaffDef *currentStaffDef);
221 
222  bool DrawCautionKeySigCancel() const { return m_drawCautionKeySigCancel; }
223  void SetDrawCautionKeySigCancel(bool drawCautionKeySig) { m_drawCautionKeySigCancel = drawCautionKeySig; }
224 
225  Clef *GetCautionStaffDefClef() { return m_cautionStaffDefClef; }
226  const Clef *GetCautionStaffDefClef() const { return m_cautionStaffDefClef; }
227  KeySig *GetCautionStaffDefKeySig() { return m_cautionStaffDefKeySig; }
228  const KeySig *GetCautionStaffDefKeySig() const { return m_cautionStaffDefKeySig; }
229  Mensur *GetCautionStaffDefMensur() { return m_cautionStaffDefMensur; }
230  const Mensur *GetCautionStaffDefMensur() const { return m_cautionStaffDefMensur; }
231  MeterSig *GetCautionStaffDefMeterSig() { return m_cautionStaffDefMeterSig; }
232  const MeterSig *GetCautionStaffDefMeterSig() const { return m_cautionStaffDefMeterSig; }
233 
234  bool HasCautionStaffDef() const
235  {
236  return (
237  m_cautionStaffDefClef || m_cautionStaffDefKeySig || m_cautionStaffDefMensur || m_cautionStaffDefMeterSig);
238  }
240 
245  void SetCrossStaffFromAbove(bool crossStaff) { m_crossStaffFromAbove = crossStaff; }
246  bool HasCrossStaffFromAbove() const { return m_crossStaffFromAbove; }
247  void SetCrossStaffFromBelow(bool crossStaff) { m_crossStaffFromBelow = crossStaff; }
248  bool HasCrossStaffFromBelow() const { return m_crossStaffFromBelow; }
250 
255  bool HasCursor() const { return (m_cursor); }
256  Cursor *GetCursor() const { return m_cursor; }
257  void SetCursor(Cursor *cursor);
258  void ResetCursor();
260 
261  //----------//
262  // Functors //
263  //----------//
264 
269  FunctorCode Accept(Functor &functor) override;
270  FunctorCode Accept(ConstFunctor &functor) const override;
271  FunctorCode AcceptEnd(Functor &functor) override;
272  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
274 
275 private:
276  //
277 public:
278  //
279 private:
283  data_STEMDIRECTION m_drawingStemDir;
284 
288  bool m_crossStaffFromBelow;
289  bool m_crossStaffFromAbove;
290 
292  Clef *m_staffDefClef;
293  KeySig *m_staffDefKeySig;
294  Mensur *m_staffDefMensur;
295  MeterSig *m_staffDefMeterSig;
296  MeterSigGrp *m_staffDefMeterSigGrp;
297  bool m_drawKeySigCancellation;
298  bool m_drawOssiaStaffDef;
299 
301  Clef *m_cautionStaffDefClef;
302  KeySig *m_cautionStaffDefKeySig;
303  Mensur *m_cautionStaffDefMensur;
304  MeterSig *m_cautionStaffDefMeterSig;
305  bool m_drawCautionKeySigCancel;
306 
308  Cursor *m_cursor;
309 };
310 
311 } // namespace vrv
312 
313 #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.
Clef * GetClefFacs(const LayerElement *test)
Get the current clef based on facsimile for the test element.
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:925
This class models the MEI <proport> element.
Definition: proport.h:23
This class represents a MEI staffDef.
Definition: staffdef.h:37