GUIDOLib  1.7.7
A Music Score Rendering Engine
GUIDOEngineAdapter.h
Go to the documentation of this file.
1 #ifndef GUIDOENGINEADAPTER_H
2 #define GUIDOENGINEADAPTER_H
3 /*
4  GUIDO Library
5  Copyright (C) 2014 Grame
6 
7  This Source Code Form is subject to the terms of the Mozilla Public
8  License, v. 2.0. If a copy of the MPL was not distributed with this
9  file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
12  research@grame.fr
13 
14 */
15 
16 #include <string>
17 #include <ostream>
18 #include "GUIDOEngine.h"
19 
20 class GuidoParser;
21 class GuidoStream;
22 
23 
27 typedef struct {
29  int line;
31  int col;
33  std::string msg;
34 } ParserError;
35 
39 typedef struct {
41  int major;
43  int minor;
45  int sub;
47  std::string str;
48 } GuidoVersion;
49 
64 {
65  public:
73  virtual ~GuidoEngineAdapter();
74 
75 
91 
99 
107  void shutdown();
108 
115  GuidoErrCode ar2gmn(ARHandler ar, std::ostream& to);
116 
128 
140  GRHandler ar2gr(ARHandler ar, const GuidoLayoutSettings &settings);
141 
149 
156  GuidoErrCode updateGR(GRHandler gr, const GuidoLayoutSettings &settings);
157 
163  void freeAR(ARHandler ar);
164 
170  void freeGR(GRHandler gr);
171 
178  std::string getErrorString(GuidoErrCode errCode);
179 
186 
194  GuidoErrCode showElement( GRHandler gr, int elt, bool status);
213  int countVoices(CARHandler inHandleAR);
214 
220  int getPageCount(CGRHandler inHandleGR);
221 
228  int getSystemCount(CGRHandler inHandleGR, int page);
229 
238  GuidoDate duration(CGRHandler inHandleGR);
239 
248  int findEventPage(CGRHandler inHandleGR, const GuidoDate& date);
249 
258  int findPageAt(CGRHandler inHandleGR, const GuidoDate& date);
259 
266  GuidoDate getPageDate(CGRHandler inHandleGR, int pageNum);
285 
296  std::string gr2SVG( const GRHandler handle, int page, std::ostream& out, int w, int h, bool embedFont = true );
297 
308  GuidoErrCode gr2SVG( const GRHandler handle, int page, std::ostream& out, bool embedFont = true, const char* font = 0, const int mappingMode = 0 );
309 
318  std::string gr2SVG(const GRHandler handle, int page, bool embedfont = true, const int mappingMode = 0);
319 
330  std::string gr2SVGColored(const GRHandler handle, int page, int r, int g, int b, bool embedfont=true);
331 
339  GuidoErrCode abstractExport(const GRHandler handle, int page, std::ostream& out);
340 
347  std::string abstractExport(const GRHandler handle, int page);
348 
356  GuidoErrCode binaryExport(const GRHandler handle, int page, std::ostream& out);
357 
364  std::string binaryExport(const GRHandler handle, int page);
365 
366 #ifdef CANVASSYSTEM
367 
373  GuidoErrCode javascriptExport(const GRHandler handle, int page);
374 #endif
375 
379  void setDrawBoundingBoxes(int bbMap);
380 
384  int getDrawBoundingBoxes();
385 
392  GuidoPageFormat getPageFormat(CGRHandler inHandleGR, int pageNum);
393 
407  void setDefaultPageFormat(const GuidoPageFormat &format);
408 
414 
415 
421  float unit2CM(float val);
422 
428  float cm2Unit(float val);
429 
435  float unit2Inches(float val);
436 
442  float inches2Unit(float val);
443 
467  std::string getVersionStr();
468 
478  GuidoErrCode checkVersionNums(int major, int minor, int sub);
479 
480 
488  float getLineSpace();
489 
490 
505  GuidoErrCode markVoice( ARHandler inHandleAR, int voicenum,
506  const GuidoDate & date, const GuidoDate & duration,
507  unsigned char red, unsigned char green, unsigned char blue );
508 
509 
517  GuidoErrCode setSymbolPath(ARHandler inHandleAR, const std::vector<std::string> &inPaths);
518 
519 
525  std::vector<std::string> getSymbolPath(const ARHandler inHandleAR);
526 
541  long getParsingTime (const ARHandler ar);
542 
548  long getAR2GRTime(const GRHandler gr);
549 
555  long getOnDrawTime(const GRHandler gr);
556 
568  GuidoParser * openParser();
569 
575  GuidoErrCode closeParser(GuidoParser *p);
576 
583  ARHandler file2AR(GuidoParser *parser, const std::string &file);
584 
591  ARHandler string2AR(GuidoParser *parser, const std::string &gmnCode);
592 
598  std::string getStream(const GuidoStream *gStream) const;
599 
607  ARHandler stream2AR(GuidoParser *p, GuidoStream* stream);
608 
614  ParserError parserGetErrorCode(GuidoParser *p);
615 
623  GuidoStream * openStream ();
624 
630  GuidoErrCode closeStream (GuidoStream *s);
631 
654  GuidoErrCode writeStream (GuidoStream *s, const std::string &str);
655 
662  GuidoErrCode resetStream (GuidoStream *s);
663 
665 };
669 #endif // GUIDOENGINEADAPTER_H
onDraw
GuidoErrCode onDraw(GuidoOnDrawDesc *desc)
Draws one page of score into a graphic device.
unit2Inches
float unit2Inches(float val)
Converts internal Guido units into inches.
cm2Unit
float cm2Unit(float val)
Converts centimeters into internal Guido units.
getVersionStr
std::string getVersionStr()
GuidoInitDesc
A data structure containing all information required by GuidoInit()
Definition: GUIDOEngine.h:49
countVoices
int countVoices(CARHandler inHandleAR)
Gives the number of score pages of the graphic representation.
init
GuidoErrCode init(GuidoInitDesc *desc)
Initialises the Guido Engine. Must be called before any attempt to read a Guido file or to use the Gu...
ar2gr
GRHandler ar2gr(ARHandler ar)
Transforms a Guido abstract representation into a Guido graphic representation. The engine applies la...
GuidoOnDrawDesc
Contains all graphic-related information required by GuidoOnDraw()
Definition: GUIDOEngine.h:152
getLineSpace
float getLineSpace()
Gives the distance between two staff lines.
closeStream
GuidoErrCode closeStream(GuidoStream *s)
Close a guido stream.
openStream
GuidoStream * openStream()
Open a guido stream.
freeGR
void freeGR(GRHandler gr)
Releases a Guido graphic representation. Don't release the ARHandler refenrece in the GRHandler befor...
file2AR
ARHandler file2AR(GuidoParser *parser, const std::string &file)
Parse a file and create the corresponding AR.
GUIDOEngine.h
duration
GuidoDate duration(CGRHandler inHandleGR)
Returns the music duration of a score.
setSymbolPath
GuidoErrCode setSymbolPath(ARHandler inHandleAR, const std::vector< std::string > &inPaths)
Makes the correspondance between an ARMusic and a path.
resizePageToMusic
GuidoErrCode resizePageToMusic(GRHandler inHandleGR)
Resize the page sizes to the music size.
binaryExport
GuidoErrCode binaryExport(const GRHandler handle, int page, std::ostream &out)
Exports an representation of GUIDO draw commands in a data-reduced dsl.
getPageDate
GuidoDate getPageDate(CGRHandler inHandleGR, int pageNum)
Gives the time location of a Page.
getVersion
GuidoVersion getVersion()
Gives the library version number as three integers.
GuidoPageFormat
The page format parameters.
Definition: GUIDOEngine.h:316
markVoice
GuidoErrCode markVoice(ARHandler inHandleAR, int voicenum, const GuidoDate &date, const GuidoDate &duration, unsigned char red, unsigned char green, unsigned char blue)
Gives a color to all notes of a voice between a given time interval.
getAR2GRTime
long getAR2GRTime(const GRHandler gr)
Gets AR to GR procedure time.
getOnDrawTime
long getOnDrawTime(const GRHandler gr)
Gets GR drawing procedure time.
shutdown
void shutdown()
Guido Engine shutdown.
CGRHandler
const struct NodeGR * CGRHandler
Definition: GUIDOEngine.h:39
writeStream
GuidoErrCode writeStream(GuidoStream *s, const std::string &str)
Write data to the stream.
getParsingTime
long getParsingTime(const ARHandler ar)
Gets parsing time.
abstractExport
GuidoErrCode abstractExport(const GRHandler handle, int page, std::ostream &out)
Exports an abstract representation of GUIDO draw commands.
GuidoEngineAdapter
class_export GuidoEngineAdapter
Definition: GUIDOEngineAdapter.h:64
updateGR
GuidoErrCode updateGR(GRHandler gr)
Applies new layout settings to an existing Guido graphic representation. Default settings are applied...
GuidoVersion::str
std::string str
String representation of guido version.
Definition: GUIDOEngineAdapter.h:47
string2AR
ARHandler string2AR(GuidoParser *parser, const std::string &gmnCode)
Parse a string and create the corresponding AR.
checkVersionNums
GuidoErrCode checkVersionNums(int major, int minor, int sub)
Checks a required library version number.
ar2gmn
GuidoErrCode ar2gmn(ARHandler ar, std::ostream &to)
Print a Guido abstract representation to a stream formatted as gmn code.
setDrawBoundingBoxes
void setDrawBoundingBoxes(int bbMap)
Control bounding boxes drawing.
GuidoErrCode
GuidoErrCode
The guido error codes list.
Definition: GUIDOEngine.h:211
setDefaultPageFormat
void setDefaultPageFormat(const GuidoPageFormat &format)
Sets the default score page format.
getErrorString
std::string getErrorString(GuidoErrCode errCode)
Gives a textual description of a Guido error code.
gr2SVG
std::string gr2SVG(const GRHandler handle, int page, std::ostream &out, int w, int h, bool embedFont=true)
Exports one page of score to SVG.
GuidoVersion::sub
int sub
sub sub number version
Definition: GUIDOEngineAdapter.h:45
GuidoDate
Representation of a date as a rational value.
Definition: GUIDOEngine.h:83
getStream
std::string getStream(const GuidoStream *gStream) const
returns the string of the stream
getPageCount
int getPageCount(CGRHandler inHandleGR)
Gives the number of score pages of the graphic representation.
ParserError::msg
std::string msg
msg a string that will contain the error message
Definition: GUIDOEngineAdapter.h:33
showElement
GuidoErrCode showElement(GRHandler gr, int elt, bool status)
getDefaultPageFormat
GuidoPageFormat getDefaultPageFormat()
Gives the default score page format.
getSystemCount
int getSystemCount(CGRHandler inHandleGR, int page)
Gives the number of systems on a given page.
getDefaultLayoutSettings
GuidoLayoutSettings getDefaultLayoutSettings()
Gives the default values of the layout settings.
GuidoLayoutSettings
Engine settings for the graphic score layout.
Definition: GUIDOEngine.h:255
GRHandler
struct NodeGR * GRHandler
Definition: GUIDOEngine.h:37
closeParser
GuidoErrCode closeParser(GuidoParser *p)
Close a guido parser and releases all the associated ressources.
ParserError::col
int col
col a reference that will contain a column number in case of syntax error
Definition: GUIDOEngineAdapter.h:31
getSymbolPath
std::vector< std::string > getSymbolPath(const ARHandler inHandleAR)
Returns the path corresponding to an AR.
gr2SVGColored
std::string gr2SVGColored(const GRHandler handle, int page, int r, int g, int b, bool embedfont=true)
Exports one page of score to SVG.
getPageFormat
GuidoPageFormat getPageFormat(CGRHandler inHandleGR, int pageNum)
Gives a score page format.
parserGetErrorCode
ParserError parserGetErrorCode(GuidoParser *p)
Get the error syntax line/column/message.
~GuidoEngineAdapter
virtual ~GuidoEngineAdapter()
~GuidoEngineAdapter
stream2AR
ARHandler stream2AR(GuidoParser *p, GuidoStream *stream)
Parse a stream and create the corresponding AR.
ParserError
A structure for parser error.
Definition: GUIDOEngineAdapter.h:27
GuidoVersion::major
int major
major major number version
Definition: GUIDOEngineAdapter.h:41
ARHandler
struct NodeAR * ARHandler
Definition: GUIDOEngine.h:36
class_export
#define class_export
Definition: GUIDOExport.h:38
freeAR
void freeAR(ARHandler ar)
Releases a Guido abstract representation. This method must be called after freeGR.
openParser
GuidoParser * openParser()
Creates a new parser.
GuidoVersion::minor
int minor
minor minor number version
Definition: GUIDOEngineAdapter.h:43
getDrawBoundingBoxes
int getDrawBoundingBoxes()
Gives bounding boxes drawing state.
ParserError::line
int line
line a reference that will contain a line number in case of syntax error
Definition: GUIDOEngineAdapter.h:29
resetStream
GuidoErrCode resetStream(GuidoStream *s)
Erase all stream content in order to reuse it.
inches2Unit
float inches2Unit(float val)
Converts inches into internal Guido units.
CARHandler
const struct NodeAR * CARHandler
Definition: GUIDOEngine.h:38
unit2CM
float unit2CM(float val)
Converts internal Guido units into centimeters.
findEventPage
int findEventPage(CGRHandler inHandleGR, const GuidoDate &date)
Finds the page which has an event (note or rest) at a given date.
findPageAt
int findPageAt(CGRHandler inHandleGR, const GuidoDate &date)
Finds the page which contain a given date.
GuidoVersion
A structure for guido version, composed of 3 digit.
Definition: GUIDOEngineAdapter.h:39

Guido Project Copyright © 2019 Grame-CNCM