void ColorChooser::changeBackgroundColor(const QImage* imageOriginal, QRgb rgbBg) { if (rgbBg != m_rgbBg) { m_rgbBg = rgbBg; loadForegroundPixmap(m_rgbBg); loadHistograms(imageOriginal); } }
void analyzeContinuously(HumdrumFile& infile, int windowsize, double stepsize, double* majorKey, double* minorKey) { Array<Array<double> > segments; infile.analyzeRhythm("4"); int segmentCount = int(infile.getTotalDuration() / stepsize + 0.5); if (segmentCount < windowsize) { cout << "Not enough data for requested analysis" << endl; return; } segments.setSize(segmentCount); segments.allowGrowth(0); int i; for (i=0; i<segments.getSize(); i++) { segments[i].setSize(12); segments[i].allowGrowth(0); segments[i].setAll(0); } loadHistograms(segments, infile, segmentCount); if (debugQ) { printHistogramTotals(segments); } Array<Array<double> > pitchhist; Array<Array<double> > correlations; pitchhist.setSize(segmentCount-windowsize); correlations.setSize(segmentCount-windowsize); pitchhist.allowGrowth(0); correlations.allowGrowth(0); for (i=0; i<segmentCount-windowsize; i++) { pitchhist[i].setSize(13); //last spot for best key pitchhist[i].allowGrowth(0); correlations[i].setSize(24); correlations[i].allowGrowth(0); } for (i=0; i<segmentCount - windowsize; i++) { createHistogram(pitchhist[i], i, windowsize, segments); identifyKeyDouble(pitchhist[i], correlations[i], majorKey, minorKey); } Array<double> measures; getLocations(measures, infile, segmentCount); cout << "**key\t**rval\t**conf\t**start\t**mid\t**end\n"; for (i=0; i<pitchhist.getSize(); i++) { printBestKey(int(pitchhist[i][12] + 0.5)); cout << "\t"; printCorrelation(correlations[i][int(pitchhist[i][12]+ 0.1)], roundQ); cout << "\t"; cout << getConfidence(correlations[i], int(pitchhist[i][12]+0.1)); cout << "\t"; cout << "=" << measures[i]; cout << "\t"; cout << "=" << int((measures[i] + measures[i+windowsize])/2+0.49); cout << "\t"; cout << "=" << measures[i+windowsize]; cout << endl; } cout << "*-\t*-\t*-\t*-\t*-\t*-\n"; }
ColorChooser::ColorChooser(QWidget* parent, const QImage* imageOriginal, int xTopLeft, int yTopLeft, QRgb rgbBg, bool showLarge) : m_parent(parent), pixmapIntensity(colorchooser_value_xpm), pixmapForeground(colorchooser_value_xpm), pixmapHue(colorchooser_hue_xpm), pixmapSaturation(colorchooser_saturation_xpm), pixmapValue(colorchooser_value_xpm), editLow(0), editHigh(0), m_discretizeMethod(DiscretizeNone), m_rgbBg(rgbBg), m_showLarge(showLarge) { DigitDebug::ctor(QString("colorchooser ") + QString::number((ulong) this, 16)); ASSERT_ENGAUGE(m_parent != 0); int x = xTopLeft, y = yTopLeft; QColor grayoutColor(232, 232, 232); if (showLarge) { m_chooserHeight = ChooserFullHeight; m_scaleHeight = ScaleFullHeight; } else { m_chooserHeight = ChooserFullHeight / 2; m_scaleHeight = ScaleFullHeight / 2; } chooserCanvas = new Q3Canvas(parent); CHECK_PTR_ENGAUGE(chooserCanvas); chooserCanvas->resize(ChooserWidth + 2 * ChooserPadding, m_chooserHeight); grayoutLower = new Q3CanvasPolygon(chooserCanvas); CHECK_PTR_ENGAUGE(grayoutLower); grayoutLower->setBrush(QBrush(grayoutColor)); grayoutLower->setZ(-1); grayoutLower->setVisible(true); grayoutUpper = new Q3CanvasPolygon(chooserCanvas); CHECK_PTR_ENGAUGE(grayoutUpper); grayoutUpper->setBrush(QBrush(grayoutColor)); grayoutUpper->setZ(-1); grayoutUpper->setVisible(true); chooserCanvasView = new ClickableView(chooserCanvas, m_parent); CHECK_PTR_ENGAUGE(chooserCanvasView); chooserCanvasView->setGeometry(x, y, ChooserWidth + 2 * ChooserPadding + ChooserFrame, m_chooserHeight); y += m_chooserHeight + Separation; chooserCanvasView->setHScrollBarMode(Q3ScrollView::AlwaysOff); chooserCanvasView->setVScrollBarMode(Q3ScrollView::AlwaysOff); QWhatsThis::add(chooserCanvasView, QString(tr( "Histogram of color attribute values. The lower and upper limits are shown, " "and may be dragged using the handles"))); scaleCanvas = new Q3Canvas(this); CHECK_PTR_ENGAUGE(scaleCanvas); scaleCanvas->resize(ChooserWidth + 2 * ChooserPadding, m_scaleHeight); scaleCanvasView = new Q3CanvasView(scaleCanvas, m_parent); CHECK_PTR_ENGAUGE(scaleCanvasView); scaleCanvasView->setGeometry(x, y, ChooserWidth + 2 * ChooserPadding + ChooserFrame, m_scaleHeight); y += m_scaleHeight + 5; scaleCanvasView->setHScrollBarMode(Q3ScrollView::AlwaysOff); scaleCanvasView->setVScrollBarMode(Q3ScrollView::AlwaysOff); QWhatsThis::add(scaleCanvasView, QString(tr("Scale for histogram"))); // histogram widgets dividerLower = new Divider(this, chooserCanvas, true); CHECK_PTR_ENGAUGE(dividerLower); dividerUpper = new Divider(this, chooserCanvas, false); CHECK_PTR_ENGAUGE(dividerUpper); if (m_showLarge) { // labels over min and max value columns labelLower = new QLabel(QString(tr("Lower limit:")), m_parent); CHECK_PTR_ENGAUGE(labelLower); labelLower->setGeometry(x, y, EditWidth, 30); labelUpper = new QLabel(QString(tr("Upper limit:")), m_parent); CHECK_PTR_ENGAUGE(labelUpper); labelUpper->setGeometry(x + ChooserWidth + 2 * ChooserPadding + ChooserFrame - EditWidth, y, EditWidth, 30); y += 25; // edit controls for keyboard editing of limits editLow = new QLineEdit(m_parent); CHECK_PTR_ENGAUGE(editLow); editLow->setGeometry(x, y, EditWidth, 30); QWhatsThis::add(editLow, QString(tr("Lower limit.\n\nIf the lower limit is less than the upper limit, " "only values between the limits are considered on. If the lower limit is greater than the upper limit, " "only values outside the limits are considered on"))); validatorLow = new QIntValidator(editLow); CHECK_PTR_ENGAUGE(validatorLow); editLow->setValidator(validatorLow); connect(editLow, SIGNAL(textChanged(const QString &)), this, SLOT(slotLow(const QString &))); editHigh = new QLineEdit(m_parent); CHECK_PTR_ENGAUGE(editHigh); editHigh->setGeometry(x + ChooserWidth + 2 * ChooserPadding + ChooserFrame - EditWidth, y, EditWidth, 30); QWhatsThis::add(editHigh, QString(tr("Upper limit.\n\nIf the lower limit is less than the upper limit, " "only values between the limits are considered on. If the lower limit is greater than the upper limit, " "only values outside the limits are considered on"))); validatorHigh = new QIntValidator(editHigh); CHECK_PTR_ENGAUGE(validatorHigh); editHigh->setValidator(validatorHigh); connect(editHigh, SIGNAL(textChanged(const QString &)), this, SLOT(slotHigh(const QString &))); } loadHistograms(imageOriginal); }