Lomse library. API documentation
0.30.0
|
#include <lomse_graphical_model.h>
The GraphicModel represents the visual representation of the document. It is a tree of objects representing the graphical elements (lines, arcs, shapes, etc.) that describe the final appearance of the document from a purely geometric point of view. The graphical model objects (GmoShape and GmoBox derived objects) behave as vertex sources, providing the coordinates for the polygons that define the visual representation of the document.
The GraphicModel is a representation of what in computer graphics theory is named the real world, a virtual rendition of the full document at real size (e.g. millimeters). It is a virtual image of the full document organized as expected by the chosen View type.
The Graphic Model subdivides the document layout in regions or boxes, represented by objects derived from GmoBox. The boxes are organized in a tree so that each box is also a container for other boxes. For instance, the main boxes for an score are depicted in following picture:
The GraphicModel is built from the Internal Model by the layout process. Once it is built, it will be re-built only if the document or the View type change. Other changes, such as resolution, window size, allocation of a new rendering bitmap, do not affect the Graphic Model.
Rendering the document is done using the Graphic Model. At high level, rendering is a simple operation. It is just traversing the graphical model tree and invoking the GmoObj::on_draw() method on each object. The on_draw()
method will issue drawing commands that will be processed by a Drawer object for generating the rendition.
The GraphicModel also provides access to global information (e.g. number of pages) as well as to the most relevant objects.
The Graphic Model can be accessed by invoking method Interactor::get_graphic_model().
Public Member Functions | |
Access to some information | |
int | get_num_pages () |
int | get_num_systems (ImoId scoreId) |
int | get_page_number_containing (GmoObj *pGmo) |
GmMeasuresTable * | get_measures_table (ImoId scoreId) |
Access to main boxes | |
GmoBoxDocument * | get_root () |
GmoBoxDocPage * | get_page (int i) |
GmoBoxSystem * | get_system_for (ImoId scoreId, TimeUnits timepos) |
GmoBoxSystem * | get_system_box (int iSystem, ImoId scoreId) |
GmoBoxSystem * | get_system_for (ImoScore *pScore, const MeasureLocator &ml) |
GmoBoxSystem * | get_system_for_staffobj (ImoId id) |
GmoShapeStaff * | get_shape_for_first_staff_in_first_system (ImoId scoreId) |
Access to shapes and boxes related to an ImoObj | |
GmoShape * | get_shape_for_imo (ImoId imoId, ShapeId shapeId) |
GmoShape * | get_main_shape_for_imo (ImoId id) |
GmoShape * | find_shape_for_object (ImoStaffObj *pSO) |
GmoShape * | get_shape_for_noterest (ImoNoteRest *pNR) |
GmoBox * | get_box_for_imo (ImoId id) |
Information for clicked point | |
GmoShape * | find_shape_at (int iPage, LUnits x, LUnits y) |
GmoBox * | find_inner_box_at (int iPage, LUnits x, LUnits y) |
AreaInfo * | get_info_for_point (int iPage, LUnits x, LUnits y) |
GmoBox* GraphicModel::find_inner_box_at | ( | int | iPage, |
LUnits | x, | ||
LUnits | y | ||
) |
Returns pointer to the innermost GmoBox located in the given cordinates of a document page.
iPage | The number of the page (0..n-1). |
x,y | The relative coordinates for the point (logical units referred to the top-left corner of the page). |
GmoShape* GraphicModel::find_shape_at | ( | int | iPage, |
LUnits | x, | ||
LUnits | y | ||
) |
Returns pointer to the shape (if any) located in the given cordinates of a document page. If no shape there, returns nullptr.
iPage | The number of the page (0..n-1). |
x,y | The relative coordinates for the point (logical units referred to the top-left corner of the page). |
GmoShape* GraphicModel::find_shape_for_object | ( | ImoStaffObj * | pSO | ) |
Returns pointer to the main GmoShape generated by an ImoStaffObj.
pSO | Pointer to the ImoStaffObj to which the request is referring. |
GmoBox* GraphicModel::get_box_for_imo | ( | ImoId | id | ) |
Returns pointer to the innermost GmoBox in which the shape for an ImoObj is contained.
id | The Id of the ImoObj to which the request is referring. |
AreaInfo* GraphicModel::get_info_for_point | ( | int | iPage, |
LUnits | x, | ||
LUnits | y | ||
) |
Returns pointer to an AreaInfo object containing the classification information and pointers to shape and boxes related to the given cordinates of a document page.
iPage | The number of the page (0..n-1). |
x,y | The relative coordinates for the point (logical units referred to the top-left corner of the page). |
GmoShape* GraphicModel::get_main_shape_for_imo | ( | ImoId | id | ) |
Returns pointer to the main GmoShape generated by an ImoObj. It is equivalent to get_shape_for_imo(imoId, 0).
id | The Id of the ImoObj to which the request is referring. |
GmMeasuresTable* GraphicModel::get_measures_table | ( | ImoId | scoreId | ) |
Returns the GmMeasuresTable for the given score. The GmMeasuresTable object manages the table with the graphical information about the measures in the score and provides information such as the number of measures in the score, or their coordinates.
scoreId | The Id of the score to which the request is referring. |
int GraphicModel::get_num_pages | ( | ) |
Returns the number of pages of the rendered document. This value can also be obtained by invoking Interactor::get_num_pages().
int GraphicModel::get_num_systems | ( | ImoId | scoreId | ) |
Returns the number of systems in the rendered score.
scoreId | The Id of the score to which the request is referring. |
GmoBoxDocPage* GraphicModel::get_page | ( | int | i | ) |
Returns the GmoBoxDocPage for the given page number.
i | The number of the page (0..n-1) for which the GmoBoxDocPage is requested. |
int GraphicModel::get_page_number_containing | ( | GmoObj * | pGmo | ) |
|
inline |
Returns the root object of the Graphical Model. It is always a GmoBoxDocument object.
GmoShapeStaff* GraphicModel::get_shape_for_first_staff_in_first_system | ( | ImoId | scoreId | ) |
Returns pointer to the GmoShapeStaff for the first staff in first system.
scoreId | The Id of the score to which the request is referring. |
GmoShape* GraphicModel::get_shape_for_imo | ( | ImoId | imoId, |
ShapeId | shapeId | ||
) |
Returns pointer to the GmoShape generated by an ImoObj.
imoId | The Id of the ImoObj to which the request is referring. |
shapeId | As any ImoObj can generate several shapes it is necessary to provide the shape index. The first generated shape has index 0, the next one index 1, and so on. |
GmoShape* GraphicModel::get_shape_for_noterest | ( | ImoNoteRest * | pNR | ) |
Returns pointer to the main GmoShape generated by an ImoNoteRest.
pNR | Pointer to the ImoNoteRest to which the request is referring. |
GmoBoxSystem* GraphicModel::get_system_box | ( | int | iSystem, |
ImoId | scoreId | ||
) |
Returns pointer to the GmoBoxSystem for the given system number.
iSystem | The number of the system (0..n-1) for which the GmoBoxSystem is requested. |
scoreId | The Id of the score to which the request is referring. |
GmoBoxSystem* GraphicModel::get_system_for | ( | ImoId | scoreId, |
TimeUnits | timepos | ||
) |
Returns pointer to the GmoBoxSystem that contains the specified timepos. If there is no system for the given timepos, returns nullptr.
This method gives preference to finding a system containing a note/rest at the given tiempos
instead of non-timed staff objects. For example, the last barline in one system has the same timepos
than the first note/rest in next system. Therefore, this method will return the second system not the one containing the barline.
scoreId | The Id of the score to which the request is referring. |
timepos | The time position (absolute time units) for the requested system. |
GmoBoxSystem* GraphicModel::get_system_for | ( | ImoScore * | pScore, |
const MeasureLocator & | ml | ||
) |
Returns pointer to the GmoBoxSystem that contains the specified MeasureLocator. If there is no system for the given location, returns nullptr.
pScore | The score to which the request is referring. |
ml | The MeasureLocator for which the GmoBoxSystem is requested. |
GmoBoxSystem* GraphicModel::get_system_for_staffobj | ( | ImoId | id | ) |
Returns pointer to the GmoBoxSystem that contains the specified ImoStaffObj.
id | The Id of the ImoStaffObj to which the request is referring. |