You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CircleOfFifths.cpp 1.9KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "CircleOfFifths.h"
  2. #include "MainWindow.h"
  3. #include <QColorDialog>
  4. CircleOfFifths::CircleOfFifths(qreal x, qreal y, qreal w, qreal h, MainWindow * parent): QGraphicsScene(x,y,w,h){
  5. addItem(circleElements[0] = new CircleElement(parent->colorScale.getToneByName("C")));
  6. addItem(circleElements[1] = new CircleElement(parent->colorScale.getToneByName("G")));
  7. addItem(circleElements[2] = new CircleElement(parent->colorScale.getToneByName("D")));
  8. addItem(circleElements[3] = new CircleElement(parent->colorScale.getToneByName("A")));
  9. addItem(circleElements[4] = new CircleElement(parent->colorScale.getToneByName("E")));
  10. addItem(circleElements[5] = new CircleElement(parent->colorScale.getToneByName("H")));
  11. addItem(circleElements[6] = new CircleElement(parent->colorScale.getToneByName("Fis")));
  12. addItem(circleElements[7] = new CircleElement(parent->colorScale.getToneByName("Cis")));
  13. addItem(circleElements[8] = new CircleElement(parent->colorScale.getToneByName("Gis")));
  14. addItem(circleElements[9] = new CircleElement(parent->colorScale.getToneByName("Dis")));
  15. addItem(circleElements[10] = new CircleElement(parent->colorScale.getToneByName("Ais")));
  16. addItem(circleElements[11] = new CircleElement(parent->colorScale.getToneByName("F")));
  17. for(int i=0; i<12; i++)
  18. QObject::connect(circleElements[i]->getTone(), &Tone::colorchanged, circleElements[i], &CircleElement::redraw);
  19. };
  20. void CircleOfFifths::mousePressEvent(QGraphicsSceneMouseEvent *event){
  21. if(event->button() == Qt::LeftButton){
  22. for(int i=0; i<12; i++){
  23. if(circleElements[i]->sceneBoundingRect().contains(event->scenePos())){
  24. circleElements[i]->getTone()->setColor(QColorDialog::getColor(circleElements[i]->getTone()->getColor()));
  25. }
  26. }}
  27. };
  28. CircleElement * CircleOfFifths::getCircleElement(int number)const{
  29. return circleElements[number];
  30. };