TunerView::TunerView( int viewID_, QWidget *parent ) : ViewWidget( viewID_, parent) { //setCaption("Chromatic Tuner"); Q3GridLayout *layout = new Q3GridLayout(this, 9, 3, 2); layout->setResizeMode(QLayout::SetNoConstraint); // Tuner widget goes from (0, 0) to (0, 8); //tunerWidget = new TunerWidget(this); tunerWidget = new VibratoTunerWidget(this); layout->addMultiCellWidget(tunerWidget, 0, 0, 0, 8); // Slider goes from (2,0) to (2,9) //slider = new QwtSlider(this, "slider", Qt::Horizontal, QwtSlider::Bottom, QwtSlider::BgTrough); #if QWT_VERSION == 0x050000 slider = new QwtSlider(this, Qt::Horizontal, QwtSlider::Bottom, QwtSlider::BgTrough); #else slider = new QwtSlider(this, Qt::Horizontal, QwtSlider::BottomScale, QwtSlider::BgTrough); #endif slider->setRange(0, 2); slider->setReadOnly(false); layout->addMultiCellWidget(slider, 1, 1, 0, 8); QToolTip::add(slider, "Increase slider to smooth the pitch over a longer time period"); ledBuffer = new QPixmap(); leds.push_back(new LEDIndicator(ledBuffer, this, "A")); leds.push_back(new LEDIndicator(ledBuffer, this, "B")); leds.push_back(new LEDIndicator(ledBuffer, this, "C")); leds.push_back(new LEDIndicator(ledBuffer, this, "D")); leds.push_back(new LEDIndicator(ledBuffer, this, "E")); leds.push_back(new LEDIndicator(ledBuffer, this, "F")); leds.push_back(new LEDIndicator(ledBuffer, this, "G")); leds.push_back(new LEDIndicator(ledBuffer, this, "#")); // Add the leds for note names into the positions (1, 0) to (1, 6) for (int n = 0; n < 7; n++) { layout->addWidget(leds.at(n), 2, n); } // (1, 7) is blank // Add the flat led layout->addWidget(leds.at(7), 2, 8); layout->setRowStretch( 0, 4 ); layout->setRowStretch( 1, 1 ); layout->setRowStretch( 2, 0 ); //connect(gdata->view, SIGNAL(onFastUpdate(double)), this, SLOT(update())); //connect(gdata, SIGNAL(onChunkUpdate()), tunerWidget, SLOT(doUpdate())); connect(gdata, SIGNAL(onChunkUpdate()), this, SLOT(doUpdate())); connect(tunerWidget, SIGNAL(ledSet(int, bool)), this, SLOT(setLed(int, bool))); }
HTrackView::HTrackView( int viewID_, QWidget *parent ) : ViewWidget( viewID_, parent) { //setCaption("HTrack view"); Q3GridLayout *mainLayout = new Q3GridLayout(this, 2, 2); mainLayout->setResizeMode(QLayout::SetNoConstraint); //QBoxLayout *topLayout = new QVBoxLayout(mainLayout); //QBoxLayout *rightLayout = new QVBoxLayout(mainLayout); Q3BoxLayout *rightLayout = new Q3VBoxLayout(); Q3BoxLayout *bottomLayout = new Q3HBoxLayout(); Q3Grid *frame = new Q3Grid(1, this); frame->setFrameStyle(Q3Frame::WinPanel | Q3Frame::Sunken); //frame->setLineWidth(2); //frame->setMidLineWidth(2); QWidget *aWidget = new QWidget(frame); hTrackWidget = new HTrackWidget(aWidget); hTrackWidget->setWhatsThis("Shows a 3D keyboard with the current note coloured. " "Vertical columns (or tracks), each representing a harmonic (or component frequency), protrude from the back, and move further away over time. " "The height of each track is related to how much energy is at that frequency. " "Tracks alternate in colour for better visibility. It can be seen how the hamonics in a note fit into the musical scale."); //hTrackWidget->show(); peakThresholdSlider = new QSlider(0, 100, 10, 5, Qt::Vertical, this); QToolTip::add(peakThresholdSlider, "Thresholding of harmonics"); rotateXWheel = new QwtWheel(this); rotateXWheel->setWheelWidth(20); rotateXWheel->setRange(-180, 180, 0.1, 1); QToolTip::add(rotateXWheel, "Rotate piano horizonally"); rotateYWheel = new QwtWheel(this); rotateYWheel->setOrientation(Qt::Vertical); rotateYWheel->setWheelWidth(20); rotateYWheel->setRange(-90, 0, 0.1, 1); QToolTip::add(rotateYWheel, "Rotate piano vertically"); distanceWheel = new QwtWheel(this); distanceWheel->setOrientation(Qt::Vertical); //distanceWheel->setWheelWidth(20); distanceWheel->setRange(100, 5000, 10, 20); distanceWheel->setTotalAngle(20*360); QToolTip::add(distanceWheel, "Move towards/away from piano"); QPushButton *homeButton = new QPushButton("Reset", this, "homebutton"); QToolTip::add(homeButton, "Return to the original view"); QSizeGrip *sizeGrip = new QSizeGrip(this); //sizeGrip->setFixedSize(15, 15); mainLayout->addWidget(frame, 0, 0); mainLayout->addLayout(bottomLayout, 1, 0); mainLayout->addLayout(rightLayout, 0, 1); rightLayout->addStretch(2); rightLayout->addWidget(peakThresholdSlider); rightLayout->addStretch(4); rightLayout->addWidget(rotateYWheel); rightLayout->addSpacing(14); rightLayout->addWidget(distanceWheel); bottomLayout->addStretch(0); bottomLayout->addWidget(homeButton); bottomLayout->addSpacing(14); bottomLayout->addWidget(rotateXWheel); //bottomLayout->addSpacing(20); mainLayout->addWidget(sizeGrip, 1, 1); //make the widget get updated when the view changes connect(gdata->view, SIGNAL(onSlowUpdate(double)), hTrackWidget, SLOT(update())); connect(peakThresholdSlider, SIGNAL(valueChanged(int)), this, SLOT(setPeakThreshold(int))); connect(rotateYWheel, SIGNAL(valueChanged(double)), hTrackWidget, SLOT(setViewAngleVertical(double))); connect(rotateYWheel, SIGNAL(valueChanged(double)), hTrackWidget, SLOT(update())); connect(hTrackWidget, SIGNAL(viewAngleVerticalChanged(double)), rotateYWheel, SLOT(setValue(double))); connect(distanceWheel, SIGNAL(valueChanged(double)), hTrackWidget, SLOT(setDistanceAway(double))); connect(distanceWheel, SIGNAL(valueChanged(double)), hTrackWidget, SLOT(update())); connect(hTrackWidget, SIGNAL(distanceAwayChanged(double)), distanceWheel, SLOT(setValue(double))); connect(rotateXWheel, SIGNAL(valueChanged(double)), hTrackWidget, SLOT(setViewAngleHorizontal(double))); connect(rotateXWheel, SIGNAL(valueChanged(double)), hTrackWidget, SLOT(update())); connect(hTrackWidget, SIGNAL(viewAngleHorizontalChanged(double)), rotateXWheel, SLOT(setValue(double))); connect(homeButton, SIGNAL(clicked()), hTrackWidget, SLOT(home())); }