QString Zones::summarize(int rnum, QVector<double> &time_in_zone) const { assert(rnum < ranges.size()); ZoneRange *range = ranges[rnum]; assert(time_in_zone.size() == range->zones.size()); QString summary; if(range->cp > 0){ summary += "<table align=\"center\" width=\"70%\" border=\"0\">"; summary += "<tr><td align=\"center\">"; summary += tr("Critical Power: %1").arg(range->cp); summary += "</td></tr></table>"; } summary += "<table align=\"center\" width=\"70%\" "; summary += "border=\"0\">"; summary += "<tr>"; summary += "<td align=\"center\">Zone</td>"; summary += "<td align=\"center\">Description</td>"; summary += "<td align=\"center\">Low</td>"; summary += "<td align=\"center\">High</td>"; summary += "<td align=\"center\">Time</td>"; summary += "</tr>"; QColor color = QApplication::palette().alternateBase().color(); color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value()); for (int zone = 0; zone < time_in_zone.size(); ++zone) { if (time_in_zone[zone] > 0.0) { QString name, desc; int lo, hi; zoneInfo(rnum, zone, name, desc, lo, hi); if (zone % 2 == 0) summary += "<tr bgcolor='" + color.name() + "'>"; else summary += "<tr>"; summary += QString("<td align=\"center\">%1</td>").arg(name); summary += QString("<td align=\"center\">%1</td>").arg(desc); summary += QString("<td align=\"center\">%1</td>").arg(lo); if (hi == INT_MAX) summary += "<td align=\"center\">MAX</td>"; else summary += QString("<td align=\"center\">%1</td>").arg(hi); summary += QString("<td align=\"center\">%1</td>") .arg(time_to_string((unsigned) round(time_in_zone[zone]))); summary += "</tr>"; } } summary += "</table>"; return summary; }
ColorLabel::ColorLabel(QWidget *parent, const QColor &c, int id, const QString &text) : QLabel(parent) , m_id(id) { setText(text); QPalette palette; palette.setColor(backgroundRole(), c); palette.setColor(QPalette::WindowText, !c.value()); setPalette(palette); setAutoFillBackground(true); setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); setFrameShape(StyledPanel); setFrameShadow(Sunken); setLineWidth(2); }
QColor TimelineColorScheme::frameColor(bool present, bool active) const { QColor color = Qt::transparent; if (present && !active) { color = m_d->baseColor; } else if (present && active) { QColor bgColor = qApp->palette().color(QPalette::Base); int darkenCoeff = bgColor.value() > 128 ? 130 : 80; color = m_d->baseColor.darker(darkenCoeff); } else if (!present && active) { QColor bgColor = qApp->palette().color(QPalette::Base); return blendColors(m_d->baseColor, bgColor, 0.2); } return color; }
QPixmap BrushStyle::getSample(qreal scale, qreal alpha, bool selected, const QColor &color, bool emptyBackground) { QPixmap backgroundPixmap( (selected) ? BRUSH_SAMPLE_SELECTED_BG : BRUSH_SAMPLE_BACKGROUND); if (emptyBackground) backgroundPixmap.fill(Qt::transparent); // Scale the sample QSizeF pointSize(BRUSH_SAMPLE_SIDE, BRUSH_SAMPLE_SIDE); if (scale != 1.0) { pointSize.setWidth(pointSize.width() * scale); pointSize.setHeight(pointSize.height() * scale); } // Apply color and alpha QColor alphaColor(Qt::black); if (color.isValid()) alphaColor = color; if (alpha != 1.0) alphaColor.setAlphaF(alpha); // Draw sample in the middle of background QPainter painter(&backgroundPixmap); painter.setRenderHint(QPainter::Antialiasing); QRectF pointRect(QPointF(0, 0), pointSize); pointRect.moveTo(backgroundPixmap.width() / 2 - pointSize.width() / 2, backgroundPixmap.height() / 2 - pointSize.height() / 2); if (color.isValid() && color.value() > 210 && color.saturation() < 50) painter.setPen("#d0d0d0"); else painter.setPen(Qt::NoPen); painter.setBrush(alphaColor); painter.drawEllipse(pointRect); painter.end(); return backgroundPixmap; }
void EmbeddedWebView::addCustomStylesheet(const QString &css) { m_customCss = css; QWebSettings *s = settings(); QString bgName, fgName; QColor bg = palette().color(QPalette::Active, QPalette::Base), fg = palette().color(QPalette::Active, QPalette::Text); switch (m_colorScheme) { case ColorScheme::BlackOnWhite: bgName = QStringLiteral("white !important"); fgName = QStringLiteral("black !important"); break; case ColorScheme::AdjustedSystem: { // This is HTML, and the authors of that markup are free to specify only the background colors, or only the foreground colors. // No matter what we pass from outside, there will always be some color which will result in unreadable text, and we can do // nothing except adding !important everywhere to fix this. // This code attempts to create a color which will try to produce exactly ugly results for both dark-on-bright and // bright-on-dark segments of text. However, it's pure alchemy and only a limited heuristics. If you do not like this, please // submit patches (or talk to the HTML producers, hehehe). const int v = bg.value(); if (v < 96 && fg.value() > 128 + v/2) { int h,s,vv,a; fg.getHsv(&h, &s, &vv, &a) ; fg.setHsv(h, s, 128+v/2, a); } bgName = bg.name(); fgName = fg.name(); break; } case ColorScheme::System: bgName = bg.name(); fgName = fg.name(); break; } const QString urlPrefix(QStringLiteral("data:text/css;charset=utf-8;base64,")); const QString myColors(QStringLiteral("body { background-color: %1; color: %2; }\n").arg(bgName, fgName)); s->setUserStyleSheetUrl(QString::fromUtf8(urlPrefix.toUtf8() + (myColors + m_customCss).toUtf8().toBase64())); }
void KTColorPalette::setColor(const QBrush& brush) { QColor color = brush.color(); if(color.isValid()) { if(m_type == Gradient) { m_gradientManager->setCurrentColor(color); } if(m_displayValueColor && m_outlineAndFillColors && m_colorPicker && m_nameColor && m_luminancePicker) { m_colorPicker->setCol(color.hue(), color.saturation ()); if(m_type == Solid) { m_outlineAndFillColors->setCurrentColor(color); } m_nameColor->setText(color.name ()); m_luminancePicker->setCol(color.hue(), color.saturation(), color.value()); m_containerPalette->setColor( brush ); m_displayValueColor->setColor(color); } } else if(brush.gradient()) { QGradient gradient(*brush.gradient()); changeBrushType(tr("Gradient")); m_containerPalette->setColor(gradient); m_outlineAndFillColors->setCurrentColor(gradient); if( sender () != m_gradientManager ) { m_gradientManager->setGradient(gradient); } } emit brushChanged( m_outlineAndFillColors->foreground(),m_outlineAndFillColors->background() ); }
void ColorWheel::changeColor(const QColor &color) { if (color == m_currentColor) { return; } if (color.hue() != m_currentColor.hue()) { hueChanged(color.hue()); } if (color.saturation() != m_currentColor.saturation() || color.value() != m_currentColor.value() ) { svChanged(color); } //emit colorChanged(color); update(); }
/** * \return Highlighted color for the given color. */ RColor RColor::getHighlighted(const RColor& color, const QColor& bgColor, int minDist) { if (!color.isValid()) { return Qt::gray; } RColor ret = color; int vColor = color.value(); int vBgColor = bgColor.value(); // 0 vColor vBgColor 255 // |--------^----------------------------^------------------| // |<--d1-->|<------------d2------------>|<-------d3------->| int d1 = qMin(vColor, vBgColor); //int d2 = qAbs(vColor - vBgColor); int d3 = 255 - qMax(vColor, vBgColor); // d3 is big enough: set value to max (highlight): if (d3>=minDist) { ret.setHsv(color.hue(), color.saturation(), 255); } // d1 is big enough: set value to half (lowlight): else if (d1>=minDist) { ret.setHsv(color.hue(), color.saturation(), qMin(vColor, vBgColor)/2); } // black on white: else if (vColor<32 && vBgColor>224) { ret.setHsv(color.hue(), color.saturation(), 160); } // d2 is the only significant distance, set value to medium: else if (vColor<vBgColor) { ret.setHsv(color.hue(), color.saturation(), qMin(vColor+minDist, 255)); } else { ret.setHsv(color.hue(), color.saturation(), qMax(vColor-minDist, 0)); } return ret; }
void ColorButton::paintEvent(QPaintEvent *event) { QToolButton::paintEvent(event); if (!isEnabled()) return; QColor color = properColor(m_colorString); QPainter p(this); QRect r(0, 0, width() - 2, height() - 2); p.drawTiledPixmap(r.adjusted(1, 1, -1, -1), tilePixMap(9)); if (isEnabled()) p.setBrush(color); else p.setBrush(Qt::transparent); if (color.value() > 80) p.setPen(QColor(0x444444)); else p.setPen(QColor(0x9e9e9e)); p.drawRect(r.translated(1, 1)); if (m_showArrow) { p.setRenderHint(QPainter::Antialiasing, true); QVector<QPointF> points; if (isChecked()) { points.append(QPointF(2, 3)); points.append(QPointF(8, 3)); points.append(QPointF(5, 9)); } else { points.append(QPointF(8, 6)); points.append(QPointF(2, 9)); points.append(QPointF(2, 3)); } p.translate(0.5, 0.5); p.setBrush(QColor(0xaaaaaa)); p.setPen(QColor(0x444444)); p.drawPolygon(points); } }
void ColorWheel::mousePressEvent(QMouseEvent *event) { QPoint lastPos = event->pos(); if (mSquareRect.contains(lastPos)) { mIsInWheel = false; mIsInSquare = true; QColor color = pickColor(lastPos); saturationChanged(color.saturation()); valueChanged(color.value()); } else if (mWheelRect.contains(lastPos)) { mIsInWheel = true; mIsInSquare = false; QColor color = pickColor(lastPos); hueChanged(color.hue()); } }
void ColorWheel::setColor(const QColor &color) { if (color == m_currentColor) { return; } if (color.hue() != m_currentColor.hue()) { hueChanged(color.hue()); } if (color.saturation() != m_currentColor.saturation() || color.value() != m_currentColor.value() ) { svChanged(color); } update(); emit colorSelected(color); }
Transformation Transformation::createColor(QString color) { Transformation t; if (color.toLower() != "random") { QColor c(color); QColor hsv = c.toHsv(); t.deltaH = hsv.hue(); t.scaleAlpha = hsv.alpha()/255.0; t.scaleS = hsv.saturation()/255.0; t.scaleV = hsv.value()/255.0; t.absoluteColor = true; } else { t.deltaH = 1000; t.absoluteColor = true; } //Debug(QString("Abs Color: %1, %2, %3, %4").arg(t.deltaH).arg(t.scaleS).arg(t.scaleV).arg(t.scaleAlpha)); return t; }
void RecSkinColorPalette::getColor(const QColor &averageColor) { isDrawEllipse = true; emit sigMousePressRGB(averageColor.rgb()); hsvValue = averageColor.value(); int width = 359; int height = 255; QImage temp(QSize(width, height), QImage::Format_ARGB32); for(int w = 0; w < width; ++w) { for(int h = 0; h < height; ++h) { QRgb rgb = QColor::fromHsv(w,h,hsvValue,255).rgb(); QRgb r = qRgba(qRed(rgb), qGreen(rgb), qBlue(rgb), 255); temp.setPixel(w, h, r); } } drawImage = temp; QImage tempImage = drawImage.scaled(this->width(),this->height()); bool isTrue = false; for(int i = 0; i < tempImage.width(); ++i) { for(int j = 0; j < tempImage.height(); ++j) { if(QColor::fromRgb(tempImage.pixel(i,j)) == averageColor) { mousePoint.setX(i); mousePoint.setY(j); isTrue = true; break; } } if(isTrue) break; } update(); }
void ColorWheel::setColor(QColor color) { // this is a UI updating function, never emit any signals // and don't call any functions that will emit signals color = color.toHsv(); if (color == mCurrentColor) { return; } if (color.hue() == -1) // grayscale color, keep the current hue { color.setHsv(mCurrentColor.hue(), color.saturation(), color.value(), color.alpha()); } mCurrentColor = color; drawSquareImage(color.hue()); update(); }
//---------------------------------------------------------------------------- // Update Chart //---------------------------------------------------------------------------- void ReportPieChart::updateChart() { mModel->setRowCount( mDataList.size() ); if( mDataList.size() > 0 ) { // Sort data items switch( mSortType ) { case SORT_BY_BALANCE_DESCENDING: qSort( mDataList.begin(), mDataList.end(), pieDataSortByBalanceDescending ); break; case SORT_BY_NAME_ASCENDING: qSort( mDataList.begin(), mDataList.end(), pieDataSortByNameAscending ); break; } const int colorRange = COLOR_RANGE; int step = qMin( MAX_COLOR_STEP, (colorRange / mDataList.size()) ); QColor baseColor = BASE_COLOR.toHsv(); int h = baseColor.hue(); int s = baseColor.saturation(); int v = baseColor.value(); for (int i = 0; i < mDataList.size(); ++i) { QColor secondaryLabelColor = ( mDataList[i].mValue > 0 ) ? QColor(Qt::darkGreen) : QColor(Qt::red); QColor nextColor; int newH = (h + step*i)%colorRange; nextColor.setHsv( newH, s, v ); QString valueStr = Transaction::getAmountText( mDataList[i].mValue ); mModel->setData( mModel->index(i,(int)PieView::COLUMN_LABEL), mDataList[i].mName ); mModel->setData( mModel->index(i,(int)PieView::COLUMN_LABEL), nextColor, Qt::DecorationRole ); mModel->setData( mModel->index(i,(int)PieView::COLUMN_VALUE), qAbs(mDataList[i].mValue) ); mModel->setData( mModel->index(i,(int)PieView::COLUMN_SEC_LABEL), valueStr ); mModel->setData( mModel->index(i,(int)PieView::COLUMN_SEC_LABEL), secondaryLabelColor, Qt::DecorationRole ); } } updateViewport(); } // ReportPieChart::updateChart
QPointF ColorVolumeWidget::getColorPosition(const QColor &color) const { qreal size = (this->direction == Horizontal) ? imageRect.width() : imageRect.height(); qreal pos; if (this->mode == DarkOnly) { pos = color.valueF() * size; } else { if (color.value() < 255) { pos = (color.valueF()) * (size / 2); } else { pos = (255.0 - color.saturation()) / 255 * (size / 2) + size / 2; } } return (this->direction == Horizontal) ? QPointF(pos, 0) : QPointF(0, pos); }
void ColorWheel::mouseMoveEvent(QMouseEvent* event) { QPoint lastPos = event->pos(); if (event->buttons() == Qt::NoButton) { return; } if (mIsInSquare) { if (lastPos.x() < mSquareRect.topLeft().x()) { lastPos.setX(mSquareRect.topLeft().x()); } else if (lastPos.x() > mSquareRect.bottomRight().x()) { lastPos.setX(mSquareRect.bottomRight().x()); } if (lastPos.y() < mSquareRect.topLeft().y()) { lastPos.setY(mSquareRect.topLeft().y()); } else if (lastPos.y() > mSquareRect.bottomRight().y()) { lastPos.setY(mSquareRect.bottomRight().y()); } QColor color = pickColor(lastPos); saturationChanged(color.saturation()); valueChanged(color.value()); } else if (mWheelRect.contains(lastPos) && mIsInWheel) { QColor color = pickColor(lastPos); hueChanged(color.hue()); } }
void ColorWheel::drawPicker(const QColor &color) { QPainter painter(&m_wheelPixmap); painter.setRenderHint(QPainter::Antialiasing); QPoint squareTopLeft = m_squareRegion.boundingRect().topLeft(); painter.translate(squareTopLeft.x(), squareTopLeft.y()); QSize squareSize = m_squareRegion.boundingRect().size(); qreal S = color.saturationF() * squareSize.width(); qreal V = squareSize.height() - (color.valueF() * squareSize.height()); QPen pen; pen.setWidth(3); if (color.saturation() > 30 || color.value() < 50) { pen.setColor(Qt::white); } painter.setPen(pen); painter.drawEllipse(S - 5, V - 5, 10, 10); }
void tst_QColor::setHsv() { QColor color; for (int A = 0; A <= USHRT_MAX; ++A) { { // 0-255 int a = A >> 8; color.setHsv(0, 0, 0, a); QCOMPARE(color.alpha(), a); int h, s, v, a2; color.getHsv(&h, &s, &v, &a2); QCOMPARE(a2, a); } { // 0.0-1.0 qreal a = A / qreal(USHRT_MAX); color.setHsvF(0.0, 0.0, 0.0, a); QCOMPARE(color.alphaF(), a); qreal h, s, v, a2; color.getHsvF(&h, &s, &v, &a2); QCOMPARE(a2, a); } } for (int H = 0; H < 36000; ++H) { { // 0-255 int h = H / 100; color.setHsv(h, 0, 0, 0); QCOMPARE(color.hue(), h); int h2, s, v, a; color.getHsv(&h2, &s, &v, &a); QCOMPARE(h2, h); } { // 0.0-1.0 qreal h = H / 36000.0; color.setHsvF(h, 0.0, 0.0, 0.0); QCOMPARE(color.hueF(), h); qreal h2, s, v, a; color.getHsvF(&h2, &s, &v, &a); QCOMPARE(h2, h); } } for (int S = 0; S <= USHRT_MAX; ++S) { { // 0-255 int s = S >> 8; color.setHsv(0, s, 0, 0); QCOMPARE(color.saturation(), s); int h, s2, v, a; color.getHsv(&h, &s2, &v, &a); QCOMPARE(s2, s); } { // 0.0-1.0 qreal s = S / qreal(USHRT_MAX); color.setHsvF(0.0, s, 0.0, 0.0); QCOMPARE(color.saturationF(), s); qreal h, s2, v, a; color.getHsvF(&h, &s2, &v, &a); QCOMPARE(s2, s); } } for (int V = 0; V <= USHRT_MAX; ++V) { { // 0-255 int v = V >> 8; color.setHsv(0, 0, v, 0); QCOMPARE(color.value(), v); int h, s, v2, a; color.getHsv(&h, &s, &v2, &a); QCOMPARE(v2, v); } { // 0.0-1.0 qreal v = V / qreal(USHRT_MAX); color.setHsvF(0.0, 0.0, v, 0.0); QCOMPARE(color.valueF(), v); qreal h, s, v2, a; color.getHsvF(&h, &s, &v2, &a); QCOMPARE(v2, v); } } }
void tst_QColor::dark() { QColor gray(Qt::gray); QColor darker = gray.dark(); QVERIFY(darker.value() < gray.value()); }
void tst_QColor::light() { QColor gray(Qt::gray); QColor lighter = gray.light(); QVERIFY(lighter.value() > gray.value()); }
void NMGChartSeries::paintArea(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { int maxValuesInPartialPath = 1000; QColor hsv = baseColor.toHsv(); hsv.setHsv(hsv.hue(), (int)(hsv.saturation()*0.25), hsv.value()); if(isAveraged || isAccumulated) { painter->setBrush(hsv); paintLine(painter, option, widget); } else { // not average nor accumulated /* NOTE A specific implementation is needed in this case because Graphics View doesn't * support correctly huge amount of points (X11 crashes). The design has been based in * partial paths that are painted with brush (to paint the area), and later they are * added to the complete path (to paint the boundary line).*/ painter->setPen(Qt::NoPen); painter->setBrush(hsv); QPainterPath completedPath; double closingYpixel = ((minValues.y < 0.0 && 0.0 < maxValues.y) ? yWindowToViewport(0.0) : ((minValues.y >= 0.0) ? yWindowToViewport(minValues.y) : yWindowToViewport(maxValues.y))); QList<Vertex>::const_iterator it = vertexList.constBegin(); do { QPainterPath partialPath; QPainterPath partialPathModif; partialPath.moveTo(xWindowToViewport(it->x), -yWindowToViewport(it->y)); for(int i = 1; i <= maxValuesInPartialPath && it != vertexList.constEnd(); i++, it++) { partialPath.lineTo(xWindowToViewport(it->x),-yWindowToViewport(it->y)); } if(completedPath.isEmpty()) { partialPathModif = partialPath; partialPathModif.lineTo(partialPathModif.currentPosition().rx(), -closingYpixel); partialPathModif.lineTo(xWindowToViewport(vertexList.first().x), -closingYpixel); completedPath = partialPath; } else { partialPathModif = partialPath; partialPathModif.lineTo(partialPath.currentPosition().rx(), -closingYpixel); partialPathModif.lineTo(completedPath.currentPosition().rx(), -closingYpixel); partialPathModif.lineTo(completedPath.currentPosition().rx(), completedPath.currentPosition().ry()); completedPath.connectPath(partialPath); } partialPathModif.closeSubpath(); painter->drawPath(partialPathModif); } while(it != vertexList.constEnd()); painter->setPen(Qt::SolidLine); painter->setPen(baseColor); painter->setBrush(Qt::NoBrush); completedPath.lineTo(xWindowToViewport(vertexList.last().x), -closingYpixel); completedPath.lineTo(xWindowToViewport(vertexList.first().x), -closingYpixel); completedPath.closeSubpath(); painter->drawPath(completedPath); } }
void PaletteEditor::stopsChangedAction() { static const int GradientBufferLastIdx = GradientBufferSize - 1; static const qreal dx = 1.0 / GradientBufferSize; QSize s( m_gradientLabel->maximumSize() ); QRect r( QPoint(0, 0), QSize(s.width(), (s.height() / 2.0 ) ) ); QImage palette_image(s, QImage::Format_RGB32); QPainter painter(&palette_image); GradientStops stops(m_gradientStops->getStops()); qStableSort(stops.begin(), stops.end(), GradientStop::lessThanGradientStopComparison); // now apply the ends and update the palette GradientStops ends( m_gradientEnds->getStops() ); QGradient::Spread spread((QGradient::Spread)m_gradientSpreadGroup->checkedId()); GradientStop n_stop(stops.first()); QRgb ccolor = n_stop.second.rgba(); for (int n = 0, fpos = n_stop.first * GradientBufferSize ; n < fpos ; n++) m_gradient[qMin(n, GradientBufferLastIdx)] = ccolor; int last_stop_idx = stops.size() - 1; for (int begin_idx = 0; begin_idx < last_stop_idx ; begin_idx++) { GradientStop a = stops.at(begin_idx); GradientStop b = stops.at(begin_idx + 1); QColor ac = a.second; QColor bc = b.second; qreal d = ( b.first - a.first ); qreal rdx, gdx, bdx, adx; if (b.colorspace == 0) { rdx = ( (bc.red() - ac.red() ) / d ) * dx; gdx = ( (bc.green() - ac.green() ) / d ) * dx; bdx = ( (bc.blue() - ac.blue() ) / d ) * dx; adx = ( (bc.alpha() - ac.alpha() ) / d ) * dx; } else { rdx = ( (bc.hue() - ac.hue() ) / d ) * dx; gdx = ( (bc.saturation() - ac.saturation() ) / d ) * dx; bdx = ( (bc.value() - ac.value() ) / d ) * dx; adx = ( (bc.alpha() - ac.alpha() ) / d ) * dx; if (b.colorspace == 1) { if (rdx == 0.0) rdx = 180.0 / d * dx; else if (rdx < 0) rdx *= -1; } else { if (rdx == 0.0) rdx = -180.0 / d * dx; else if (rdx > 0) rdx *= -1; } } int n = a.first * GradientBufferSize ; int nb = (int)(b.first * GradientBufferSize ); for (int i = 0 ; n < nb ; i++, n++) { if (b.colorspace == 0) { m_gradient[n] = qRgba( qBound(0, (int)( ac.red() + rdx * i + 0.5 ), 255), qBound(0, (int)( ac.green() + gdx * i + 0.5 ), 255), qBound(0, (int)( ac.blue() + bdx * i + 0.5 ), 255), qBound(0, (int)( ac.alpha() + adx * i + 0.5 ), 255)); } else { int h = (int)( ac.hue() + rdx * i + 0.5 ); if (h < 0) h += 360; m_gradient[n] = QColor::fromHsv(h % 360, qBound(0, (int)( ac.saturation() + gdx * i + 0.5 ), 255), qBound(0, (int)( ac.value() + bdx * i + 0.5 ), 255), qBound(0, (int)( ac.alpha() + adx * i + 0.5 ), 255)).rgba(); } } } n_stop = stops.last(); ccolor = n_stop.second.rgba(); for (int n = n_stop.first * GradientBufferSize ; n < GradientBufferSize ; n++) m_gradient[n] = ccolor; qreal start(ends.at(0).first); qreal end(ends.at(1).first); int begin_idx = start * 256 ; int end_idx = end * 256 ; int ibuf_size = end_idx - begin_idx; flam3_palette_entry* ibuf = new flam3_palette_entry[ibuf_size](); // a very acute filter qreal c2 = 0.01; qreal c3 = 1.0; qreal c4 = 0.01; qreal norm = c2 + c3 + c4; qreal k = 0.0; qreal skip( (GradientBufferSize / 256.0) / qMax(qreal(1.0/GradientBufferSize), end - start) ); for (int n = 0 ; n < ibuf_size ; n++, k += skip) { int j = k; QRgb a2( m_gradient[qBound(0, j + 0, GradientBufferLastIdx)] ); QRgb a3( m_gradient[qMin(j + 1, GradientBufferLastIdx)] ); QRgb a4( m_gradient[qMin(j + 2, GradientBufferLastIdx)] ); ibuf[n].color[0] = (qRed(a2)*c2 + qRed(a3)*c3 + qRed(a4)*c4 ) / (norm * 255.); ibuf[n].color[1] = (qGreen(a2)*c2 + qGreen(a3)*c3 + qGreen(a4)*c4 ) / (norm * 255.); ibuf[n].color[2] = (qBlue(a2)*c2 + qBlue(a3)*c3 + qBlue(a4)*c4 ) / (norm * 255.); ibuf[n].color[3] = (qAlpha(a2)*c2 + qAlpha(a3)*c3 + qAlpha(a4)*c4 ) / (norm * 255.); } // update the gradient editor label painter.fillRect(QRect(QPoint(0,0), s), checkers); if (ibuf_size == 256) { for (int n = 0, h = s.height() ; n < 256 ; n++) { painter.setPen(QColor::fromRgbF(ibuf[n].color[0], ibuf[n].color[1], ibuf[n].color[2], ibuf[n].color[3])); painter.drawLine(n, 0, n, h); } } else { for (int n = 0, h = s.height(), j = 0 ; n < 256 ; n++, j += 4) { QRgb a2( m_gradient[qBound(0, j + 0, GradientBufferLastIdx)] ); QRgb a3( m_gradient[qMin(j + 1, GradientBufferLastIdx)] ); QRgb a4( m_gradient[qMin(j + 2, GradientBufferLastIdx)] ); QRgb r((qRed(a2)*c2 + qRed(a3)*c3 + qRed(a4)*c4 ) / norm ); QRgb g((qGreen(a2)*c2 + qGreen(a3)*c3 + qGreen(a4)*c4 ) / norm ); QRgb b((qBlue(a2)*c2 + qBlue(a3)*c3 + qBlue(a4)*c4 ) / norm ); QRgb a((qAlpha(a2)*c2 + qAlpha(a3)*c3 + qAlpha(a4)*c4 ) / norm ); QColor c(r, g, b, a); painter.setPen(c); painter.drawLine(n, 0, n, h); } } m_gradientLabel->setPixmap(QPixmap::fromImage(palette_image)); // Rescale the gradient colors into the palette with a simple filter if (spread == QGradient::PadSpread) { QRgb fc(m_gradient[0]); flam3_palette_entry e = { 0., { qRed(fc)/255., qGreen(fc)/255., qBlue(fc)/255., qAlpha(fc)/255. }}; for (int n = 0 ; n < begin_idx ; n++) p[n] = e; for (int n = begin_idx, j = 0 ; n < end_idx ; n++, j++) p[n] = ibuf[j]; fc = m_gradient[GradientBufferLastIdx]; e = (flam3_palette_entry){ 1., { qRed(fc)/255., qGreen(fc)/ 255., qBlue(fc)/255., qAlpha(fc)/255. }}; for (int n = end_idx ; n < 256 ; n++) p[n] = e; } else if (spread == QGradient::RepeatSpread) { for (int n = begin_idx, j = 0 ; n < 256 ; n++, j++) p[n] = ibuf[j % ibuf_size]; for (int n = begin_idx - 1, j = ibuf_size * 4096 - 1 ; n >= 0 ; n--, j--) p[n] = ibuf[j % ibuf_size]; } else if (spread == QGradient::ReflectSpread) { for (int n = begin_idx, j = 0, h = 4096*ibuf_size -1 ; n < begin_idx + ibuf_size ; n++, j++, h--) { for (int k = n, q = n + ibuf_size ; k < 256 ; k += 2*ibuf_size, q += 2*ibuf_size ) { p[k] = ibuf[j % ibuf_size]; if (q < 256) p[q] = ibuf[h % ibuf_size]; } } for (int n = begin_idx - 1, j = ibuf_size * 4096 - 1, h = 0 ; n >= begin_idx - ibuf_size ; n--, j--, h++) { for (int k = n, q = n - ibuf_size ; k >= 0 ; k -= 2*ibuf_size, q -= 2*ibuf_size ) { p[k] = ibuf[h % ibuf_size]; if (q >= 0) p[q] = ibuf[j % ibuf_size]; } } } delete[] ibuf; setPaletteView(); emit paletteChanged(); }
NV_INT32 ComputeLineDistanceFilter (NV_F64_COORD2 lineStart, NV_F64_COORD2 lineEnd, nvMap *map, MISC *misc, OPTIONS *options) { NV_INT32 numPointsWithin = 0; NV_FLOAT64 utmE, utmN; NV_BOOL hitMax = NVFalse; QColor color; QColor GetAVShotColor (NV_INT32 index, MISC *misc, OPTIONS *options); for (NV_INT32 i = 0; i < misc->abe_share->point_cloud_count; i++) { // Only send over what's viewable on the screen if ((!check_bounds (map, options, misc, i, NVTrue, NVFalse)) && misc->data[i].type == PFM_CZMIL_DATA) { NV_FLOAT64 x = misc->data[i].x * NV_DEG_TO_RAD; NV_FLOAT64 y = misc->data[i].y * NV_DEG_TO_RAD; pj_transform (misc->pj_latlon, misc->pj_utm, 1, 1, &x, &y, NULL); utmE = x; utmN = y; Vertex ptOfInterest (utmE, utmN, 0.0f); Vertex closestPt = Vector::ClosestPtOnLine (Vertex (lineStart.x, lineStart.y, 0.0f), Vertex (lineEnd.x, lineEnd.y, 0.0f), ptOfInterest); // compare against our class variable not a constant if (Vector::GetDistance (ptOfInterest, closestPt) < options->distThresh) { // load up the shots array for AV misc->avb.shotArray[numPointsWithin].recordNumber = misc->data[i].rec; misc->avb.shotArray[numPointsWithin].subRecordNumber = misc->data[i].sub; misc->avb.shotArray[numPointsWithin].pfmHandle = misc->pfm_handle[misc->data[i].pfm]; misc->avb.shotArray[numPointsWithin].fileNo = misc->data[i].file; misc->avb.shotArray[numPointsWithin].masterIdx = i; misc->avb.shotArray[numPointsWithin].type = misc->data[i].type; color = GetAVShotColor (i, misc, options); misc->avb.shotArray[numPointsWithin].colorH = color.hue (); misc->avb.shotArray[numPointsWithin].colorS = color.saturation(); misc->avb.shotArray[numPointsWithin].colorV = color.value(); numPointsWithin++; if (numPointsWithin == MAX_ATTRIBUTE_SHOTS) { hitMax = NVTrue; // If we hit the maximum, send a message out for the user to re-select. QString msg = QString (pfmEdit::tr ("The line specified results in more shots satisfying the threshold than can be held (MAX = %1).\n").arg (MAX_ATTRIBUTE_SHOTS) + pfmEdit::tr ("Please draw a shorter line or change the distance threshold parameter")); QMessageBox::warning (0, pfmEdit::tr ("pfmEdit"), msg); break; } } } } // lock shared memory and load up shots and notify AV new data is coming misc->abeShare->lock (); if (numPointsWithin > 0) { misc->av_dist_count = numPointsWithin; misc->av_dist_list = (NV_INT32 *) realloc (misc->av_dist_list, (misc->av_dist_count + 1) * sizeof (NV_INT32)); if (misc->av_dist_list == NULL) { perror ("Allocating misc->av_dist_list memory in pfmEdit"); exit (-1); } for (NV_INT32 i = 0; i < numPointsWithin; i++) { misc->abe_share->avShare.shots[i] = misc->avb.shotArray[i]; misc->av_dist_list[i] = misc->avb.shotArray[i].masterIdx; } } misc->abe_share->avShare.numShots = numPointsWithin; misc->abe_share->avShare.avNewData = NVTrue; misc->abe_share->avShare.hitMax = hitMax; misc->abeShare->unlock (); return (numPointsWithin); }
void QgsColorWheel::setColorFromPos( const QPointF pos ) { QPointF center = QPointF( width() / 2.0, height() / 2.0 ); //line from center to mouse position QLineF line = QLineF( center.x(), center.y(), pos.x(), pos.y() ); QColor newColor = QColor(); int h, s, l, alpha; mCurrentColor.getHsl( &h, &s, &l, &alpha ); //override hue with explicit hue, so we don't get -1 values from QColor for hue h = hue(); if ( mClickedPart == QgsColorWheel::Triangle ) { //adapted from equations at https://github.com/timjb/colortriangle/blob/master/colortriangle.js by Tim Baumann //position of event relative to triangle center double x = pos.x() - center.x(); double y = pos.y() - center.y(); double eventAngleRadians = line.angle() * M_PI / 180.0; double hueRadians = h * M_PI / 180.0; double rad0 = fmod( eventAngleRadians + 2.0 * M_PI - hueRadians, 2.0 * M_PI ); double rad1 = fmod( rad0, (( 2.0 / 3.0 ) * M_PI ) ) - ( M_PI / 3.0 ); double length = mWheelImage->width() / 2.0; double triangleLength = length - mWheelThickness - 1; double a = 0.5 * triangleLength; double b = tan( rad1 ) * a; double r = sqrt( x * x + y * y ); double maxR = sqrt( a * a + b * b ); if ( r > maxR ) { double dx = tan( rad1 ) * r; double rad2 = atan( dx / maxR ); rad2 = qMin( rad2, M_PI / 3.0 ); rad2 = qMax( rad2, -M_PI / 3.0 ); eventAngleRadians += rad2 - rad1; rad0 = fmod( eventAngleRadians + 2.0 * M_PI - hueRadians, 2.0 * M_PI ); rad1 = fmod( rad0, (( 2.0 / 3.0 ) * M_PI ) ) - ( M_PI / 3.0 ); b = tan( rad1 ) * a; r = sqrt( a * a + b * b ); } double triangleSideLength = sqrt( 3.0 ) * triangleLength; double newL = (( -sin( rad0 ) * r ) / triangleSideLength ) + 0.5; double widthShare = 1.0 - ( fabs( newL - 0.5 ) * 2.0 ); double newS = ((( cos( rad0 ) * r ) + ( triangleLength / 2.0 ) ) / ( 1.5 * triangleLength ) ) / widthShare; s = qMin( qRound( qMax( 0.0, newS ) * 255.0 ), 255 ); l = qMin( qRound( qMax( 0.0, newL ) * 255.0 ), 255 ); newColor = QColor::fromHsl( h, s, l ); //explicitly set the hue again, so that it's exact newColor.setHsv( h, newColor.hsvSaturation(), newColor.value(), alpha ); } else if ( mClickedPart == QgsColorWheel::Wheel ) { //use hue angle s = mCurrentColor.hsvSaturation(); int v = mCurrentColor.value(); int newHue = line.angle(); newColor = QColor::fromHsv( newHue, s, v, alpha ); //hue has changed, need to redraw triangle mTriangleDirty = true; } if ( newColor.isValid() && newColor != mCurrentColor ) { //color has changed mCurrentColor = QColor( newColor ); if ( mCurrentColor.hue() >= 0 ) { //color has a valid hue, so update the QgsColorWidget's explicit hue mExplicitHue = mCurrentColor.hue(); } update(); emit colorChanged( mCurrentColor ); } }
void QgsColorRampWidget::paintEvent( QPaintEvent *event ) { Q_UNUSED( event ); QPainter painter( this ); if ( mShowFrame ) { //draw frame QStyleOptionFrameV3 option; option.initFrom( this ); option.state = hasFocus() ? QStyle::State_KeyboardFocusChange : QStyle::State_None; style()->drawPrimitive( QStyle::PE_Frame, &option, &painter ); } if ( hasFocus() ) { //draw focus rect QStyleOptionFocusRect option; option.initFrom( this ); option.state = QStyle::State_KeyboardFocusChange; style()->drawPrimitive( QStyle::PE_FrameFocusRect, &option, &painter ); } if ( mComponent != QgsColorWidget::Alpha ) { int maxValue = ( mOrientation == QgsColorRampWidget::Horizontal ? width() : height() ) - 1 - 2 * mMargin; QColor color = QColor( mCurrentColor ); color.setAlpha( 255 ); QPen pen; pen.setWidth( 0 ); painter.setPen( pen ); painter.setBrush( Qt::NoBrush ); //draw background ramp for ( int c = 0; c <= maxValue; ++c ) { int colorVal = componentRange() * ( double )c / maxValue; //vertical sliders are reversed if ( mOrientation == QgsColorRampWidget::Vertical ) { colorVal = componentRange() - colorVal; } alterColor( color, mComponent, colorVal ); if ( color.hue() < 0 ) { color.setHsv( hue(), color.saturation(), color.value() ); } pen.setColor( color ); painter.setPen( pen ); if ( mOrientation == QgsColorRampWidget::Horizontal ) { //horizontal painter.drawLine( c + mMargin, mMargin, c + mMargin, height() - mMargin - 1 ); } else { //vertical painter.drawLine( mMargin, c + mMargin, width() - mMargin - 1, c + mMargin ); } } } else if ( mComponent == QgsColorWidget::Alpha ) { //alpha ramps are drawn differently //start with the checkboard pattern QBrush checkBrush = QBrush( transparentBackground() ); painter.setBrush( checkBrush ); painter.setPen( Qt::NoPen ); painter.drawRect( mMargin, mMargin, width() - 2 * mMargin - 1, height() - 2 * mMargin - 1 ); QLinearGradient colorGrad; if ( mOrientation == QgsColorRampWidget::Horizontal ) { //horizontal colorGrad = QLinearGradient( mMargin, 0, width() - mMargin - 1, 0 ); } else { //vertical colorGrad = QLinearGradient( 0, mMargin, 0, height() - mMargin - 1 ); } QColor transparent = QColor( mCurrentColor ); transparent.setAlpha( 0 ); colorGrad.setColorAt( 0, transparent ); QColor opaque = QColor( mCurrentColor ); opaque.setAlpha( 255 ); colorGrad.setColorAt( 1, opaque ); QBrush colorBrush = QBrush( colorGrad ); painter.setBrush( colorBrush ); painter.drawRect( mMargin, mMargin, width() - 2 * mMargin - 1, height() - 2 * mMargin - 1 ); } if ( mOrientation == QgsColorRampWidget::Horizontal ) { //draw marker triangles for horizontal ramps painter.setRenderHint( QPainter::Antialiasing ); painter.setBrush( QBrush( Qt::black ) ); painter.setPen( Qt::NoPen ); painter.translate( mMargin + ( width() - 2 * mMargin ) * ( double )componentValue() / componentRange(), mMargin - 1 ); painter.drawPolygon( mTopTriangle ); painter.translate( 0, height() - mMargin - 2 ); painter.setBrush( QBrush( Qt::white ) ); painter.drawPolygon( mBottomTriangle ); painter.end(); } else { //draw cross lines for vertical ramps int ypos = mMargin + ( height() - 2 * mMargin - 1 ) - ( height() - 2 * mMargin - 1 ) * ( double )componentValue() / componentRange(); painter.setBrush( Qt::white ); painter.setPen( Qt::NoPen ); painter.drawRect( mMargin, ypos - 1, width() - 2 * mMargin - 1, 3 ); painter.setPen( Qt::black ); painter.drawLine( mMargin, ypos, width() - mMargin - 1, ypos ); } }
bool Tools::tooDark(const QColor &color) { return color.value() < 175; }
static inline QColor invertColor(const QColor color) { QColor c = color.toHsv(); c.setHsv(c.hue(), c.saturation(), 255 - c.value()); return c; }
void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (!panelWidget(widget)) return QProxyStyle::drawPrimitive(element, option, painter, widget); bool animating = (option->state & State_Animating); int state = option->state; QRect rect = option->rect; QRect oldRect; QRect newRect; if (widget && (element == PE_PanelButtonTool) && !animating) { QWidget *w = const_cast<QWidget *> (widget); int oldState = w->property("_q_stylestate").toInt(); oldRect = w->property("_q_stylerect").toRect(); newRect = w->rect(); w->setProperty("_q_stylestate", (int)option->state); w->setProperty("_q_stylerect", w->rect()); // Determine the animated transition bool doTransition = ((state & State_On) != (oldState & State_On) || (state & State_MouseOver) != (oldState & State_MouseOver)); if (oldRect != newRect) { doTransition = false; d->animator.stopAnimation(widget); } if (doTransition) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); Animation *anim = d->animator.widgetAnimation(widget); QStyleOption opt = *option; opt.state = (QStyle::State)oldState; opt.state |= State_Animating; startImage.fill(0); Transition *t = new Transition; t->setWidget(w); QPainter startPainter(&startImage); if (!anim) { drawPrimitive(element, &opt, &startPainter, widget); } else { anim->paint(&startPainter, &opt); d->animator.stopAnimation(widget); } QStyleOption endOpt = *option; endOpt.state |= State_Animating; t->setStartImage(startImage); d->animator.startAnimation(t); endImage.fill(0); QPainter endPainter(&endImage); drawPrimitive(element, &endOpt, &endPainter, widget); t->setEndImage(endImage); if (oldState & State_MouseOver) t->setDuration(150); else t->setDuration(75); t->setStartTime(QTime::currentTime()); } } switch (element) { case PE_IndicatorDockWidgetResizeHandle: painter->fillRect(option->rect, creatorTheme()->color(Theme::DockWidgetResizeHandleColor)); break; case PE_FrameDockWidget: QCommonStyle::drawPrimitive(element, option, painter, widget); break; case PE_PanelLineEdit: { painter->save(); // Fill the line edit background QRect filledRect = option->rect.adjusted(1, 1, -1, -1); painter->setBrushOrigin(filledRect.topLeft()); painter->fillRect(filledRect, option->palette.base()); if (option->state & State_Enabled) StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5); else StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5); if (option->state & State_HasFocus || option->state & State_MouseOver) { QColor hover = StyleHelper::baseColor(); if (state & State_HasFocus) hover.setAlpha(100); else hover.setAlpha(50); painter->setPen(QPen(hover, 1)); painter->drawRect(QRectF(option->rect).adjusted(1.5, 1.5, -1.5, -1.5)); } painter->restore(); } break; case PE_FrameStatusBarItem: break; case PE_PanelButtonTool: { Animation *anim = d->animator.widgetAnimation(widget); if (!animating && anim) { anim->paint(painter, option); } else { bool pressed = option->state & State_Sunken || option->state & State_On; QColor shadow(0, 0, 0, 30); painter->setPen(shadow); if (pressed) { QColor shade = option->palette.base().color(); shade.setHsv(shade.hue(), shade.saturation(), 255 - shade.value(), 40); painter->fillRect(rect, shade); const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5); painter->drawLine(borderRect.topLeft() + QPointF(1, 0), borderRect.topRight() - QPointF(1, 0)); painter->drawLine(borderRect.topLeft(), borderRect.bottomLeft()); painter->drawLine(borderRect.topRight(), borderRect.bottomRight()); } else if (option->state & State_Enabled && option->state & State_MouseOver) { painter->fillRect(rect, creatorTheme()->color(Theme::PanelButtonToolBackgroundColorHover)); } else if (widget && widget->property("highlightWidget").toBool()) { QColor shade(0, 0, 0, 128); painter->fillRect(rect, shade); } if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) { QColor highlight = option->palette.highlight().color(); highlight.setAlphaF(0.4); painter->setPen(QPen(highlight.lighter(), 1)); highlight.setAlphaF(0.3); painter->setBrush(highlight); painter->setRenderHint(QPainter::Antialiasing); const QRectF rect = option->rect; painter->drawRoundedRect(rect.adjusted(2.5, 2.5, -2.5, -2.5), 2, 2); } } } break; case PE_PanelStatusBar: { if (creatorTheme()->widgetStyle() == Theme::StyleDefault) { painter->save(); QLinearGradient grad = StyleHelper::statusBarGradient(rect); painter->fillRect(rect, grad); const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5); painter->setPen(QColor(255, 255, 255, 60)); painter->drawLine(borderRect.topLeft() + QPointF(0, 1), borderRect.topRight()+ QPointF(0, 1)); painter->setPen(StyleHelper::borderColor().darker(110)); //TODO: make themable painter->drawLine(borderRect.topLeft(), borderRect.topRight()); painter->restore(); } else { painter->fillRect(rect, creatorTheme()->color(Theme::PanelStatusBarBackgroundColor)); } } break; case PE_IndicatorToolBarSeparator: { QColor separatorColor = StyleHelper::borderColor(); separatorColor.setAlpha(100); painter->setPen(separatorColor); const int margin = 6; if (option->state & State_Horizontal) { const int offset = rect.width()/2; painter->drawLine(rect.bottomLeft().x() + offset, rect.bottomLeft().y() - margin, rect.topLeft().x() + offset, rect.topLeft().y() + margin); } else { //Draw vertical separator const int offset = rect.height()/2; painter->setPen(QPen(option->palette.background().color().darker(110))); painter->drawLine(rect.topLeft().x() + margin , rect.topLeft().y() + offset, rect.topRight().x() - margin, rect.topRight().y() + offset); } } break; case PE_IndicatorToolBarHandle: { bool horizontal = option->state & State_Horizontal; painter->save(); QPainterPath path; int x = option->rect.x() + (horizontal ? 2 : 6); int y = option->rect.y() + (horizontal ? 6 : 2); static const int RectHeight = 2; if (horizontal) { while (y < option->rect.height() - RectHeight - 6) { path.moveTo(x, y); path.addRect(x, y, RectHeight, RectHeight); y += 6; } } else { while (x < option->rect.width() - RectHeight - 6) { path.moveTo(x, y); path.addRect(x, y, RectHeight, RectHeight); x += 6; } } painter->setPen(Qt::NoPen); QColor dark = StyleHelper::borderColor(); dark.setAlphaF(0.4); QColor light = StyleHelper::baseColor(); light.setAlphaF(0.4); painter->fillPath(path, light); painter->save(); painter->translate(1, 1); painter->fillPath(path, dark); painter->restore(); painter->translate(3, 3); painter->fillPath(path, light); painter->translate(1, 1); painter->fillPath(path, dark); painter->restore(); } break; case PE_IndicatorArrowUp: case PE_IndicatorArrowDown: case PE_IndicatorArrowRight: case PE_IndicatorArrowLeft: { StyleHelper::drawArrow(element, painter, option); } break; default: QProxyStyle::drawPrimitive(element, option, painter, widget); break; } }
void LoadShotsWithinAVBox (MISC *misc, OPTIONS *options, nvMap *map, NV_I32_COORD2 targetPt) { NV_FLOAT64 dz; NV_INT32 xyz_x, xyz_y, xyz_z, lock_point; NV_I32_COORD2 llSquare, urSquare; int numShots = 0; NV_BOOL hitMax = NVFalse; QColor color; QColor GetAVShotColor (NV_INT32 index, MISC *misc, OPTIONS *options); if (misc->nearest_point != -1) { llSquare.x = targetPt.x - misc->avb.avInterfacePixelBuffer; llSquare.y = targetPt.y + misc->avb.avInterfacePixelBuffer; urSquare.x = targetPt.x + misc->avb.avInterfacePixelBuffer; urSquare.y = targetPt.y - misc->avb.avInterfacePixelBuffer; // load the target pt first lock_point = misc->nearest_point; // Get the screen coordinates of the primary cursor. Make sure it is within the AV ROI box. // It is possible that it could be outside in the event that everything within the AV box is deleted by the AV map->map_to_screen (1, &misc->data[lock_point].x, &misc->data[lock_point].y, &dz, &xyz_x, &xyz_y, &xyz_z); if ((xyz_x <= urSquare.x) && (xyz_x >= llSquare.x) && (xyz_y >= urSquare.y) && (xyz_y <= llSquare.y) && misc->data[lock_point].type == PFM_CZMIL_DATA) { misc->avb.shotArray[numShots].recordNumber = misc->data[lock_point].rec; misc->avb.shotArray[numShots].pfmHandle = misc->pfm_handle[misc->data[lock_point].pfm]; misc->avb.shotArray[numShots].fileNo = misc->data[lock_point].file; misc->avb.shotArray[numShots].type = misc->data[lock_point].type; // Save the master idx misc->avb.shotArray[numShots].masterIdx = lock_point; color = GetAVShotColor (lock_point, misc, options); misc->avb.shotArray[numShots].colorH = color.hue (); misc->avb.shotArray[numShots].colorS = color.saturation(); misc->avb.shotArray[numShots].colorV = color.value(); numShots++; } for (NV_INT32 i = 0 ; i < misc->abe_share->point_cloud_count ; i++) { if (i != lock_point) { // Check for single line display. if (!misc->num_lines || check_line (misc, misc->data[i].line)) { // Do not use null points. Do not use invalid points unless the // display_invalid flag is set. Do not check points that are not on the // display. if (!check_bounds (map, options, misc, i, NVTrue, NVFalse)) { map->map_to_screen (1, &misc->data[i].x, &misc->data[i].y, &dz, &xyz_x, &xyz_y, &xyz_z); // Check the area and the data type ('cause there might be mixed types in the editor). if ((xyz_x <= urSquare.x) && (xyz_x >= llSquare.x) && (xyz_y >= urSquare.y) && (xyz_y <= llSquare.y) && misc->data[i].type == PFM_CZMIL_DATA) { if (numShots == MAX_ATTRIBUTE_SHOTS) { hitMax = NVTrue; break; } misc->avb.shotArray[numShots].recordNumber = misc->data[i].rec; misc->avb.shotArray[numShots].subRecordNumber = misc->data[i].sub; misc->avb.shotArray[numShots].pfmHandle = misc->pfm_handle[misc->data[i].pfm]; misc->avb.shotArray[numShots].fileNo = misc->data[i].file; misc->avb.shotArray[numShots].masterIdx = i; misc->avb.shotArray[numShots].type = misc->data[i].type; color = GetAVShotColor (i, misc, options); misc->avb.shotArray[numShots].colorH = color.hue (); misc->avb.shotArray[numShots].colorS = color.saturation(); misc->avb.shotArray[numShots].colorV = color.value(); numShots++; } } } } } } misc->abeShare->lock (); for (int i = 0; i < numShots; i++) misc->abe_share->avShare.shots[i] = misc->avb.shotArray[i]; misc->abe_share->avShare.numShots = numShots; misc->abe_share->avShare.avNewData = NVTrue; misc->abe_share->avShare.hitMax = hitMax; misc->abeShare->unlock (); }