00001 #ifndef GUIDOScoreMap_H
00002 #define GUIDOScoreMap_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef WIN32
00018 # pragma warning (disable : 4661) // don't know how to solve it
00019 #endif
00020
00021 #include "GUIDOExport.h"
00022 #include "GUIDOEngine.h"
00023 #include "TRect.h"
00024
00025 #include <utility>
00026 #include <vector>
00027 #include <map>
00028 #include <iostream>
00029
00030
00036
00037
00038 typedef enum {
00039 kGuidoPage, kGuidoSystem, kGuidoSystemSlice, kGuidoStaff, kGuidoBar, kGuidoEvent,
00040 kGuidoScoreElementEnd
00041 } GuidoElementSelector;
00042
00043
00044 typedef enum {
00045 kNote = 1, kRest, kEmpty, kBar, kRepeatBegin, kRepeatEnd, kStaff, kSystemSlice, kSystem, kPage
00046 } GuidoElementType;
00047
00048
00049 typedef struct {
00050 GuidoElementType type;
00051 int staffNum;
00052 int voiceNum;
00053 int midiPitch;
00054 } GuidoElementInfos;
00055
00056
00057
00061 class_export TimeSegment: public std::pair<GuidoDate, GuidoDate>
00062 {
00063 public:
00064 TimeSegment () {}
00065 TimeSegment (const TimeSegment& s) : std::pair<GuidoDate, GuidoDate>(s.first, s.second) {}
00066 TimeSegment (const GuidoDate& a, const GuidoDate& b) : std::pair<GuidoDate, GuidoDate>(a, b) {}
00067 virtual ~TimeSegment () {}
00068
00069 void print(std::ostream& out) const;
00070 bool empty() const;
00071 bool intersect(const TimeSegment& ts) const;
00072 bool include(const GuidoDate& date) const;
00073 bool include(const TimeSegment& ts) const;
00074 bool operator < (const TimeSegment& ts) const;
00075 bool operator == (const TimeSegment& ts) const;
00076 TimeSegment operator & (const TimeSegment& ts) const;
00077 };
00078
00079 typedef std::vector<std::pair<TimeSegment, FloatRect> > Time2GraphicMap;
00080
00081 inline std::ostream& operator << (std::ostream& out, const GuidoDate& d) {
00082 out << d.num << "/" << d.denom;
00083 return out;
00084 }
00085
00086 inline std::ostream& operator << (std::ostream& out, const TimeSegment& s) {
00087 s.print(out);
00088 return out;
00089 }
00090
00091
00092
00093
00094 class MapCollector
00095 {
00096 public:
00097 virtual ~MapCollector() {}
00098
00105 virtual void Graph2TimeMap( const FloatRect& box, const TimeSegment& dates, const GuidoElementInfos& infos ) = 0;
00106 };
00107
00108
00109 class RectInfos {
00110 TimeSegment fTime;
00111 GuidoElementInfos fInfos;
00112 public:
00113 RectInfos (const TimeSegment& ts, const GuidoElementInfos& infos) : fTime(ts), fInfos(infos) {}
00114 virtual ~RectInfos () {}
00115
00116 const TimeSegment& time() const { return fTime; }
00117 const GuidoElementInfos& infos() const { return fInfos; }
00118 };
00119
00120 typedef std::pair<FloatRect, RectInfos> MapElement;
00121
00122
00123
00124
00125
00126 class TimeMapCollector
00127 {
00128 public:
00129 virtual ~TimeMapCollector() {}
00130
00136 virtual void Time2TimeMap( const TimeSegment& from, const TimeSegment& to ) = 0;
00137 };
00138
00139 #ifdef __cplusplus
00140 extern "C" {
00141 #endif
00142
00153 GUIDOAPI(GuidoErrCode) GuidoGetMap( CGRHandler gr, int pagenum, float width, float height,
00154 GuidoElementSelector sel, MapCollector& f);
00155
00156
00166 GUIDOAPI(GuidoErrCode) GuidoGetPageMap( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
00167
00178 GUIDOAPI(GuidoErrCode) GuidoGetStaffMap( CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap& outmap);
00179
00190 GUIDOAPI(GuidoErrCode) GuidoGetVoiceMap( CGRHandler gr, int pagenum, float w, float h, int voice, Time2GraphicMap& outmap);
00191
00201 GUIDOAPI(GuidoErrCode) GuidoGetSystemMap( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
00202
00211 GUIDOAPI(bool) GuidoGetTime( const GuidoDate& date, const Time2GraphicMap map, TimeSegment& t, FloatRect& r);
00212
00222 GUIDOAPI(bool) GuidoGetPoint( float x, float y, const Time2GraphicMap map, TimeSegment& t, FloatRect& r);
00223
00232 #ifdef WIN32
00233 __declspec(deprecated("Deprecated function (not maintained code)."))
00234 #endif
00235 GUIDOAPI(GuidoErrCode) GuidoGetSVGMap( GRHandler gr, int pagenum, GuidoElementSelector sel, std::vector<MapElement>& outMap) GUIDOAPI_deprecated;
00236
00243 GUIDOAPI(GuidoErrCode) GuidoGetTimeMap( CARHandler gr, TimeMapCollector& f);
00244
00245
00248 #ifdef __cplusplus
00249 }
00250 #endif
00251
00252 #endif
00253
00254
00255