00001 #ifndef GUIDOMap_H
00002 #define GUIDOMap_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 } GuidoeElementSelector;
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 } GuidoElementInfos;
00054
00055
00056
00060 class_export TimeSegment: public std::pair<GuidoDate, GuidoDate>
00061 {
00062 public:
00063 TimeSegment () {}
00064 TimeSegment (const TimeSegment& s) : std::pair<GuidoDate, GuidoDate>(s.first, s.second) {}
00065 TimeSegment (const GuidoDate& a, const GuidoDate& b) : std::pair<GuidoDate, GuidoDate>(a, b) {}
00066 virtual ~TimeSegment () {}
00067
00068 void print(std::ostream& out) const;
00069 bool empty() const;
00070 bool intersect(const TimeSegment& ts) const;
00071 bool include(const GuidoDate& date) const;
00072 bool include(const TimeSegment& ts) const;
00073 bool operator < (const TimeSegment& ts) const;
00074 bool operator == (const TimeSegment& ts) const;
00075 TimeSegment operator & (const TimeSegment& ts) const;
00076 };
00077
00078 typedef std::vector<std::pair<TimeSegment, FloatRect> > Time2GraphicMap;
00079
00080 inline std::ostream& operator << (std::ostream& out, const GuidoDate& d) {
00081 out << d.num << "/" << d.denom;
00082 return out;
00083 }
00084
00085 inline std::ostream& operator << (std::ostream& out, const TimeSegment& s) {
00086 s.print(out);
00087 return out;
00088 }
00089
00090
00091
00092
00093 class MapCollector
00094 {
00095 public:
00096 virtual ~MapCollector() {}
00097
00104 virtual void Graph2TimeMap( const FloatRect& box, const TimeSegment& dates, const GuidoElementInfos& infos ) = 0;
00105 };
00106
00107
00108 class RectInfos {
00109 TimeSegment fTime;
00110 GuidoElementInfos fInfos;
00111 public:
00112 RectInfos (const TimeSegment& ts, const GuidoElementInfos& infos) : fTime(ts), fInfos(infos) {}
00113 virtual ~RectInfos () {}
00114
00115 const TimeSegment& time() const { return fTime; }
00116 const GuidoElementInfos& infos() const { return fInfos; }
00117 };
00118
00119 typedef std::pair<FloatRect, RectInfos> MapElement;
00120
00121
00122
00123
00124
00125 class TimeMapCollector
00126 {
00127 public:
00128 virtual ~TimeMapCollector() {}
00129
00135 virtual void Time2TimeMap( const TimeSegment& from, const TimeSegment& to ) = 0;
00136 };
00137
00138 #ifdef __cplusplus
00139 extern "C" {
00140 #endif
00141
00152 GUIDOAPI(GuidoErrCode) GuidoGetMap( CGRHandler gr, int pagenum, float width, float height,
00153 GuidoeElementSelector sel, MapCollector& f);
00154
00155
00165 GUIDOAPI(GuidoErrCode) GuidoGetPageMap( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
00166
00177 GUIDOAPI(GuidoErrCode) GuidoGetStaffMap( CGRHandler gr, int pagenum, float w, float h, int staff, Time2GraphicMap& outmap);
00178
00189 GUIDOAPI(GuidoErrCode) GuidoGetVoiceMap( CGRHandler gr, int pagenum, float w, float h, int voice, Time2GraphicMap& outmap);
00190
00200 GUIDOAPI(GuidoErrCode) GuidoGetSystemMap( CGRHandler gr, int pagenum, float w, float h, Time2GraphicMap& outmap);
00201
00210 GUIDOAPI(bool) GuidoGetTime( const GuidoDate& date, const Time2GraphicMap map, TimeSegment& t, FloatRect& r);
00211
00221 GUIDOAPI(bool) GuidoGetPoint( float x, float y, const Time2GraphicMap map, TimeSegment& t, FloatRect& r);
00222
00231 GUIDOAPI(GuidoErrCode) GuidoGetSVGMap( GRHandler gr, int pagenum, GuidoeElementSelector sel, std::vector<MapElement>& outMap);
00232
00239 GUIDOAPI(GuidoErrCode) GuidoGetTimeMap( CARHandler gr, TimeMapCollector& f);
00240
00241
00244 #ifdef __cplusplus
00245 }
00246 #endif
00247
00248 #endif
00249
00250
00251