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.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //============================================================================
21 // Adapter for viewing graphical elements
22 //============================================================================
23 
24 #ifndef GRAPHICSVIEWADAPTER_H
25 #define GRAPHICSVIEWADAPTER_H
26 
27 #include <vector>
28 #include <complex>
29 
30 #include "../drawers/graphicsitem.h"
31 
48 
50 {
51 public:
53 
62 
63  struct Point
64  {
65  double x;
66  double y;
67  };
68 
72 
73  enum PenType
74  {
93  };
94 
98 
99  enum FillTypes
100  {
108  };
109 
110 public:
111 
114 
115  virtual void clear(); // Clear graphics panel
116 
118 
120  const GraphicItemsList &getGraphicItems() const;
121  GraphicsItem *getGraphicItem (int keyIndex, RoleType role);
123  GraphicItemsList getGraphicItems (int keyIndex);
125  GraphicItemsList getGraphicItems (int keyIndex, RoleType role);
127 
129 
139 
140  virtual GraphicsItem* drawLine(double x1, double y1,
141  double x2, double y2,
142  PenType pen = PEN_THIN_BLACK) = 0;
143 
154 
155  virtual GraphicsItem* drawChart(const std::vector<Point> &points,
156  PenType pen = PEN_THIN_BLACK) = 0;
157 
158 
172 
173  virtual GraphicsItem* drawFilledRect(double x, double y,
174  double w, double h,
175  PenType pen = PEN_THIN_BLACK,
176  FillTypes fill = FILL_RED) = 0;
177 
178 
195 
196  using ComplexVector = std::vector<std::complex<double>>;
197  virtual void drawStroboscope (const ComplexVector &data) = 0;
198 
200 
201 private:
203 };
204 
205 #endif // GRAPHICSVIEWADAPTER_H
GraphicsItem * getGraphicItem(int keyIndex, RoleType role)
Get a single graphics element specified by its index and its role.
virtual GraphicsItem * drawChart(const std::vector< Point > &points, PenType pen=PEN_THIN_BLACK)=0
Abstract function: Draw a chart (polygon).
std::uint32_t RoleType
Type of a user role that can be set in a GraphicsItem (bitwise flag).
Definition: graphicsitem.h:62
GraphicsItem::RoleType RoleType
Structure holding the coordinates of a single point.
virtual void drawStroboscope(const ComplexVector &data)=0
std::list< GraphicsItem * > GraphicItemsList
A list of GraphicItem (global)
Definition: graphicsitem.h:148
FillTypes
Available filling colors (e.g. to fill rectangles)
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.
GraphicItemsList mGraphicItems
List of all graphic items in the view.
double x
Real-valued x coordinate between 0 and 1.
GraphicItemsList getGraphicItemsByRole(RoleType role)
Get a list of graphic items that match with the given role.
GraphicItemsList & getGraphicItems()
Get the list of the graphic items.
std::vector< std::complex< double >> ComplexVector
Abstract function: Draw stroboscope.
~GraphicsViewAdapter()
Destructor clearing the view.
PenType
Available pen types for drawing.
Abstract base class for implementations rendering graphics.
Class for a single item in a graphics view.
Definition: graphicsitem.h:55
double y
Real-valued y coordinate between 0 and 1.
virtual GraphicsItem * drawLine(double x1, double y1, double x2, double y2, PenType pen=PEN_THIN_BLACK)=0
Abstract function: Draw a line.
GraphicsItem * getGraphicItemByRole(RoleType role)
Get the first of all graphics elements with a given role.
GraphicsViewAdapter()
Empty constructor.
GraphicsItem::RoleType RoleType
virtual void clear()
Clear the graphics panel.