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
TuningCurveGraph Class Reference

The QGraphicsView to display the tuning curve and the inharmonicity. More...

#include <tuningcurvegraph.h>

+ Inheritance diagram for TuningCurveGraph:
+ Collaboration diagram for TuningCurveGraph:

Public Member Functions

 TuningCurveGraph (QWidget *parent)
 Constructor, linking AutoScaledToKeyboardGraphicsView with the TuningCurveGraphDrawer. More...
 
virtual ~TuningCurveGraph ()
 Empty virtual destructor. More...
 
- Public Member Functions inherited from AutoScaledToKeyboardGraphicsView
 AutoScaledToKeyboardGraphicsView (QWidget *parent, DrawerBase *drawer)
 Constructor. More...
 
 ~AutoScaledToKeyboardGraphicsView ()
 Destructor. More...
 
void setKeyboard (KeyboardGraphicsView *keyboardgraphicsview)
 Setter function for the keyboard. More...
 
void highlightKey (int key)
 Function that will highlight the given key. More...
 
- Public Member Functions inherited from GraphicsViewAdapterForQt
 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...
 
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...
 
- Public Member Functions inherited from TuningCurveGraphDrawer
 TuningCurveGraphDrawer (GraphicsViewAdapter *graphics)
 Constructor, calls the DrawerBase constructor and resets variables. More...
 
 ~TuningCurveGraphDrawer ()
 Empty destructor. More...
 
void manuallyEditTuningCurveByClick (double relX, double relY)
 Manually edit tuning curve by mouse click. More...
 
OperationMode getOperationMode () const
 
- Public Member Functions inherited from DrawerBase
 DrawerBase (GraphicsViewAdapter *graphics, double intervall=1.0/24.0)
 Constructor of a drawer. More...
 
 ~DrawerBase ()
 
void redraw (bool force=false)
 Function to completely redraw the scene. More...
 
bool requestRedraw (bool force=false)
 Check whether the content has to be redrawn. More...
 
- Public Member Functions inherited from MessageListener
 MessageListener (bool defaultActivation=true)
 
virtual ~MessageListener ()
 
bool isMessageListenerActive () const
 
void activateMessageListener ()
 
void deactivateMessageListener ()
 

Protected Member Functions

virtual QSize sizeHint () const overridefinal
 
virtual QSize minimumSizeHint () const overridefinal
 
void mousePressEvent (QMouseEvent *event) override
 Function handling a mouse click. The mouse press event is used to manually edit the tuning curve. More...
 
void mouseMoveEvent (QMouseEvent *event) override
 Function for handling mouse moves. Moving the mouse will continuously change the tuning curve by dragging the green marker. More...
 
void mouseReleaseEvent (QMouseEvent *event) override
 Mouse release event to stop the change of the tuning curve. More...
 
void handleMouseInteraction (double relX, double relY)
 TuningCurveGraph::handleMouseInteraction. More...
 
- Protected Member Functions inherited from AutoScaledToKeyboardGraphicsView
void showEvent (QShowEvent *event) override
 Reimplemented to keep the visible view with the KeyboardGraphicsView. More...
 
void resizeEvent (QResizeEvent *event) override
 Reimplemented to keep the visible view with the KeyboardGraphicsView. More...
 
- Protected Member Functions inherited from GraphicsViewAdapterForQt
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...
 
virtual GraphicsItemdrawLine (double x1, double y1, double x2, double y2, PenType pen) override
 Abstract function: Draw a line. More...
 
virtual GraphicsItemdrawChart (const std::vector< Point > &points, PenType pen) override
 Abstract function: Draw a chart (polygon). More...
 
virtual GraphicsItemdrawFilledRect (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 Member Functions inherited from TuningCurveGraphDrawer
virtual void draw () final
 Main drawing function. More...
 
virtual void handleMessage (MessagePtr m) override
 Message listener and dispatcher. More...
 
double convertCentsToY (double cents)
 Convert cents to y-coordinate between 0 and 1. More...
 
double getMarkerPosition (int keyindex, RoleType role)
 Compute the position of a marker. More...
 
void drawMarkers (int8_t key)
 Draw the tuning markers in the tuning curve panel. More...
 
void drawGrid ()
 Draw the background grid in the tuning curve panel. More...
 
PenType getMarkerPenType (RoleType role)
 Get the pen type of a marker with a given role. More...
 
void updateMarkerPosition (int keyindex, RoleType role)
 
- Protected Member Functions inherited from DrawerBase
virtual void clear ()
 Clear the whole view. More...
 

Private Attributes

bool mPressed
 Is the mouse pressed? More...
 
float mPressedX
 The x coordinate where the mouse was pressed in first instance. More...
 

Additional Inherited Members

- Public Types inherited from AutoScaledToKeyboardGraphicsView
enum  ItemRoles { ROLE_HIGHLIGHT = 1024 }
 
- 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...
 
- Protected Attributes inherited from AutoScaledToKeyboardGraphicsView
KeyboardGraphicsViewmKeyboardGraphicsView
 Pointer to the KeyboardGraphicsView. More...
 
- Protected Attributes inherited from GraphicsViewAdapterForQt
DrawerBasemDrawer
 The drawer of this GraphicsViewAdapterForQt. More...
 
QGraphicsScene mScene
 The QGraphicsScene. More...
 
QRectF mSceneRect
 The scene rect. More...
 
- Protected Attributes inherited from TuningCurveGraphDrawer
const PianomPiano
 Pointer to the actual piano. More...
 
double mConcertPitch
 Chosen concert pitch in Hz. More...
 
int mKeyNumberOfA4
 Index of A4 (reference key) More...
 
int mNumberOfKeys
 Total number of keys (88) More...
 
OperationMode mOperationMode
 Current operation mode. More...
 
- Protected Attributes inherited from DrawerBase
GraphicsViewAdaptermGraphics
 Pointer to the graphics view adapter. More...
 
- Static Protected Attributes inherited from TuningCurveGraphDrawer
static const int rangeInCents = 60
 Constant, defining the visible range above and below the equal temperament level in cents. More...
 
static const PenType gridcolor = GraphicsViewAdapter::PEN_THIN_DARK_GRAY
 Pen type for background grid pentype. More...
 
static const PenType middleline = GraphicsViewAdapter::PEN_MEDIUM_DARK_GRAY
 Pen type for bold middle line of grid. More...
 
static const PenType centlines = GraphicsViewAdapter::PEN_THIN_VERY_LIGHT_GRAY
 Pen type for thin grid indicating cents. More...
 
static const PenType bmarkers = GraphicsViewAdapter::PEN_MEDIUM_LIGHT_GRAY
 Pen type for inharmonicity markers. More...
 
static const PenType frmarkers = GraphicsViewAdapter::PEN_THIN_BLUE
 Pen type for recorded frequency markers. More...
 
static const PenType fgmarkers = GraphicsViewAdapter::PEN_THIN_LIGHT_GRAY
 Pen type for recorded frequency in background. More...
 
static const PenType fcmarkers = GraphicsViewAdapter::PEN_MEDIUM_DARK_GREEN
 Pen type for computed frequency markers. More...
 
static const PenType ftmarkers = GraphicsViewAdapter::PEN_MEDIUM_RED
 Pen type for tuned frequency markers. More...
 
static const PenType opmarkers = GraphicsViewAdapter::PEN_MEDIUM_MAGENTA
 Pen type for tuned frequency markers. More...
 
static const FillType allowdAreaFill = GraphicsViewAdapter::FILL_LIGHT_GREEN
 Filling for the allowed tuning area. More...
 

Detailed Description

The QGraphicsView to display the tuning curve and the inharmonicity.

This is the Qt implementation of the TuningCurveGraphDrawer. It forwards the drawings of TuningCurveGraphDrawer to a AutoScaledToKeyboardGraphicsView.

The user can change the computed tuning curve with a mouse click on the bars. This class is basically managing these mouse clicks. A click selects the corresponding key on the keyboard by sending a MSG_KEY_SELECTION_CHANGED message.

See also
AutoScaledToKeyboardGraphicsView
TuningCurveGraphDrawer

Definition at line 48 of file tuningcurvegraph.h.

Constructor & Destructor Documentation

TuningCurveGraph::TuningCurveGraph ( QWidget *  parent)
explicit

Constructor, linking AutoScaledToKeyboardGraphicsView with the TuningCurveGraphDrawer.

Parameters
parent: The parent widget.

Definition at line 44 of file tuningcurvegraph.cpp.

virtual TuningCurveGraph::~TuningCurveGraph ( )
inlinevirtual

Empty virtual destructor.

Definition at line 53 of file tuningcurvegraph.h.

Member Function Documentation

void TuningCurveGraph::handleMouseInteraction ( double  relX,
double  relY 
)
protected

TuningCurveGraph::handleMouseInteraction.

If the mouse is within the valid range the function computes the corresponding key index. In the calculation mode the coordinates are used to manually edit the tuning curve while in all other modes a message is sent to select the corresponding key.

Parameters
relX: Relative x coordinate of the mouse pointer.
relY: Relative y coordinate of the mouse pointer.

Definition at line 142 of file tuningcurvegraph.cpp.

+ Here is the call graph for this function:

virtual QSize TuningCurveGraph::minimumSizeHint ( ) const
inlinefinaloverrideprotectedvirtual

Definition at line 57 of file tuningcurvegraph.h.

void TuningCurveGraph::mouseMoveEvent ( QMouseEvent *  event)
overrideprotected

Function for handling mouse moves. Moving the mouse will continuously change the tuning curve by dragging the green marker.

The function is only active if mPressed is true. It will use mPressedX as x value and the actual QMouseEvent's y coordinate. These coordinates are passed to the function handleMouseInteraction.

See also
handleMouseInteraction
Parameters
event: The QMouseEvent

Definition at line 92 of file tuningcurvegraph.cpp.

+ Here is the call graph for this function:

void TuningCurveGraph::mousePressEvent ( QMouseEvent *  event)
overrideprotected

Function handling a mouse click. The mouse press event is used to manually edit the tuning curve.

If the a mouse button is pressed this function sets mPressed to true and stores the mouse x position in the member variable mPressedX. It also passes the actual coordinates to the function handleMouseInteraction.

See also
handleMouseInteraction
Parameters
event: The QMouseEvent

Definition at line 68 of file tuningcurvegraph.cpp.

+ Here is the call graph for this function:

void TuningCurveGraph::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

Mouse release event to stop the change of the tuning curve.

A mouse release event will set mPressed to false. The final coordinates are passed to the function handleMouseInteraction.

See also
handleMouseInteraction
Parameters
event: The QMouseEvent

Definition at line 115 of file tuningcurvegraph.cpp.

+ Here is the call graph for this function:

virtual QSize TuningCurveGraph::sizeHint ( ) const
inlinefinaloverrideprotectedvirtual

Definition at line 56 of file tuningcurvegraph.h.

Member Data Documentation

bool TuningCurveGraph::mPressed
private

Is the mouse pressed?

Definition at line 69 of file tuningcurvegraph.h.

float TuningCurveGraph::mPressedX
private

The x coordinate where the mouse was pressed in first instance.

Definition at line 72 of file tuningcurvegraph.h.


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