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
keyboardgraphicsview.cpp
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 #include "keyboardgraphicsview.h"
21 #include <QFontDatabase>
22 #include <QMouseEvent>
23 #include <QKeyEvent>
24 #include <QShortcut>
25 #include <QLinearGradient>
26 #include <QDebug>
27 #include <QGraphicsTextItem>
28 #include <QGraphicsSimpleTextItem>
29 #include <QScroller>
36 #include "core/piano/piano.h"
40 #include "displaysize.h"
41 
44 using piano::KC_BLACK;
45 using piano::KC_WHITE;
46 
57 
58 
59 const QColor KeyboardGraphicsView::KEY_PRELIMINARY_COLOR = Qt::gray;
64 
66  : QGraphicsView(parent),
67  mKeyboard(nullptr),
68  mKeysGraphicsItems(0),
69  mCenterOnKey(-1),
70  mSelectedKey(-1),
71  mSelectedKeyState(KeyState::STATE_NORMAL),
72  mPreliminaryKey(-1),
73  mKeyNumberOfA(-1) {
76 
77  setScene(&mScene);
78  setWhatsThis(tr("This window displays the keyboard. Each key has a small indicator that will display the current recording state of this key."));
79 
80  // antialiasing for nice lines
81  setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
82 
83 
84  // create shortcuts for selecting next and previous key
85  new QShortcut(QKeySequence(Qt::Key_Left), this, SLOT(selectPrevious()));
86  new QShortcut(QKeySequence(Qt::Key_Right), this, SLOT(selectNext()));
87  new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(deselectKey()));
88 
89  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
90 
91  if (DisplaySizeDefines::getSingleton()->keepKeyboardRatioFixed()) {
92  QSizePolicy sp(sizePolicy());
93  sp.setHeightForWidth(true);
94  setSizePolicy(sp);
95  }
96 
97  // scroll bar always off, looks nicer, since it is scrollable with the finger
98  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
99  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
100  QScroller::grabGesture(this, QScroller::LeftMouseButtonGesture);
101 }
102 
104 {
105 
106 }
107 
109  mKeyboard = kb;
110  if (mKeyboard) {
112  }
113 }
114 
115 void KeyboardGraphicsView::setSelection(int key, KeyState state, int preliminary) {
116  selectKey(key, state, false);
117  selectPreliminaryKey(preliminary);
118 }
119 
121  mCenterOnKey = key;
122  if (key >= 0 && key < static_cast<int>(mKeysGraphicsItems.size())) {
123  centerOn(mKeysGraphicsItems[key]);
124  }
125 }
126 
127 void KeyboardGraphicsView::showEvent(QShowEvent *event) {
128  QGraphicsView::showEvent(event);
129 }
130 
131 void KeyboardGraphicsView::resizeEvent(QResizeEvent *event) {
132  if (!DisplaySizeDefines::getSingleton()->keepKeyboardRatioFixed()) {
133  if (mResizeBlocked > 0) {
134  --mResizeBlocked;
135  } else {
136  bool wGrH = width() / height() > mScene.width() / mScene.height();
137  QSizePolicy sp(sizePolicy());
138  sp.setHeightForWidth(wGrH);
139  setSizePolicy(sp);
140 
141  mResizeBlocked += 2;
142  }
143  }
144 
145  QGraphicsView::resizeEvent(event);
146  fitAllInView();
148 }
149 
151  QGraphicsView::scrollContentsBy(dx, dy);
152  QRectF visibleRect(getVisibleContentsRect());
153 
155  view->scene()->setSceneRect(visibleRect);
156  view->fitInView(visibleRect, Qt::IgnoreAspectRatio);
157  }
158 }
159 
161  if (mScene.sceneRect().width() == 0) {
162  return w * TOTAL_HEIGHT / (88 * KEY_WIDTH);
163  }
164  return w * mScene.height() / mScene.width();
165 }
166 
167 void KeyboardGraphicsView::mousePressEvent(QMouseEvent *event) {
168  QGraphicsView::mousePressEvent(event);
169 
170  int newSelectedKey = getKeyAtPosition(event->pos());
171 
172  bool notifyListeners = true;
173  if (newSelectedKey == mSelectedKey) {
175  deselectKey(notifyListeners);
176  } else {
177  selectKey(newSelectedKey, STATE_FORCED, notifyListeners);
178  }
179  } else {
180  selectKey(newSelectedKey, STATE_NORMAL, notifyListeners);
181  }
182 }
183 
184 void KeyboardGraphicsView::mouseMoveEvent(QMouseEvent *event) {
185  QGraphicsView::mouseMoveEvent(event);
186 
187  if (event->buttons() & Qt::LeftButton) {
188  int newSelectedKey = getKeyAtPosition(event->pos());
189  if (newSelectedKey != mSelectedKey) {
190  selectKey(newSelectedKey, STATE_NORMAL);
191  }
192  }
193 }
194 
195 void KeyboardGraphicsView::keyPressEvent(QKeyEvent *event) {
196  QGraphicsView::keyPressEvent(event);
197 
198  if (event->key() == Qt::Key_Return) {
200  }
201 }
202 
204  switch (m->getType()) {
206  auto mksc(std::static_pointer_cast<MessageKeySelectionChanged>(m));
207  selectKey(mksc->getKeyNumber(), mksc->getKeyState(), false);
209  scaledViews->highlightKey(mksc->getKeyNumber());
210  }
211  break;}
213  auto mpk(std::static_pointer_cast<MessagePreliminaryKey>(m));
214  selectPreliminaryKey(mpk->getKeyNumber());
215  break;
216  }
218  auto mpf(std::static_pointer_cast<MessageProjectFile>(m));
219  mKeyboard = &mpf->getPiano().getKeyboard();
220  changeTotalNumberOfKeys(mpf->getPiano().getKeyboard().getNumberOfKeys(), mpf->getPiano().getKeyboard().getKeyNumberOfA4());
221  break;
222  }
224  // deselect all
227 
228  // redraw all markers
230  break;
232  auto mkdc(std::static_pointer_cast<MessageKeyDataChanged>(m));
233  updateColorMarker(mkdc->getIndex());
234  setKeyColor(mkdc->getIndex());
235  // update key
236  break;
237  }
240  break;
241  default:
242  break;
243  }
244 }
245 
246 
248  EptAssert(mKeyboard, "The key data structure has to exist");
249 
250  if (mKeyboard->getKeyColor(key0) == KC_BLACK) {
251  // black
252  mKeysGraphicsItems[key0]->setBrush(QBrush(Qt::black));
253  } else {
254  // white
255  mKeysGraphicsItems[key0]->setBrush(QBrush(Qt::white));
256  }
257 
258  updateColorMarker(key0);
259 }
260 
262  EptAssert(key >= 0, "Key has to exist");
263  EptAssert(mKeyboard, "Keyboard has to be set");
264  QColor selectedKeyColor = getKeyColor(mKeyboard->getKeyColor(key),
265  mSelectedKey == key,
267  mKeyboard->at(key).isRecorded());
268  QColor preliminaryColor = KEY_PRELIMINARY_COLOR;
269 
270  if (mPreliminaryKey == key && mSelectedKey == key) {
271  /*QLinearGradient g(0, 0, 5, 5);
272  g.setSpread(QGradient::RepeatSpread);
273  g.setColorAt(0, selectedKeyColor);
274  g.setColorAt(1, preliminaryColor);
275  mKeysGraphicsItems[mSelectedKey]->setBrush(QBrush(g));*/
276  /*QColor c;
277  c.setRed(preliminaryColor.red() * selectedKeyColor.red() / 255);
278  c.setGreen(preliminaryColor.green() * selectedKeyColor.green() / 255);
279  c.setBlue(preliminaryColor.blue() * selectedKeyColor.blue() / 255);
280  mKeysGraphicsItems[mSelectedKey]->setBrush(QBrush(c));*/
282  } else if (mPreliminaryKey == key) {
283  mKeysGraphicsItems[mPreliminaryKey]->setBrush(QBrush(preliminaryColor));
284  } else if (mSelectedKey == key) {
285  mKeysGraphicsItems[mSelectedKey]->setBrush(QBrush(selectedKeyColor));
286  } else {
287  if (mKeyboard->getKeyColor(key) == KC_BLACK) {
288  // black
289  mKeysGraphicsItems[key]->setBrush(QBrush(Qt::black));
290  } else {
291  // white
292  mKeysGraphicsItems[key]->setBrush(QBrush(Qt::white));
293  }
294  }
295 }
296 
297 void KeyboardGraphicsView::selectKey(int8_t key0, piano::KeyState keyState, bool notifyMessageListeners) {
298  if (mSelectedKey == key0 && mSelectedKeyState == keyState) {
299  // nothing changed
300  return;
301  }
302 
303  if (mSelectedKey >= 0) {
305  return; // out of rage
306  }
307 
308  // reset key and marker!
310 
311  // if old key was the preliminary key, mark it as gray
312  if (mSelectedKey == mPreliminaryKey) {
314  }
315  }
316 
317  mSelectedKey = key0;
318 
319  if (notifyMessageListeners) {
320  MessageHandler::send<MessageKeySelectionChanged>(key0, mKeyboard->getKeyPtr(key0), keyState);
321  emit selectionChanged(key0);
322  }
323 
324  if (mSelectedKey < 0) {
325  return;
326  }
327 
328  mSelectedKeyState = keyState;
330 
331  updateColorMarker(key0);
332 }
333 
335  if (mPreliminaryKey == key0) {
336  return;
337  }
338 
339  int oldKey = mPreliminaryKey;
340  mPreliminaryKey = key0;
341 
342  if (oldKey >= 0) {
343  setKeyColor(oldKey);
344  }
345 
346  if (mPreliminaryKey < 0) {
347  return;
348  }
349 
351 }
352 
354  EptAssert(mKeyboard, "The key data structure has to exist");
355 
356  for (int8_t i = 0; i < (int8_t)mKeysGraphicsItems.size(); i++) {
358  }
359 }
360 
362  EptAssert(mKeyboard, "The key data structure has to exist");
363 
364  if (key0 < 0) {
365  return; // an error occurred
366  }
367 
368  bool recorded(mKeyboard->at(key0).isRecorded());
369  mMarkerPixmapItems[key0]->setPixmap(getPixmapForKeyRecordingState(recorded));
370 }
371 
373  if (!recorded) {
374  return QPixmap(":/media/images/status_unchecked.png");
375  } else {
376  return QPixmap(":/media/images/status_checked.png");
377  }
378 }
379 
380 QColor KeyboardGraphicsView::getKeyColor(piano::KeyColor color, bool selected, KeyState keyState, bool recorded) {
381  if (selected) {
382  if (recorded) {
383  if (keyState == STATE_FORCED) {
384  return QColor(KEY_SELECTED_RECORDED_COLOR).darker();
385  }
386  return QColor(KEY_SELECTED_RECORDED_COLOR);
387  } else {
388  if (keyState) {
389  return QColor(KEY_SELECTED_UNRECORDED_COLOR).darker();
390  }
391  return QColor(KEY_SELECTED_UNRECORDED_COLOR);
392  }
393  }
394  if (color == KC_WHITE) {
395  return QColor(Qt::white);
396  }
397  return QColor(Qt::black).darker(350);
398 }
399 
400 QRectF KeyboardGraphicsView::keyShape(int8_t key0) {
401  double frac = 12.0 / 7.0; // distribute 7 keys of a total size of 12
402 
403  switch ((key0 + 9 + (120 - mKeyboard->getKeyNumberOfA4())) % 12) {
404  // white keys
405  case 0: return QRectF((key0) * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH * frac, KEY_HEIGHT);
406  case 2: return QRectF((key0 - 2 + 1 * frac) * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH * frac, KEY_HEIGHT);
407  case 4: return QRectF((key0 - 4 + 2 * frac) * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH * frac, KEY_HEIGHT);
408  case 5: return QRectF((key0 - 5 + 3 *frac) * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH * frac, KEY_HEIGHT);
409  case 7: return QRectF((key0 - 7 + 4 * frac) * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH * frac, KEY_HEIGHT);
410  case 9: return QRectF((key0 - 9 + 5 * frac) * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH * frac, KEY_HEIGHT);
411  case 11: return QRectF((key0 - 11 + 6 * frac) * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH * frac, KEY_HEIGHT);
412 
413  // black keys
414  default:
415  return QRectF(key0 * KEY_WIDTH, KEY_SPACING_TO_MARKERS, KEY_WIDTH, KEY_HEIGHT * KEY_BLACK_TO_WHITE_RATIO);
416  }
417 }
418 
420  if (keys == static_cast<int>(mMarkerPixmapItems.size()) && mKeyNumberOfA == keyA) {
421  // no changes, but redraw markers
423  return;
424  }
425 
426  mKeyNumberOfA = keyA;
427 
428  mScene.clear(); // clear all elements
429 
430  mKeysGraphicsItems.resize(keys);
431  mMarkerPixmapItems.resize(keys);
432 
433  // big gradient as shadow
434  QLinearGradient shadowGradient(0, 0, 0, KEY_HEIGHT);
435  shadowGradient.setSpread(QGradient::PadSpread);
436  shadowGradient.setColorAt(0.9, Qt::black);
437  shadowGradient.setColorAt(1, Qt::transparent);
438  QGraphicsRectItem *shadowItem = mScene.addRect(0, 0, KEY_WIDTH * keys, KEY_HEIGHT, Qt::NoPen, QBrush(shadowGradient));
439  shadowItem->setPos(0, KEY_SPACING_TO_MARKERS);
440 
441 
442  // font for keys
443  QFont keyFont;
444  keyFont.setPixelSize(12);
445 
446  for (int8_t i = 0; i < (int8_t)(mMarkerPixmapItems.size()); i++) {
447  auto keyColorType = mKeyboard->getKeyColor(i);
448  QString keyText = QString::fromStdString(mKeyboard->getNoteName(i));
449 
450  QPen borderpen(QBrush(Qt::black), PEN_THIN_LINE);
451  borderpen.setCosmetic(true);
452 
453  // marker pixmaps
454  QGraphicsPixmapItem *pixmapItem = mScene.addPixmap(getPixmapForKeyRecordingState(mKeyboard->at(i).isRecorded()));
455  pixmapItem->setPos(i * KEY_WIDTH + KEY_MARKERS_MARGIN, 0);
456  // 64 is the size of the picture
457  pixmapItem->setScale(KEY_WIDTH / 64.0);
458  // smooth transformation, nicer, non pixled borders
459  pixmapItem->setTransformationMode(Qt::SmoothTransformation);
460  mMarkerPixmapItems[i] = pixmapItem;
461 
462  // just paint A's, looks nicer. Remove clear lines, to paint all names
463  QColor keyColor = getKeyColor(keyColorType, false, STATE_NORMAL, false);
464  QColor textColor;
465  if (keyColorType == KC_BLACK) {
466  // black
467  textColor = Qt::darkGray;
468  keyText.clear();
469  } else {
470  // white key
471  // only A's are black, all others are gray
472  if ((i + 1200 - mKeyNumberOfA) % 12 == 0) {
473  textColor = Qt::black;
474  } else {
475  textColor = Qt::lightGray;
476  keyText.clear();
477  }
478  }
479 
480  // key rects
481  QRectF shape(keyShape(i));
482  shape.setHeight(shape.height() - 2 * PEN_THIN_LINE);
483  QPointF pos(shape.topLeft());
484  shape.setTopLeft(QPointF(0, 0));
485  GraphicsKeyItem *item = new GraphicsKeyItem(keyColorType, keyText, textColor);
486  mScene.addItem(item);
487  item->setPos(pos);
488  item->setBrush(QBrush(keyColor));
489  item->setFont(keyFont);
490 
491  item->setPen(borderpen);
492  mKeysGraphicsItems[i] = item;
493 
494  if (keyColorType == KC_BLACK) {
495  item->setZValue(1);
496  }
497  }
498 
499 
500  setSceneRect(QRectF(0, 0, KeyboardGraphicsView::KEY_WIDTH * keys, KeyboardGraphicsView::TOTAL_HEIGHT));
501 
502  for (auto *view : mAutoScaledGraphicsViews) {
503  view->setSceneRect(QRectF(0, 0, KeyboardGraphicsView::KEY_WIDTH * keys, KeyboardGraphicsView::TOTAL_HEIGHT));
504  }
505 
506  fitAllInView();
507  updateGeometry();
508 }
509 
511  Qt::AspectRatioMode arm = Qt::KeepAspectRatioByExpanding;
512  fitInView(mScene.sceneRect(), arm);
513 
514  scrollContentsBy(0, 0);
515 }
516 
518  QGraphicsRectItem *selectedItem(nullptr);
519 
520  QList<QGraphicsItem *> itemList(items(pos));
521  for (QGraphicsItem *item : itemList) {
522  if (item->type() == QGraphicsRectItem::Type) {
523  if (!selectedItem || item->zValue() > selectedItem->zValue()) {
524  // select top most rect
525  selectedItem = dynamic_cast<QGraphicsRectItem*>(item);
526  }
527  }
528  }
529  if (!selectedItem) {return -1;}
530 
531  for (int8_t i = 0; i < (int8_t)(mKeysGraphicsItems.size()); i++) {
532  if (mKeysGraphicsItems[i] == selectedItem) {
533  return i;
534  }
535  }
536 
537  return -1;
538 }
539 
541  setFocus();
542  selectKey(std::min<int>(mSelectedKey + 1, mKeysGraphicsItems.size() - 1), STATE_NORMAL);
543 }
544 
546  setFocus();
547  selectKey(std::max(0, mSelectedKey - 1), STATE_NORMAL);
548 }
549 
550 void KeyboardGraphicsView::deselectKey(bool notifyListeners) {
551  setFocus();
552  selectKey(-1, STATE_NORMAL, notifyListeners);
553 }
554 
556  QPointF topLeft = mapToScene(0, 0);
557  topLeft.setY(0);
558  QPointF bottomRight = mapToScene(width(), height());
559  bottomRight.setY(TOTAL_HEIGHT);
560 
561  return QRectF(topLeft, bottomRight);
562 }
bool isRecorded() const
Get recorded flag.
Definition: key.h:102
void mouseMoveEvent(QMouseEvent *event) override
void redrawAllMarkers()
Force all markers to update its state.
Normal state.
Definition: pianodefines.h:41
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
Definition: message.h:98
KeyState mSelectedKeyState
The key state of the selected key.
void changeTotalNumberOfKeys(int keys, int keyA)
Function to change the total number of keys and the key number of A.
static const QColor KEY_SELECTED_UNRECORDED_COLOR
Color of the selected key if it is not recorded.
static const QColor KEY_SELECTED_RECORDED_COLOR
Color of the selected key if it is recorded.
called when the recording was cleared
Definition: message.h:50
static const QColor KEY_PRELIMINARY_COLOR
Color of the preliminary key.
void setKeyColor(int8_t key)
Function to set the key color of key.
void handleMessage(MessagePtr m) override
Message handling.
data of a key changed
Definition: message.h:62
Class describing the piano keyboard, holding a collection of keys.
Definition: keyboard.h:39
int mKeyNumberOfA
The keynumber of A of the given mKeyboard.
const Keyboard * mKeyboard
Pointer to the keyboard that is displayed.
static const int NO_KEY
No key selection constant.
static const qreal KEY_BLACK_TO_WHITE_RATIO
Size ratio of black and white keys.
const Key & at(size_t i) const
Definition: keyboard.h:61
void mousePressEvent(QMouseEvent *event) override
The mouse press will select the klicked key.
virtual void scrollContentsBy(int dx, int dy) overridefinal
std::vector< QGraphicsRectItem * > mKeysGraphicsItems
List of all key items.
static const qreal KEY_WIDTH
Width of a single key.
static const qreal KEY_WHITE_KEY_SIZE
Size of a white key (a bit bigger than KEY_WIDTH)
Message that a change was made with the current project file.
Definition: message.h:68
static const qreal PEN_MEDIUM_LINE
Medium pen line width.
KeyboardGraphicsView(QWidget *parent)
Constructor.
void deselectKey(bool notifyListeners=true)
Slot to deselect a key.
int getKeyAtPosition(const QPoint &pos)
Function to get the key index at the given position.
static void initShapes(qreal b_w, qreal b_h, qreal w_w, qreal w_h)
static const QColor KEY_PRELIMINARY_AND_SELECTED_COLOR
Color if the preliminary key equates the selected key.
QList< AutoScaledToKeyboardGraphicsView * > mAutoScaledGraphicsViews
List of other graphic views that are scaled along this keyboard view.
void selectKey(int8_t key0, KeyState keyState, bool notifyMessageListeners=true)
Function to select or deselect a key.
static const qreal KEY_FORCED_FACTOR
Color scaling if the key is forced.
const Key * getKeyPtr(int i) const
Get pointer to a key with a given number, returning nullptr if the number is out of range (read-only ...
Definition: keyboard.cpp:104
void resizeEvent(QResizeEvent *event) override
Reimplemented to keep the complete scene rect in the view.
void selectionChanged(int8_t key)
Signal beeing emitted if the selected key changed.
void resetKey(int8_t key)
Function to reset the key and marker color to the unselected state.
std::vector< QGraphicsPixmapItem * > mMarkerPixmapItems
List of all marker items.
static const qreal PEN_THIN_LINE
Thin pen line width.
int8_t mSelectedKey
The selected key.
int8_t mPreliminaryKey
The preliminary key.
Message that a key has been selected.
Definition: message.h:63
void setKeyboard(const Keyboard *kb)
Setter for mKeyboard.
KeyColor
The KeyColor enum.
Definition: pianodefines.h:51
void setSelection(int key, KeyState state, int preliminary)
Function to set the current selection.
int heightForWidth(int w) const override
Get the height for a given view width.
void centerOnKey(int8_t key)
This function will center the view on the given key.
std::string getNoteName(int keynumber) const
Get the name of the key as a string.
Definition: keyboard.cpp:135
int8_t mCenterOnKey
Index of the key to center on.
QRectF keyShape(int8_t key0)
Returns a QRectF as shape of the given key.
static const qreal TOTAL_HEIGHT
Total height of the view.
number of the key recognized during recording
Definition: message.h:67
void showEvent(QShowEvent *event) override
Reimplemented to keep the complete scene rect in the view.
White key.
Definition: pianodefines.h:53
void selectNext()
Slot that will select the next key.
Black key.
Definition: pianodefines.h:52
static const qreal KEY_SPACING_TO_MARKERS
Space between keys and markers.
void keyPressEvent(QKeyEvent *event) override
Handler for key presses.
void updateColorMarker(int8_t key0)
Function to update a single color marker.
int getKeyNumberOfA4() const
Definition: keyboard.h:73
void selectPrevious()
Slot that will select the previous key.
static const qreal KEY_MARKERS_MARGIN
Margin of a single marker.
void fitAllInView()
Fit the complete scene rect in the given view.
#define EptAssert(a, b)
Definition: eptexception.h:47
QGraphicsScene mScene
The QGraphicsScene in which the elements will be drawed.
void selectPreliminaryKey(int8_t key0)
Function to change the prelimary key stored in mPreliminaryKey.
void setFont(const QFont &font)
An GraphicsViewAdaptorForQt keeping the same size as a KeyboardGraphicsView.
static const qreal GLOBAL_SCALING
A global scaling factor.
QPixmap getPixmapForKeyRecordingState(bool recorded)
Function to get the QPixmap for the given recording state.
QColor getKeyColor(piano::KeyColor color, bool selected, KeyState keyState, bool recorded)
Function to get the key color.
static const std::unique_ptr< DisplaySizeDefines > & getSingleton()
Definition: displaysize.cpp:29
int getNumberOfKeys() const
Definition: keyboard.h:72
analysis of the signal ended
Definition: message.h:54
piano::KeyColor getKeyColor(int keynumber) const
Get the color of the key (black / white)
Definition: keyboard.cpp:160
KeyState
The KeyState enum.
Definition: pianodefines.h:40
static const qreal KEY_HEIGHT
Height of a single key.
Key is forced.
Definition: pianodefines.h:42
QRectF getVisibleContentsRect() const