Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GraphicsViewAdapter Class Referenceabstract

Abstract base class for implementations rendering graphics. More...

#include <graphicsviewadapter.h>

+ Inheritance diagram for GraphicsViewAdapter:

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:
GraphicItemsListgetGraphicItems ()
 Get the list of the graphic items. More...
 
const GraphicItemsListgetGraphicItems () const
 Get a constant list of the graphic items. More...
 
GraphicsItemgetGraphicItem (int keyIndex, RoleType role)
 Get a single graphics element specified by its index and its role. More...
 
GraphicsItemgetGraphicItemByRole (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 GraphicsItemdrawLine (double x1, double y1, double x2, double y2, PenType pen=PEN_THIN_BLACK)=0
 Abstract function: Draw a line. More...
 
virtual GraphicsItemdrawChart (const std::vector< Point > &points, PenType pen=PEN_THIN_BLACK)=0
 Abstract function: Draw a chart (polygon). More...
 
virtual GraphicsItemdrawFilledRect (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
 

Detailed Description

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.

Member Typedef Documentation

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.

See also
StroboscopicViewAdapterForQt
GraphicsItem
Parameters
data: Vector of complex numbers, encoding the amplitudes and the phase shifts of the partials.
Returns
Pointer to the created GraphicsItem.

Definition at line 196 of file graphicsviewadapter.h.

Member Enumeration Documentation

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.

Enumerator
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 

Definition at line 73 of file graphicsviewadapter.h.

Constructor & Destructor Documentation

GraphicsViewAdapter::GraphicsViewAdapter ( )
inline

Empty constructor.

Definition at line 112 of file graphicsviewadapter.h.

GraphicsViewAdapter::~GraphicsViewAdapter ( )
inline

Destructor clearing the view.

Definition at line 113 of file graphicsviewadapter.h.

+ Here is the call graph for this function:

Member Function Documentation

void GraphicsViewAdapter::clear ( )
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.

virtual GraphicsItem* GraphicsViewAdapter::drawChart ( const std::vector< Point > &  points,
PenType  pen = PEN_THIN_BLACK 
)
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.

Parameters
points: Vector of points.
pen: The pen used to draw the polygon.
Returns
The newly created graphics item or nullptr if out of range.

Implemented in GraphicsViewAdapterForQt.

virtual GraphicsItem* GraphicsViewAdapter::drawFilledRect ( double  x,
double  y,
double  w,
double  h,
PenType  pen = PEN_THIN_BLACK,
FillTypes  fill = FILL_RED 
)
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.

Parameters
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.
Returns
The newly created graphics item or nullptr if out of range.

Implemented in GraphicsViewAdapterForQt.

virtual GraphicsItem* GraphicsViewAdapter::drawLine ( double  x1,
double  y1,
double  x2,
double  y2,
PenType  pen = PEN_THIN_BLACK 
)
pure virtual

Abstract function: Draw a line.

Parameters
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
Returns
The newly created graphics item or nullptr if out of range.

Implemented in GraphicsViewAdapterForQt.

virtual void GraphicsViewAdapter::drawStroboscope ( const ComplexVector data)
pure virtual
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.

See also
getGraphicItems(RoleType)
Parameters
keyIndex: Index of the graphics element
role: User-defined role of the graphics element
Returns
Pointer to the graphics item or nullptr

Definition at line 92 of file graphicsviewadapter.cpp.

+ Here is the call graph for this function:

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.

See also
getGraphicItems(int, RoleType)
Parameters
role: The role of the searched graphics element
Returns
Pointer to the first graphics element in the list or nullptr

Definition at line 115 of file graphicsviewadapter.cpp.

+ Here is the call graph for this function:

GraphicItemsList & GraphicsViewAdapter::getGraphicItems ( )

Get the list of the graphic items.

Getter function retrieving the complete list of the drawn graphic items.

Returns
mGraphicItems : List of graphics item.

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.

Returns
mGraphicItems : Constant list of graphics item.

Definition at line 71 of file graphicsviewadapter.cpp.

GraphicItemsList GraphicsViewAdapter::getGraphicItems ( int  keyIndex)

Get a list of graphic items that match with the keyIndex.

Parameters
keyIndex: Index of the key used as a filter
Returns
List of graphics items that may be empty

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.

Parameters
keyIndex: Index of the key used as a filter
role: Role of the graphics item used as a filter
Returns
List of graphics items

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.

Parameters
role: Role of the graphics item used as a filter
Returns
List of graphics items that may be empty

Definition at line 153 of file graphicsviewadapter.cpp.

Member Data Documentation

GraphicItemsList GraphicsViewAdapter::mGraphicItems
private

List of all graphic items in the view.

Definition at line 202 of file graphicsviewadapter.h.


The documentation for this class was generated from the following files: