Entropy Piano Tuner
1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
|
Implementation of the GraphicsViewAdapter in Qt using QGraphicsView. More...
#include <graphicsviewadapterforqt.h>
Public Member Functions | |
GraphicsViewAdapterForQt (QWidget *parent, DrawerBase *drawer, QRectF sceneRect) | |
Constructor. More... | |
~GraphicsViewAdapterForQt () | |
Destructor, removing all graphics items from the list. More... | |
void | setSceneRect (const QRectF &rect) |
Setter function for the scene rectangle. More... | |
QPointF | convertRelToAbs (const QPointF &p) const |
Converting from relative to absolute coordinates. More... | |
QSizeF | convertRelToAbs (const QSizeF &s) const |
Converting from relative to absolute coordinates. More... | |
QLineF | convertRelToAbsLine (qreal x1, qreal y1, qreal x2, qreal y2) const |
Converting of a line from relative to absolute coordinates. More... | |
QPointF | convertAbsToRel (const QPointF &p) const |
Converting from absolute to relative coordinates. More... | |
Public Member Functions inherited from GraphicsViewAdapter | |
GraphicsViewAdapter () | |
Empty constructor. More... | |
~GraphicsViewAdapter () | |
Destructor clearing the view. More... | |
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... | |
Protected Member Functions | |
Reimplemented functions for managing the scene (panel): | |
void | showEvent (QShowEvent *event) override |
Show the scene (reimplemented show event). More... | |
void | resizeEvent (QResizeEvent *event) override |
Resize the scene (reimplemented resize event). More... | |
virtual void | clear () override |
Clear the scene. More... | |
Reimplemented functions for drawing: | |
virtual GraphicsItem * | drawLine (double x1, double y1, double x2, double y2, PenType pen) override |
Abstract function: Draw a line. More... | |
virtual GraphicsItem * | drawChart (const std::vector< Point > &points, PenType pen) override |
Abstract function: Draw a chart (polygon). More... | |
virtual GraphicsItem * | drawFilledRect (double x, double y, double w, double h, PenType pen, FillTypes fill) override |
Abstract function: Draw a filled rectangle. More... | |
virtual void | drawStroboscope (const ComplexVector &data) override |
Protected Attributes | |
DrawerBase * | mDrawer |
The drawer of this GraphicsViewAdapterForQt. More... | |
QGraphicsScene | mScene |
The QGraphicsScene. More... | |
QRectF | mSceneRect |
The scene rect. More... | |
Private Member Functions | |
QPen | getPen (PenType penType, bool cosmetic=true) const |
Get a QPen for the given value of PenTypes. More... | |
QBrush | getFill (FillTypes fill) const |
Create a QBrush for the given value of FillTypes. More... | |
Additional Inherited Members | |
Public Types inherited from GraphicsViewAdapter | |
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 |
using | ComplexVector = std::vector< std::complex< double >> |
Abstract function: Draw stroboscope. More... | |
Implementation of the GraphicsViewAdapter in Qt using QGraphicsView.
This class handles the drawing of lines, charts and filled rectangles and will create GraphicsItemForQt as GraphicsItem. It also handles the conversion from relative to absolute coordinates.
The mSceneRect is used for converting relative to absolute coordinates. It will always be fully displayed in the QGraphicsView.
Definition at line 40 of file graphicsviewadapterforqt.h.
GraphicsViewAdapterForQt::GraphicsViewAdapterForQt | ( | QWidget * | parent, |
DrawerBase * | drawer, | ||
QRectF | sceneRect | ||
) |
Constructor.
parent | : The parent widget |
drawer | : The drawer that draws into this graphics view |
sceneRect | : The scene rectange for QGraphicsView |
Definition at line 39 of file graphicsviewadapterforqt.cpp.
GraphicsViewAdapterForQt::~GraphicsViewAdapterForQt | ( | ) |
Destructor, removing all graphics items from the list.
Definition at line 65 of file graphicsviewadapterforqt.cpp.
|
overrideprotectedvirtual |
Clear the scene.
This function clears the QGraphicsScene and calls GraphicsViewAdapter::clear()
Reimplemented from GraphicsViewAdapter.
Reimplemented in StroboscopicViewAdapterForQt.
Definition at line 142 of file graphicsviewadapterforqt.cpp.
QPointF GraphicsViewAdapterForQt::convertAbsToRel | ( | const QPointF & | p | ) | const |
Converting from absolute to relative coordinates.
p | : A QPointF in absolute coordinates |
Definition at line 332 of file graphicsviewadapterforqt.cpp.
QPointF GraphicsViewAdapterForQt::convertRelToAbs | ( | const QPointF & | p | ) | const |
Converting from relative to absolute coordinates.
p | : A QPointF in relative coordinates |
Definition at line 305 of file graphicsviewadapterforqt.cpp.
QSizeF GraphicsViewAdapterForQt::convertRelToAbs | ( | const QSizeF & | s | ) | const |
Converting from relative to absolute coordinates.
s | : A QSizeF in relative coordinates |
Definition at line 313 of file graphicsviewadapterforqt.cpp.
QLineF GraphicsViewAdapterForQt::convertRelToAbsLine | ( | qreal | x1, |
qreal | y1, | ||
qreal | x2, | ||
qreal | y2 | ||
) | const |
Converting of a line from relative to absolute coordinates.
x1 | : The starting point x-coord of the line |
y1 | : The starting point y-coord of the line |
x2 | : The ending point x-coord of the line |
y2 | : The ending point y-coord of the line |
Definition at line 321 of file graphicsviewadapterforqt.cpp.
|
overrideprotectedvirtual |
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. |
Implements GraphicsViewAdapter.
Definition at line 167 of file graphicsviewadapterforqt.cpp.
|
overrideprotectedvirtual |
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. |
Implements GraphicsViewAdapter.
Definition at line 193 of file graphicsviewadapterforqt.cpp.
|
overrideprotectedvirtual |
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 |
Implements GraphicsViewAdapter.
Definition at line 153 of file graphicsviewadapterforqt.cpp.
|
inlineoverrideprotectedvirtual |
Implements GraphicsViewAdapter.
Reimplemented in StroboscopicViewAdapterForQt.
Definition at line 60 of file graphicsviewadapterforqt.h.
|
private |
Create a QBrush for the given value of FillTypes.
fill | : The fill type |
Definition at line 280 of file graphicsviewadapterforqt.cpp.
|
private |
Get a QPen for the given value of PenTypes.
penType | : The pen type |
cosmetic | : A cosmetic pen does not scale with the QGraphicsView |
Definition at line 211 of file graphicsviewadapterforqt.cpp.
|
overrideprotected |
Resize the scene (reimplemented resize event).
event | : The QResizeEvent event |
This function resizes the existing mSceneRect in the QGraphicsViewer.
Definition at line 124 of file graphicsviewadapterforqt.cpp.
void GraphicsViewAdapterForQt::setSceneRect | ( | const QRectF & | rect | ) |
Setter function for the scene rectangle.
rect | : The new scene rect of QGraphicsView |
Changing the scene rect will also force the drawer to redraw.
Definition at line 88 of file graphicsviewadapterforqt.cpp.
|
overrideprotected |
Show the scene (reimplemented show event).
event | : The QShowEvent event |
This function fits the mSceneRect into the view of the QGraphicsViewer.
Definition at line 106 of file graphicsviewadapterforqt.cpp.
|
protected |
The drawer of this GraphicsViewAdapterForQt.
Definition at line 119 of file graphicsviewadapterforqt.h.
|
protected |
The QGraphicsScene.
Definition at line 120 of file graphicsviewadapterforqt.h.
|
protected |
The scene rect.
Definition at line 121 of file graphicsviewadapterforqt.h.