QString Resistor::makeSvg(const QString & resistance, ViewLayer::ViewLayerID viewLayerID) { QString moduleID = this->moduleID(); double ohms = TextUtils::convertFromPowerPrefix(resistance, OhmSymbol); QString sohms = QString::number(ohms, 'e', 3); int firstband = sohms.at(0).toAscii() - '0'; int secondband = sohms.at(2).toAscii() - '0'; int thirdband = sohms.at(3).toAscii() - '0'; int temp = (firstband * 10) + secondband; if (moduleID.contains("5Band")) { temp = (temp * 10) + thirdband; } int multiplier = (temp == 0) ? 0 : log10(ohms / temp); QString tolerance = prop("tolerance"); QString errorStr; int errorLine; int errorColumn; QDomDocument domDocument; if (!domDocument.setContent(viewLayerID == ViewLayer::Breadboard ? BreadboardSvgs.value(moduleID) : IconSvgs.value(moduleID), &errorStr, &errorLine, &errorColumn)) { return ""; } QDomElement root = domDocument.documentElement(); setBands(root, firstband, secondband, thirdband, multiplier, tolerance); return domDocument.toString(); }
void Resistor::setBands(QDomElement & element, int firstband, int secondband, int thirdband, int multiplier, const QString & tolerance) { QString id = element.attribute("id"); if (!id.isEmpty()) { if (id.compare("band_1_st") == 0) { element.setAttribute("fill", ColorBands.value(firstband, Qt::black).name()); } else if (id.compare("band_2_nd") == 0) { element.setAttribute("fill", ColorBands.value(secondband, Qt::black).name()); } else if (id.compare("band_3") == 0) { element.setAttribute("fill", ColorBands.value(thirdband, Qt::black).name()); } else if (id.compare("band_rd_multiplier") == 0) { element.setAttribute("fill", ColorBands.value(multiplier, Qt::black).name()); } else if (id.compare("gold_band") == 0) { element.setAttribute("fill", Tolerances.value(tolerance, QColor(173, 159, 78)).name()); } } QDomElement child = element.firstChildElement(); while (!child.isNull()) { setBands(child, firstband, secondband, thirdband, multiplier, tolerance); child = child.nextSiblingElement(); } }
void VoicePrint::resizeEvent(QResizeEvent *) { mOffset=0; mBuffer.resize(size()); QPainter paint(&mBuffer); paint.fillRect(QRect(0,0, QWidget::width(), height()), QColor(mLowColor)); setBands(magic(height()/mSegmentWidth)); }
void Terrain::setup() { frames = 0; meshResolution = 128; dist = 300; begin.set(18, 3, 194); end.set(38, 172, 22); indexLow = 0; indexHigh = 0; setColors(begin, end); gridSurfaceSetup(); setPeeks(); setBands(meshResolution); setFilter(1.25f); setSmoothingFactor(0.975f); cam.setDistance(dist); cam.enableMouseInput(); ofBackground(0, 0, 0); }
KJStereoFFT::KJStereoFFT(const QStringList &l, KJLoader *parent) : KJVisScope(parent), StereoFFTScope(50), mGradient(0) { //kdDebug(66666) << k_funcinfo << endl; int x = l[1].toInt(); int y = l[2].toInt(); int xs = l[3].toInt()-x; int ys = l[4].toInt()-y; // each bar will be 1px wide mMultiples=1; if ( parent->exist("analyzercolor") ) { QStringList &col = parser()["analyzercolor"]; mColor.setRgb ( col[1].toInt(), col[2].toInt(), col[3].toInt() ); } else // TODO: what should be default colors for Vis? { mColor.setRgb ( 255, 255, 255 ); // white is default } // background under vis QPixmap tmp = parent->pixmap(parent->item("backgroundimage")[1]); mBack = new KPixmap ( QSize(xs,ys) ); bitBlt( mBack, 0, 0, &tmp, x, y, xs, ys, Qt::CopyROP ); mAnalyzer = new KPixmap ( QSize(xs,ys) ); bitBlt( mAnalyzer, 0, 0, &tmp, x, y, xs, ys, Qt::CopyROP ); // create a gradient for the bars going from 30% lighter to 30% darker than mColor mGradient = new KPixmap ( QSize(xs,ys) ); KPixmapEffect::gradient ( *mGradient, mColor.light(_KJ_GRADIENT_DIFF), mColor.dark(_KJ_GRADIENT_DIFF), KPixmapEffect::VerticalGradient ); setRect (x,y,xs,ys); setBands(magic(xs/mMultiples)); readConfig(); // read our config settings start(); }