GUIDOLib  1.7.7
A Music Score Rendering Engine
GUIDOScoreMap.h
Go to the documentation of this file.
1 #ifndef GUIDOScoreMap_H
2 #define GUIDOScoreMap_H
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2004 Grame
7 
8  This Source Code Form is subject to the terms of the Mozilla Public
9  License, v. 2.0. If a copy of the MPL was not distributed with this
10  file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 
12  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
13  research@grame.fr
14 
15 */
16 
17 #ifdef WIN32
18 # pragma warning (disable : 4661) // don't know how to solve it
19 #endif
20 
21 #include "GUIDOExport.h"
22 #include "GUIDOEngine.h"
23 #include "TRect.h"
24 
25 #include <utility>
26 #include <vector>
27 #include <map>
28 #include <iostream>
29 
30 
38 //------------------------------------------------------------------------------
39 // graphic elements selector definitions
40 typedef enum {
44 
45 // graphic elements type definitions
46 typedef enum {
49 
50 
55 typedef struct {
57  int staffNum;
58  int voiceNum;
59  int midiPitch;
61 
62 
63 //----------------------------------------------------------------------
67 class_export TimeSegment: public std::pair<GuidoDate, GuidoDate>
68 {
69  public:
70  TimeSegment () {}
71  TimeSegment (const TimeSegment& s) : std::pair<GuidoDate, GuidoDate>(s.first, s.second) {}
72  TimeSegment (const GuidoDate& a, const GuidoDate& b) : std::pair<GuidoDate, GuidoDate>(a, b) {}
73  virtual ~TimeSegment () {}
74 
75  void print(std::ostream& out) const;
76  float duration() const;
77  bool empty() const;
78  bool intersect(const TimeSegment& ts) const;
79  bool include(const GuidoDate& date) const;
80  bool include(const TimeSegment& ts) const;
81  bool startEqual(const TimeSegment& ts) const;
82  bool operator < (const TimeSegment& ts) const;
83  bool operator == (const TimeSegment& ts) const;
84  TimeSegment operator & (const TimeSegment& ts) const;
85 };
86 
87 typedef std::pair<TimeSegment, FloatRect> TMapSegments;
88 typedef std::pair<TimeSegment, TimeSegment> TTimeMapSegments;
89 typedef std::vector<TMapSegments> Time2GraphicMap;
90 typedef std::vector<TTimeMapSegments> TTime2TimeMap;
91 typedef Time2GraphicMap::const_iterator Time2GraphicMapIterator;
92 
93 inline std::ostream& operator << (std::ostream& out, const GuidoDate& d) {
94  out << d.num << "/" << d.denom;
95  return out;
96 }
97 
98 inline std::ostream& operator << (std::ostream& out, const TimeSegment& s) {
99  s.print(out);
100  return out;
101 }
102 
103 
104 //------------------------------------------------------------------------------
105 // mapping collector abstract class definition
110 {
111  public:
112  virtual ~MapCollector() {}
113 
120  virtual void Graph2TimeMap( const FloatRect& box, const TimeSegment& dates, const GuidoElementInfos& infos ) = 0;
121 };
122 
123 //------------------------------------------------------------------------------
127 class RectInfos {
128  TimeSegment fTime;
129  GuidoElementInfos fInfos;
130  public:
131  RectInfos (const TimeSegment& ts, const GuidoElementInfos& infos) : fTime(ts), fInfos(infos) {}
132  virtual ~RectInfos () {}
133 
134  const TimeSegment& time() const { return fTime; }
135  const GuidoElementInfos& infos() const { return fInfos; }
136 };
137 
138 typedef std::pair<FloatRect, RectInfos> MapElement;
139 
140 
141 
142 //------------------------------------------------------------------------------
143 // time mapping collector abstract class definition
148 {
149  public:
150  virtual ~TimeMapCollector() {}
151 
157  virtual void Time2TimeMap( const TimeSegment& from, const TimeSegment& to ) = 0;
158 };
159 
160 typedef std::pair<TimeSegment, TimeSegment> TimeMapElement;
161 
162 #ifdef __cplusplus
163 extern "C" {
164 #endif
165 
176 GUIDOAPI GuidoErrCode GuidoGetMap( CGRHandler gr, int pagenum, float width, float height,
178 
189 GUIDOAPI GuidoErrCode GuidoGetRAWStaffMap( CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap& outmap);
190 
201 GUIDOAPI GuidoErrCode GuidoGetRAWVoiceMap( CGRHandler gr, int pagenum, float w, float h, int voice, Time2GraphicMap& outmap);
202 
212 GUIDOAPI GuidoErrCode GuidoGetRAWSystemMap( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
213 
223 GUIDOAPI GuidoErrCode GuidoGetPageMap( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
224 
236 GUIDOAPI GuidoErrCode GuidoGetStaffMap( CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap& outmap);
237 
248 GUIDOAPI GuidoErrCode GuidoGetStaffMapV1( CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap& outmap);
249 
260 GUIDOAPI GuidoErrCode GuidoGetVoiceMap( CGRHandler gr, int pagenum, float w, float h, int voice, Time2GraphicMap& outmap);
261 
272 GUIDOAPI GuidoErrCode GuidoGetSystemMap( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
273 
283 GUIDOAPI GuidoErrCode GuidoGetSystemMapV1( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
284 
293 GUIDOAPI bool GuidoGetTime( const GuidoDate& date, const Time2GraphicMap map, TimeSegment& t, FloatRect& r);
294 
304 GUIDOAPI bool GuidoGetPoint( float x, float y, const Time2GraphicMap map, TimeSegment& t, FloatRect& r);
305 
314 #ifdef WIN32
315  __declspec(deprecated("Deprecated function (not maintained code)."))
316 #endif
317 GUIDOAPI GuidoErrCode GuidoGetSVGMap( GRHandler gr, int pagenum, GuidoElementSelector sel, std::vector<MapElement>& outMap) GUIDOAPI_deprecated;
318 
326 
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 #endif
335 
336 
337 
MapElement
std::pair< FloatRect, RectInfos > MapElement
Definition: GUIDOScoreMap.h:138
kPage
Definition: GUIDOScoreMap.h:47
GuidoGetTimeMap
GuidoErrCode GuidoGetTimeMap(CARHandler ar, TimeMapCollector &f)
Retrieves the rolled to unrolled time mapping.
TMapSegments
std::pair< TimeSegment, FloatRect > TMapSegments
Definition: GUIDOScoreMap.h:85
MapCollector::Graph2TimeMap
virtual void Graph2TimeMap(const FloatRect &box, const TimeSegment &dates, const GuidoElementInfos &infos)=0
a method called by the GuidoGetMap function
GuidoDate::num
int num
the date numerator
Definition: GUIDOEngine.h:86
MapCollector
an abstract class to be provided by clients to collect mappings
Definition: GUIDOScoreMap.h:109
kGuidoScoreElementEnd
Definition: GUIDOScoreMap.h:42
RectInfos::RectInfos
RectInfos(const TimeSegment &ts, const GuidoElementInfos &infos)
Definition: GUIDOScoreMap.h:131
intersect
bool intersect(const TimeSegment &ts) const
check for segments intersection
RectInfos
information associated to a rectangle in a mapping (MapElement)
Definition: GUIDOScoreMap.h:127
kMeterSel
Definition: GUIDOScoreMap.h:41
TimeMapCollector::~TimeMapCollector
virtual ~TimeMapCollector()
Definition: GUIDOScoreMap.h:150
GUIDOEngine.h
GuidoGetSVGMap
GuidoErrCode GuidoGetSVGMap(GRHandler gr, int pagenum, GuidoElementSelector sel, std::vector< MapElement > &outMap) GUIDOAPI_deprecated
Retrieves the graphic to time mapping corresponding to the SVG output.
operator==
bool operator==(const TimeSegment &ts) const
GuidoGetRAWSystemMap
GuidoErrCode GuidoGetRAWSystemMap(CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap &outmap)
Retrieves a guido system graphic to time mapping, without any processing (RAW).
kBar
Definition: GUIDOScoreMap.h:47
TimeMapCollector::Time2TimeMap
virtual void Time2TimeMap(const TimeSegment &from, const TimeSegment &to)=0
a method called by the GuidoGetTimeMap function
kGuidoBarAndEvent
Definition: GUIDOScoreMap.h:41
TimeSegment
class_export TimeSegment
a time segment definition and operations
Definition: GUIDOScoreMap.h:67
kRepeatEnd
Definition: GUIDOScoreMap.h:47
TTimeMapSegments
std::pair< TimeSegment, TimeSegment > TTimeMapSegments
Definition: GUIDOScoreMap.h:88
Time2GraphicMapIterator
Time2GraphicMap::const_iterator Time2GraphicMapIterator
Definition: GUIDOScoreMap.h:91
operator<<
std::ostream & operator<<(std::ostream &out, const GuidoDate &d)
Definition: GUIDOScoreMap.h:93
kGuidoStaff
Definition: GUIDOScoreMap.h:41
MapCollector::~MapCollector
virtual ~MapCollector()
Definition: GUIDOScoreMap.h:112
GuidoElementInfos::midiPitch
int midiPitch
the element midi pitch, or -1 when na
Definition: GUIDOScoreMap.h:59
CGRHandler
const struct NodeGR * CGRHandler
Definition: GUIDOEngine.h:39
kClefSel
Definition: GUIDOScoreMap.h:41
RectInfos::time
const TimeSegment & time() const
Definition: GUIDOScoreMap.h:134
GuidoGetPoint
bool GuidoGetPoint(float x, float y, const Time2GraphicMap map, TimeSegment &t, FloatRect &r)
Retrieves a time segment and the associated graphic segment in a mapping.
kGuidoBar
Definition: GUIDOScoreMap.h:41
GUIDOAPI
#define GUIDOAPI
Definition: GUIDOExport.h:39
GuidoElementInfos::voiceNum
int voiceNum
the element voice number or 0 when na
Definition: GUIDOScoreMap.h:58
kGuidoEvent
Definition: GUIDOScoreMap.h:41
GUIDOAPI_deprecated
#define GUIDOAPI_deprecated
Definition: GUIDOEngine.h:28
kNote
Definition: GUIDOScoreMap.h:47
duration
float duration() const
gives the segment duration
kGuidoPage
Definition: GUIDOScoreMap.h:41
GuidoGetSystemMap
GuidoErrCode GuidoGetSystemMap(CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap &outmap)
Retrieves a guido system graphic to time mapping. New behaviour: if all staves have a rest at a same ...
operator<
bool operator<(const TimeSegment &ts) const
order relationship: the smaller is the smaller first date
empty
bool empty() const
check for empty segment
RectInfos::~RectInfos
virtual ~RectInfos()
Definition: GUIDOScoreMap.h:132
Time2GraphicMap
std::vector< TMapSegments > Time2GraphicMap
Definition: GUIDOScoreMap.h:89
GuidoErrCode
GuidoErrCode
The guido error codes list.
Definition: GUIDOEngine.h:211
GUIDOExport.h
GuidoGetRAWVoiceMap
GuidoErrCode GuidoGetRAWVoiceMap(CGRHandler gr, int pagenum, float w, float h, int voice, Time2GraphicMap &outmap)
Retrieves a guido voice graphic to time mapping, without any processing (RAW).
GuidoElementInfos::type
GuidoElementType type
the element type
Definition: GUIDOScoreMap.h:56
GuidoGetStaffMap
GuidoErrCode GuidoGetStaffMap(CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap &outmap)
Retrieves a guido staff graphic to time mapping. New behaviour: if a rest is at a bar start,...
kGuidoSystem
Definition: GUIDOScoreMap.h:41
kGraceNote
Definition: GUIDOScoreMap.h:47
GuidoDate
Representation of a date as a rational value.
Definition: GUIDOEngine.h:83
GuidoGetRAWStaffMap
GuidoErrCode GuidoGetRAWStaffMap(CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap &outmap)
Retrieves a guido staff graphic to time mapping, without any processing (RAW).
kSystem
Definition: GUIDOScoreMap.h:47
kGuidoSystemSlice
Definition: GUIDOScoreMap.h:41
kStaff
Definition: GUIDOScoreMap.h:47
operator&
TimeSegment operator&(const TimeSegment &ts) const
intersection operation (may return an arbitrary empty segment)
GuidoElementInfos
Information related to elements.
Definition: GUIDOScoreMap.h:55
GuidoDate::denom
int denom
the date denominator
Definition: GUIDOEngine.h:88
RectInfos::infos
const GuidoElementInfos & infos() const
Definition: GUIDOScoreMap.h:135
kRest
Definition: GUIDOScoreMap.h:47
kEmpty
Definition: GUIDOScoreMap.h:47
GRHandler
struct NodeGR * GRHandler
Definition: GUIDOEngine.h:37
GuidoGetPageMap
GuidoErrCode GuidoGetPageMap(CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap &outmap)
Retrieves a guido page graphic to time mapping.
GuidoGetSystemMapV1
GuidoErrCode GuidoGetSystemMapV1(CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap &outmap)
Retrieves a guido system graphic to time mapping. To use the new behaviour, see GuidoGetSystemMap.
GuidoElementInfos::staffNum
int staffNum
the element staff number or 0 when na
Definition: GUIDOScoreMap.h:57
kMeter
Definition: GUIDOScoreMap.h:47
kSystemSlice
Definition: GUIDOScoreMap.h:47
GuidoGetStaffMapV1
GuidoErrCode GuidoGetStaffMapV1(CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap &outmap)
Retrieves a guido staff graphic to time mapping. To use the new behaviour, see GuidoGetStaffMap.
kClef
Definition: GUIDOScoreMap.h:47
GuidoElementSelector
GuidoElementSelector
Definition: GUIDOScoreMap.h:40
class_export
#define class_export
Definition: GUIDOExport.h:38
TTime2TimeMap
std::vector< TTimeMapSegments > TTime2TimeMap
Definition: GUIDOScoreMap.h:90
include
bool include(const GuidoDate &date) const
check for date inclusion
TimeMapElement
std::pair< TimeSegment, TimeSegment > TimeMapElement
Definition: GUIDOScoreMap.h:160
startEqual
bool startEqual(const TimeSegment &ts) const
check if start date is the same
GuidoGetVoiceMap
GuidoErrCode GuidoGetVoiceMap(CGRHandler gr, int pagenum, float w, float h, int voice, Time2GraphicMap &outmap)
Retrieves a guido voice graphic to time mapping.
GuidoGetTime
bool GuidoGetTime(const GuidoDate &date, const Time2GraphicMap map, TimeSegment &t, FloatRect &r)
Retrieves a time segment and the associated graphic segment in a mapping.
kRepeatBegin
Definition: GUIDOScoreMap.h:47
GuidoElementType
GuidoElementType
Definition: GUIDOScoreMap.h:46
GuidoGetMap
GuidoErrCode GuidoGetMap(CGRHandler gr, int pagenum, float width, float height, GuidoElementSelector sel, MapCollector &f)
Retrieves the graphic to time mapping, without any processing (RAW)
CARHandler
const struct NodeAR * CARHandler
Definition: GUIDOEngine.h:38
TimeMapCollector
an abstract class to be provided by clients to collect time mappings
Definition: GUIDOScoreMap.h:147

Guido Project Copyright © 2019 Grame-CNCM