/*! * Initialize color map with some predefined colors. * Useful colors: http://www.computerhope.com/htmcolor.htm */ ColorMap::ColorMap(void) { //the unspecified type this->registerName(Pothos::DType().name(), Qt::gray); //integer types registerIntType<int8_t>(Qt::magenta); registerIntType<int16_t>(Qt::yellow); registerIntType<int32_t>(Qt::green); static const QColor orange("#FF7F00"); registerIntType<int64_t>(orange); //floating point registerFloatType<float>(Qt::red); static const QColor skyBlue("#6698FF"); registerFloatType<double>(skyBlue); //strings static const QColor cornYellow("#FFF380"); registerRType<std::string>(cornYellow); registerRType<std::wstring>(cornYellow); registerRType<QString>(cornYellow); //boolean static const QColor tiffBlue("#81D8D0"); registerRType<bool>(tiffBlue); //finalize with the pastelize for (auto &pair : *this) pair.second = pastelize(pair.second); }
/*********************************************************************** * work functions **********************************************************************/ void ConstellationDisplay::handleSamples(const Pothos::BufferChunk &buff) { if (_queueDepth.fetch_sub(1) != 1) return; //create curve that it doesnt exist if (not _curve) { _curve.reset(new QwtPlotCurve()); _curve->attach(_mainPlot); _curve->setPen(pastelize(getDefaultCurveColor(0)), 2.0); _curve->setStyle(QwtPlotCurve::Dots); } //convert to points and post to curve const auto samps = buff.as<const std::complex<float> *>(); QVector<QPointF> points(buff.elements()); for (int i = 0; i < points.size(); i++) { points[i] = QPointF(samps[i].real(), samps[i].imag()); } _curve->setSamples(points); //replot _mainPlot->replot(); }
static QColor __typeStrToColor(const QString &typeStr) { //This first part does nothing more than create 3 random 8bit numbers //by mapping a chunk of a repeatable hash function to a color hex code. QCryptographicHash hasher(QCryptographicHash::Md5); hasher.addData(typeStr.toUtf8()); const auto hexHash = hasher.result().toHex(); QColor c("#" + QString(hexHash).mid(0, 6)); //Use the 3 random numbers to create a pastel color. return pastelize(c); }