Entropy Piano Tuner
1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
|
Abstract base class for implementations rendering graphics. More...
#include <graphicsviewadapter.h>
Classes | |
struct | Point |
Structure holding the coordinates of a single point. More... | |
Public Types | |
enum | PenType { PEN_THIN_BLACK, PEN_MEDIUM_BLACK, PEN_THIN_VERY_LIGHT_GRAY, PEN_THIN_LIGHT_GRAY, PEN_THIN_DARK_GRAY, PEN_MEDIUM_LIGHT_GRAY, PEN_MEDIUM_DARK_GRAY, PEN_MEDIUM_GRAY, PEN_THIN_CYAN, PEN_MEDIUM_CYAN, PEN_MEDIUM_ORANGE, PEN_MEDIUM_MAGENTA, PEN_THIN_MAGENTA, PEN_THIN_RED, PEN_MEDIUM_RED, PEN_THIN_BLUE, PEN_THIN_TRANSPARENT, PEN_MEDIUM_DARK_GREEN } |
Available pen types for drawing. More... | |
enum | FillTypes { FILL_TRANSPARENT, FILL_LIGHT_GRAY, FILL_RED, FILL_ORANGE, FILL_GREEN, FILL_LIGHT_GREEN, FILL_BLUE } |
Available filling colors (e.g. to fill rectangles) More... | |
using | RoleType = GraphicsItem::RoleType |
Public Member Functions | |
GraphicsViewAdapter () | |
Empty constructor. More... | |
~GraphicsViewAdapter () | |
Destructor clearing the view. More... | |
virtual void | clear () |
Clear the graphics panel. More... | |
Functions for handling graphics items: | |
GraphicItemsList & | getGraphicItems () |
Get the list of the graphic items. More... | |
const GraphicItemsList & | getGraphicItems () const |
Get a constant list of the graphic items. More... | |
GraphicsItem * | getGraphicItem (int keyIndex, RoleType role) |
Get a single graphics element specified by its index and its role. More... | |
GraphicsItem * | getGraphicItemByRole (RoleType role) |
Get the first of all graphics elements with a given role. More... | |
GraphicItemsList | getGraphicItems (int keyIndex) |
Get a list of graphic items that match with the keyIndex. More... | |
GraphicItemsList | getGraphicItemsByRole (RoleType role) |
Get a list of graphic items that match with the given role. More... | |
GraphicItemsList | getGraphicItems (int keyIndex, RoleType role) |
Get the list of all graphics elements of a given key and role. More... | |
Private Attributes | |
GraphicItemsList | mGraphicItems |
List of all graphic items in the view. More... | |
Functions for drawing: | |
using | ComplexVector = std::vector< std::complex< double >> |
Abstract function: Draw stroboscope. More... | |
virtual GraphicsItem * | drawLine (double x1, double y1, double x2, double y2, PenType pen=PEN_THIN_BLACK)=0 |
Abstract function: Draw a line. More... | |
virtual GraphicsItem * | drawChart (const std::vector< Point > &points, PenType pen=PEN_THIN_BLACK)=0 |
Abstract function: Draw a chart (polygon). More... | |
virtual GraphicsItem * | drawFilledRect (double x, double y, double w, double h, PenType pen=PEN_THIN_BLACK, FillTypes fill=FILL_RED)=0 |
Abstract function: Draw a filled rectangle. More... | |
virtual void | drawStroboscope (const ComplexVector &data)=0 |
Abstract base class for implementations rendering graphics.
The GraphicsViewAdapter provides pure virtual functions to be implemented in the actual GUI. Drawers derived from DrawerBase will use these methods to draw.
At the core level, all coordinates are relative, that is, they vary between 0 and 1 and refer to the respective panel in which the object is drawn.
The GraphicsViewAdapter holds a list of GraphicsItem, which allows individual elements of the panel to be redrawn separately. Moreover, it provides a system of flags to mark certain classes of items such as lines, tuning markers etc., and to access them selectively.
Definition at line 49 of file graphicsviewadapter.h.
using GraphicsViewAdapter::ComplexVector = std::vector<std::complex<double>> |
Abstract function: Draw stroboscope.
A stroboscope is a tuning indicator which displays interference patterns of the incoming PCM data with respect to the target frequency. In the EPT the stroboscopic display is simplified in that it only gets the amplitudes and complex phases of the first few partials. Nevertheless the data should be displayed immediately. Therefore, the whole drawing is done in the implementation of this adapter.
data | : Vector of complex numbers, encoding the amplitudes and the phase shifts of the partials. |
Definition at line 196 of file graphicsviewadapter.h.
Definition at line 52 of file graphicsviewadapter.h.
Available filling colors (e.g. to fill rectangles)
Enumerator | |
---|---|
FILL_TRANSPARENT | |
FILL_LIGHT_GRAY | |
FILL_RED | |
FILL_ORANGE | |
FILL_GREEN | |
FILL_LIGHT_GREEN | |
FILL_BLUE |
Definition at line 99 of file graphicsviewadapter.h.
Available pen types for drawing.
Definition at line 73 of file graphicsviewadapter.h.
|
inline |
Empty constructor.
Definition at line 112 of file graphicsviewadapter.h.
|
inline |
Destructor clearing the view.
Definition at line 113 of file graphicsviewadapter.h.
|
virtual |
Clear the graphics panel.
This function deletes all graphics items helt in the private list.
Reimplemented in StroboscopicViewAdapterForQt, and GraphicsViewAdapterForQt.
Definition at line 37 of file graphicsviewadapter.cpp.
|
pure virtual |
Abstract function: Draw a chart (polygon).
This function draws a chart (polygon) of points connected by straight lines. The points are passed to the function as a vector. The function is abstract and has to be overridden in the implementation.
points | : Vector of points. |
pen | : The pen used to draw the polygon. |
Implemented in GraphicsViewAdapterForQt.
|
pure virtual |
Abstract function: Draw a filled rectangle.
This function draws a filled rectangle. It is a pure virtual function which has to be overridden in the respective implementation.
x | : Left x coordinate |
y | : Upper y coordinate |
w | : Width of the rectangle |
h | : Height of the rectangle |
pen | : The pen used to draw the border |
fill | : The filling color used to fill the rectangle. |
Implemented in GraphicsViewAdapterForQt.
|
pure virtual |
Abstract function: Draw a line.
x1 | : Starting point x coordinate between 0 and 1 |
y1 | : Starting point y coordinate between 0 and 1 |
x2 | : Ending point x coordinate between 0 and 1 |
y2 | : Ending point y coordinate between 0 and 1 |
pen | : The pen to be used |
Implemented in GraphicsViewAdapterForQt.
|
pure virtual |
Implemented in GraphicsViewAdapterForQt, and StroboscopicViewAdapterForQt.
GraphicsItem * GraphicsViewAdapter::getGraphicItem | ( | int | keyIndex, |
RoleType | role | ||
) |
Get a single graphics element specified by its index and its role.
This function returns the pointer to a single graphics element which is specified by its index and its role. Note that the function will return nullptr if no item in the list matches with the request. The function will fail if more than one item matches.
keyIndex | : Index of the graphics element |
role | : User-defined role of the graphics element |
Definition at line 92 of file graphicsviewadapter.cpp.
GraphicsItem * GraphicsViewAdapter::getGraphicItemByRole | ( | RoleType | role | ) |
Get the first of all graphics elements with a given role.
Note that the function will return nullptr if no item matches with the requested role. The function will fail if more than one item matches.
role | : The role of the searched graphics element |
Definition at line 115 of file graphicsviewadapter.cpp.
GraphicItemsList & GraphicsViewAdapter::getGraphicItems | ( | ) |
Get the list of the graphic items.
Getter function retrieving the complete list of the drawn graphic items.
Definition at line 56 of file graphicsviewadapter.cpp.
const GraphicItemsList & GraphicsViewAdapter::getGraphicItems | ( | ) | const |
Get a constant list of the graphic items.
Getter function retreiving the complete list of the drawn graphic items.
Definition at line 71 of file graphicsviewadapter.cpp.
GraphicItemsList GraphicsViewAdapter::getGraphicItems | ( | int | keyIndex | ) |
Get a list of graphic items that match with the keyIndex.
keyIndex | : Index of the key used as a filter |
Definition at line 134 of file graphicsviewadapter.cpp.
GraphicItemsList GraphicsViewAdapter::getGraphicItems | ( | int | keyIndex, |
RoleType | role | ||
) |
Get the list of all graphics elements of a given key and role.
keyIndex | : Index of the key used as a filter |
role | : Role of the graphics item used as a filter |
Definition at line 173 of file graphicsviewadapter.cpp.
GraphicItemsList GraphicsViewAdapter::getGraphicItemsByRole | ( | RoleType | role | ) |
Get a list of graphic items that match with the given role.
role | : Role of the graphics item used as a filter |
Definition at line 153 of file graphicsviewadapter.cpp.
|
private |
List of all graphic items in the view.
Definition at line 202 of file graphicsviewadapter.h.