コード例 #1
0
ファイル: stylehelper.cpp プロジェクト: innoink/SiftFaceRec
QColor StyleHelper::borderColor(bool lightColored)
{
    QColor result = baseColor(lightColored);
    result.setHsv(result.hue(),
                  result.saturation(),
                  result.value() / 2);
    return result;
}
コード例 #2
0
 QColor buttonColor(const QPalette& pal) const
 {
     QColor buttonColor = pal.button().color();
     const int val = qGray(buttonColor.rgb());
     buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
     buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
     return buttonColor;
 }
コード例 #3
0
ファイル: stylehelper.cpp プロジェクト: martamius/mushi
QColor StyleHelper::shadowColor()
{
    QColor result = baseColor();
    result.setHsv(result.hue(),
                  clamp(result.saturation() * 1.1),
                  clamp(result.value() * 0.70));
    return result;
}
コード例 #4
0
ファイル: colorpicker.cpp プロジェクト: timsee/Corluma
void ColorPicker::handleMouseEvent(QMouseEvent *event) {
    QRect geometry = mColorWheel->geometry();
    if (eventIsOverWheel(event)) {
        QPixmap pixmap = QWidget::grab(mColorWheel->geometry());
        // some mobile and other environments save pixmaps without pixel density taken into account. For example, breaks on iPhone 6 without this.
        if (pixmap.size() != mColorWheel->geometry().size()) {
            pixmap = pixmap.scaled(mColorWheel->geometry().size().width(),
                                   mColorWheel->geometry().size().height());
        }
        QColor color = pixmap.toImage().pixel(event->pos().x() - geometry.x(),
                                              event->pos().y() - geometry.y());
        if (checkIfColorIsValid(color)){
            if (mCurrentLayoutColorPicker == ELayoutColorPicker::multiColorLayout) {
                if (mWheelIsEnabled) {
                    mCustomColorPicker->updateSelected(color);
                    emit multiColorUpdate();
                }
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::ambientLayout) {
                // use the poorly named "value" of the HSV range to calculate the brightness
                auto brightness = uint32_t(color.valueF() * 100.0);
                // adjust the color so that it has a maxed out value in the HSV colorspace
                color.setHsv(color.hue(),
                             color.saturation(),
                             255);
                // then calculate then use the resulting QColor to convert to color temperature.
                int ct = cor::rgbToColorTemperature(color);
                chooseAmbient(ct, brightness, true);
                mTempBrightSliders->changeTemperatureAndBrightness(ct, brightness);
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::brightnessLayout) {
                // use the poorly named "value" of the HSV range to calculate the brightness
                auto brightness = uint32_t(color.valueF() * 100.0);
                chooseBrightness(brightness);
                mBrightnessSlider->changeBrightness(brightness);
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::standardLayout) {
                chooseColor(color);
                mRGBSliders->changeColor(color);
            } else if (mCurrentLayoutColorPicker == ELayoutColorPicker::colorSchemeLayout) {
                if (mCircleIndex == -1) {
                    mColorSchemeCircles->moveCenterCircle(event->pos(), true);
                    mCircleIndex = 10;
                } else if (mCircleIndex == 10) {
                    mColorSchemeCircles->moveCenterCircle(event->pos(), false);
                } else {
                    mColorSchemeCircles->moveStandardCircle(uint32_t(mCircleIndex), event->pos());
                }

                // turn into vector of colors
                std::vector<QColor> colors;
                for (const auto& circle : mColorSchemeCircles->circles()) {
                    colors.push_back(circle.color);
                }
                emit colorsUpdate(colors);

               // mColorSchemeGrid->setColor(2, color);
            }
        }
    }
}
コード例 #5
0
ファイル: edge.cpp プロジェクト: dstoeckel/causaltrail
void Edge::removeHighlighting(){
    QColor temp;
    temp.setHsv(210,220,250);
    if (edgeColor_==temp){
        fixedColor_=false;
        edgeColor_=Qt::black;
        update();
    }
}
コード例 #6
0
ファイル: ClsBaseQStateArrayView.cpp プロジェクト: jeez/iqr
QPixmap ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight, int _iColorMode ) {
#ifdef DEBUG_CLSBASEQSTATEARRAYVIEW
    cout << "ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight)" << endl;
#endif

//    int iColorMode = ClsBaseQStateArrayView::GRAY;
//    int iColorMode = ClsBaseQStateArrayView::BLUE2RED;
//    int iColorMode = ClsBaseQStateArrayView::HSV;

    QPixmap pmGradient;
    QPainter* paintGradient = new QPainter();
    QWMatrix mxRot;
    int iDiag = (int)(sqrt(double(iImgWidth * iImgWidth + iImgHeight * iImgHeight))/2.);

    pmGradient.resize(2 * iDiag, 2 * iDiag);
    paintGradient->begin(&pmGradient);

    paintGradient->setWindow( 0, 0, 2 * iDiag, 2 * iDiag );

    int iNrSices = 50;
    for ( int i=0; i<iNrSices; i++ ) {
	paintGradient->setWorldMatrix( mxRot );
	QColor c;
	if(_iColorMode == ClsBaseQStateArrayView::GRAY){
	    c.setRgb( i* 255 / iNrSices,  i* 255 / iNrSices,  i* 255 / iNrSices );
	}
	else if(_iColorMode == ClsBaseQStateArrayView::BLUE2RED){
	    if(i<iNrSices/2){
		/* BLUE */
		c.setRgb(0, 0,  255 - i * 510/iNrSices);
	    }
	    else {
		/* RED */
		c.setRgb( (i - iNrSices/2) * 255/(iNrSices/2),  0,0);
	    }
	}
	else {
	    c.setHsv( i* 360 / iNrSices, 255, 255 );
	}
	paintGradient->setBrush( c );
	paintGradient->setPen( c );
//zzz	QPointArray a;
	QPolygon a;

	a.setPoints( 4,
		     0, 0,
		     iDiag * 2 / iNrSices, 0,
		     iDiag * 2 / iNrSices, iDiag * 2,
		     0, iDiag * 2 );
	paintGradient->drawPolygon( a );
	mxRot.translate( (double)iDiag * 2.0 / (double)iNrSices, 0.0  );
    }

    paintGradient->end();
    return pmGradient;

}
コード例 #7
0
ファイル: zpunctum.cpp プロジェクト: Vaa3D/vaa3d_tools
QColor ZPunctum::selectingColor(const QColor &color) const
{
  QColor select;

  select.setHsv((color.hue() + 60) % 360,
                /*color.saturation()*/255, 255/*color.value()*/);

  return select;
}
コード例 #8
0
ファイル: carditem.cpp プロジェクト: DINKIN/Cockatrice
void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->save();
    AbstractCardItem::paint(painter, option, widget);
    
    int i = 0;
    QMapIterator<int, int> counterIterator(counters);
    while (counterIterator.hasNext()) {
        counterIterator.next();
        QColor color;
        color.setHsv(counterIterator.key() * 60, 150, 255);
        
        paintNumberEllipse(counterIterator.value(), 14, color, i, counters.size(), painter);
        ++i;
    }
    
    QSizeF translatedSize = getTranslatedSize(painter);
    qreal scaleFactor = translatedSize.width() / boundingRect().width();
    
    if (!pt.isEmpty()) {
        painter->save();
        transformPainter(painter, translatedSize, tapAngle);

        if(info)
        {
            QStringList ptSplit = pt.split("/");
            QStringList ptDbSplit = info->getPowTough().split("/");
        
            if (getFaceDown() || ptDbSplit.at(0) != ptSplit.at(0) || ptDbSplit.at(1) != ptSplit.at(1))
                painter->setPen(QColor(255, 150, 0));
            else
                painter->setPen(Qt::white);
        } else {
            painter->setPen(Qt::white);
        }
        painter->setBackground(Qt::black);
        painter->setBackgroundMode(Qt::OpaqueMode);
        
        painter->drawText(QRectF(4 * scaleFactor, 4 * scaleFactor, translatedSize.width() - 10 * scaleFactor, translatedSize.height() - 8 * scaleFactor), Qt::AlignRight | Qt::AlignBottom, pt);
        painter->restore();
    }
    if (!annotation.isEmpty()) {
        painter->save();

        transformPainter(painter, translatedSize, tapAngle);
        painter->setBackground(Qt::black);
        painter->setBackgroundMode(Qt::OpaqueMode);
        painter->setPen(Qt::white);
        
        painter->drawText(QRectF(4 * scaleFactor, 4 * scaleFactor, translatedSize.width() - 8 * scaleFactor, translatedSize.height() - 8 * scaleFactor), Qt::AlignCenter | Qt::TextWrapAnywhere, annotation);
        painter->restore();
    }
    if (getBeingPointedAt())
        painter->fillRect(boundingRect(), QBrush(QColor(255, 0, 0, 100)));
    painter->restore();
}
コード例 #9
0
ファイル: editor.cpp プロジェクト: Norrius/Shovel-and-Shotgun
void editor::listenToMouse()
{
    if (levelLoaded)
    {
        if (pressedL)
        {
            int x = floor((xMouseReal-xCorner)/double(tilesize));
            int y = level.h - floor((yMouseReal-yCorner)/double(tilesize)) - 1;
            switch (mode)
            {
            case 0:
            case 1:
            case 2:
                try {
                    setTile(x, y, mode,
                            mode?selectedColor:(char *)"#ffffff",
                            selectedDurability);
                } catch (...) {}
                updateTile(x, y);
                break;
            case 3:
                if (x>=0 && y>=0 && x<level.w && y<level.h && tileType(x, y))
                {
                    int h=0, s=0, v=0;
                    int c = 0;
                    for (int i=-1; i<2; i++)
                        for (int j=-1; j<2; j++, c++)
                        {
                            try {
                                QColor tmp(tileColor(x+i, y+j));
                                h += tmp.hue();
                                s += tmp.saturation();
                                v += tmp.value();
                            } catch (...) {
                                QColor tmp(tileColor(x+(-1*i), y+(-1*j)));
                                h += tmp.hue();
                                s += tmp.saturation();
                                v += tmp.value();
                            }
                        }
                    h /= c;
                    s /= c;
                    v /= c;
                    QColor q;
                    q.setHsv(h, s, v);
                    char m[8];
                    for (int i=0; i<8; i++)
                        m[i] = (q.name().constData()+i)->toAscii();
                    qstrcpy(tileColor(x, y), m);
                    updateTile(x, y);
                    break;
                }
            }
        }
    }
}
コード例 #10
0
ファイル: color.cpp プロジェクト: dirkhh/subsurface
QColor getPressureColor(double density)
{
	QColor color;

	int h = ((int) (180.0 - 180.0 * density / 8.0));
	while (h < 0)
		h += 360;
	color.setHsv(h , 255, 255);
	return color;
}
コード例 #11
0
ファイル: colorbox.cpp プロジェクト: KDE/android-qt-creator
void ColorBox::setCurrent(int x, int y)
{
    QColor newColor;
    x = clamp(x, 0, 120);
    y = clamp(y, 0, 120);
    int oldAlpha = m_color.alpha();
    newColor.setHsv(hue(), (x*255) / 120, 255 - (y*255) / 120);
    newColor.setAlpha(oldAlpha);
    setColor(newColor);
}
コード例 #12
0
void NetworkInstance::visualizeCondition(std::vector<QString> &condition)
{
    for (QString& item : condition){
        QString name = item.split(" ")[0];
        QColor queryColor;
        queryColor.setHsv(20,30,250);
        nv_->getNode(nc_.getNetwork().getNode(name.toStdString()).getID())->originalState();
        nv_->getNode(nc_.getNetwork().getNode(name.toStdString()).getID())->setColor(queryColor);
    }
}
コード例 #13
0
QPixmap
IconLoader::loadPixmap(QString name)
{
    QColor bg = QApplication::palette().window().color();
    if (bg.red() + bg.green() + bg.blue() > 384) { // light background
        QPixmap pmap(QString(":icons/%1").arg(name));
        if (pmap.isNull()) {
            pmap = QPixmap(QString(":icons/%1.png").arg(name));
        }
        return pmap;
    }

    QPixmap pmap(QString(":icons/%1").arg(name));
    if (pmap.isNull()) {
        pmap = QPixmap(QString(":icons/%1_inverse.png").arg(name));
        if (pmap.isNull()) {
            pmap = QPixmap(QString(":icons/%1.png").arg(name));
        }
    }
    if (pmap.isNull()) return pmap;

    for (int i = 0; i < sizeof(autoInvertExceptions)/
                        sizeof(autoInvertExceptions[0]); ++i) {
        if (autoInvertExceptions[i] == name) {
            return pmap;
        }
    }

    // No suitable inverted icon found for black background; try to
    // auto-invert the default one

    QImage img = pmap.toImage().convertToFormat(QImage::Format_ARGB32);

    for (int y = 0; y < img.height(); ++y) {
        for (int x = 0; x < img.width(); ++x) {

            QRgb rgba = img.pixel(x, y);
            QColor colour = QColor
                (qRed(rgba), qGreen(rgba), qBlue(rgba), qAlpha(rgba));

            int alpha = colour.alpha();
            if (colour.saturation() < 5 && colour.alpha() > 10) {
                colour.setHsv(colour.hue(),
                              colour.saturation(),
                              255 - colour.value());
                colour.setAlpha(alpha);
                img.setPixel(x, y, colour.rgba());
            }
        }
    }

    pmap = QPixmap::fromImage(img);
    return pmap;
}
コード例 #14
0
void CalibrationWindow::changeColorMin()
{
    QColor colorMin;
    colorMin.setHsv(ui->horizontalSliderH_Min->value(),
                    ui->horizontalSliderS_Min->value(),
                    ui->horizontalSliderV_Min->value(),
                    ui->horizontalSliderAMin->value());
    QPalette pMin;
    pMin.setColor(QPalette::Base, colorMin);
    ui->textEditColorMin->setPalette(pMin);
}
コード例 #15
0
ファイル: Zones.cpp プロジェクト: mdherynk/GoldenCheetah
// generate a zone color with a specific number of zones
QColor zoneColor(int z, int num_zones) {
  assert ((z >= 0) && (z < num_zones));
  if (num_zones == 1)
    return QColor(128, 128, 128);
  QColor color;

  // pick a color from violet (z=0) to red (z=num_zones)
  color.setHsv(int(300 * (num_zones - z - 1) / (num_zones - 1)), 255, 255); 

  return color;
}
コード例 #16
0
void
Style::drawHeaderSection(const QStyleOption *option, QPainter *painter, const QWidget*) const
{
    OPT_SUNKEN OPT_HOVER
    const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option);
    const bool sorting = header && (header->sortIndicator != QStyleOptionHeader::None);

    Qt::Orientation o = Qt::Vertical; int s = RECT.height();
    if (header && header->orientation == Qt::Vertical)
    {
        o = Qt::Horizontal;
        s = RECT.width();
    }

    QColor c =  sorting ? COLOR(config.view.sortingHeader_role[Bg]) : COLOR(config.view.header_role[Bg]);

    if (Colors::value(c) < 50)
        { int h,s,v,a; c.getHsv(&h, &s, &v, &a); c.setHsv(h, s, 50, a); }

    if (appType == GTK)
        sunken = option->state & State_HasFocus;
    if (sunken)
    {
        const QPixmap &sunk = Gradients::pix(c, s, o, Gradients::Sunken);
        painter->drawTiledPixmap(RECT, sunk);
        return;
    }

    const Gradients::Type gt = sorting ? config.view.sortingHeaderGradient : config.view.headerGradient;

    if (hover)
        c = Colors::mid(c, sorting ? CCOLOR(view.sortingHeader, Fg) : CCOLOR(view.header, Fg),8,1);

    if (gt == Gradients::None)
        painter->fillRect(RECT, c);
    else
        painter->drawTiledPixmap(RECT, Gradients::pix(c, s, o, gt));

    if (o == Qt::Vertical)
    {
        if (!header || header->section < QStyleOptionHeader::End)
        {
            QRect r = RECT; r.setLeft(r.right() - F(1));
            painter->drawTiledPixmap(r, Gradients::pix(CCOLOR(view.header, Bg), s, o, Gradients::Sunken));
        }
        if (Colors::value(CCOLOR(view.header, Bg)) > 90) // not on dark elements - looks just stupid...
        {
            SAVE_PEN
            painter->setPen(Colors::mid(FCOLOR(Base), Qt::black, 6, 1));
            painter->drawLine(RECT.bottomLeft(), RECT.bottomRight());
            RESTORE_PEN
        }
    }
コード例 #17
0
ファイル: ClsFEGroupPlot.cpp プロジェクト: jeez/iqr
void ClsFEGroupPlot::DataSinkAdded(string strID, int iColor){
#ifdef DEBUG_CLSFEGROUPPLOT
    cout << "ClsFEGroupPlot::DataSinkAdded(string strID, int iColor)" << endl;
#endif
    strID = "";

//     cout << "ClsFEGroupPlot::DataSinkAdded(string strID)" << endl;
    QColor qc;
    qc.setHsv(iColor*2, 255, 210); // try to multiply by some factor, so the differences become larger
    wSpacePlot->setColor(qc);

};
コード例 #18
0
ファイル: entityidentifier.cpp プロジェクト: EtlamGit/minutor
void EntityIdentifier::parseEntityDefinition(JSONObject *entity,
                                             QString const &category,
                                             QColor catcolor, int packID) {
  QString id("unknown");
  if (entity->has("id"))
    id = entity->at("id")->asString().toLower();

  if (entity->has("catcolor")) {
    QString colorname = entity->at("catcolor")->asString();
    catcolor.setNamedColor(colorname);
    assert(catcolor.isValid());
  }

  QColor color;
  if (entity->has("color")) {
    QString colorname = entity->at("color")->asString();
    color.setNamedColor(colorname);
    assert(color.isValid());
  } else {  // use hashed by name instead
    quint32 hue = qHash(id);
    color.setHsv(hue % 360, 255, 255);
  }

  QString name;
  if (entity->has("name")) {
    // use provided name
    name = entity->at("name")->asString();
  } else {
    // or try to build name automatically
    // split at underscores
    QStringList tokens = id.toLower().replace('_',' ').split(" ");
    // make first character uppercase
    for (QList<QString>::iterator tokItr = tokens.begin(); tokItr != tokens.end(); ++tokItr) {
      (*tokItr) = (*tokItr).at(0).toUpper() + (*tokItr).mid(1);
    }
    name = tokens.join(" ");
  }

  // enter entity into manager
  TentityMap& map = getMapForPackID(packID);
  map.insert(id, EntityInfo(name, category, catcolor, color));

  // add duplicates: when new 1.11+ or 1.13+ id definitions are available
  // legacy id is stored in own definition element (duplicates automatically)
  if (entity->has("idlist")) {
    JSONArray *idlist = dynamic_cast<JSONArray *>(entity->at("idlist"));
    int len = idlist->length();
    for (int j = 0; j < len; j++) {
      QString idl = entity->at("idlist")->at(j)->asString().toLower();
      map.insert(idl, EntityInfo(name, category, catcolor, color));
    }
  }
}
コード例 #19
0
ScColor ColorWheel::colorSpaceColor(ScColor col)
{
	QColor newcol;
	ScColor ret;
	int h, s, v;

	ScColorEngine::getRGBColor(col, currentDoc).getHsv(&h, &s, &v);
	newcol.setHsv(h, s, v);
	ret.fromQColor(newcol);
	ret = ScColorEngine::convertToModel(ret, currentDoc, currentColorSpace);
	return ret;
}
コード例 #20
0
// Make a color darker if it's too bright
QColor make_color_readable(QColor clr)
{
    // Gray
    if (clr.red() == clr.green() && clr.green() == clr.blue()) {
        return QColor("black");
    }
    clr = clr.toHsv();
    int value = MIN(clr.value(), 150);
    int saturation = 255;
    clr.setHsv(clr.hue(), saturation, value, 255);
    return clr.toRgb();
}
コード例 #21
0
ファイル: qtcolortriangle.cpp プロジェクト: dmt4/klf5
/*!
    Constructs a color triangle widget with the given \a parent.
*/
QtColorTriangle::QtColorTriangle(QWidget *parent)
    : QWidget(parent), bg(sizeHint(), QImage::Format_RGB32), selMode(Idle)
{
    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    setFocusPolicy(Qt::StrongFocus);

    mustGenerateBackground = true;

    QColor tmp;
    tmp.setHsv(76, 184, 206);
    setColor(tmp);
}
コード例 #22
0
QList<QSharedPointer<GeneratedStructure>>
GeneratedStructure::tryParse(const Tag* data) {
  QList<QSharedPointer<GeneratedStructure>> ret;
  if (data && data != &NBT::Null) {
    auto features = data->at("Features");
    if (features && features != &NBT::Null) {
      // convert the features to a qvariant here
      QVariant maybeFeatureMap = features->getData();
      if ((QMetaType::Type)maybeFeatureMap.type() == QMetaType::QVariantMap) {
        QMap<QString, QVariant> featureMap = maybeFeatureMap.toMap();
        for (auto &feature : featureMap) {
          if ((QMetaType::Type)feature.type() == QMetaType::QVariantMap) {
            QMap<QString, QVariant> featureProperties = feature.toMap();
            // check for required properties
            if (featureProperties.contains("BB") &&
                (QMetaType::Type)featureProperties["BB"].type() ==
                QMetaType::QVariantList && featureProperties.contains("id")) {
              QList<QVariant> bb = featureProperties["BB"].toList();
              if (bb.size() == 6) {
                GeneratedStructure* structure = new GeneratedStructure();
                structure->setBounds(
                    Point(bb[0].toInt(), bb[1].toInt(), bb[2].toInt()),
                    Point(bb[3].toInt(), bb[4].toInt(), bb[5].toInt()));
                structure->setType("Structure." +
                                   featureProperties["id"].toString());
                structure->setDisplay(featureProperties["id"].toString());
                structure->setProperties(featureProperties);

                // base the color on a hash of its type
                quint32 hue = qHash(featureProperties["id"].toString());
                QColor color;
                color.setHsv(hue % 360, 255, 255, 64);
                structure->setColor(color);

                // this will have to be maintained if new structures are added
                if (structure->type() == "Structure.Fortress") {
                  structure->setDimension("nether");
                } else if (structure->type() == "Structure.EndCity") {
                  structure->setDimension("end");
                } else {
                  structure->setDimension("overworld");
                }
                ret.append(QSharedPointer<GeneratedStructure>(structure));
              }
            }
          }
        }
      }
    }
  }
  return ret;
}
コード例 #23
0
void QmitkPopupColorChooser::drawGradient( QPainter* p)
{
  p->setWindow( 0, 0, m_Steps-1, m_Steps );       // defines coordinate system
  p->setPen( Qt::NoPen );

  QColor c;
  for ( unsigned int h = 0; h < m_Steps; ++h )
  {
    for ( unsigned int v = 1; v < m_Steps2; ++v )
    {
      c.setHsv( h*m_HStep, 255, v*m_VStep );             // rainbow effect
      p->setBrush( c );                  // solid fill with color c
      p->drawRect( v-1, h, m_Steps2, m_Steps );         // draw the rectangle
    }
    for ( unsigned int s = 0; s < m_Steps2; ++s )
    {
      c.setHsv( h*m_HStep, 255 - s*m_SStep, 255 );             // rainbow effect
      p->setBrush( c );                  // solid fill with color c
      p->drawRect( m_Steps2+s-1, h, m_Steps2, m_Steps );         // draw the rectangle
    }
  }
}
コード例 #24
0
ファイル: colorshower.cpp プロジェクト: newdebug/NewDebug
void YviColorShower::setHsv(int h, int s, int v)
{
    if (h < -1 || (uint)s > 255 || (uint)v > 255)
        return;

    m_hue = h; m_val = v; m_sat = s;
    QColor c;
    c.setHsv(m_hue, m_sat, m_val);
    m_curCol = c.rgb();

    showCurrentColor();
    //updateQColor();
}
コード例 #25
0
QColor KODayMatrix::getShadedColor( const QColor &color ) const
{
  QColor shaded;
  int h = 0;
  int s = 0;
  int v = 0;
  color.getHsv( &h, &s, &v );
  s = s / 4;
  v = 192 + v / 4;
  shaded.setHsv( h, s, v );

  return shaded;
}
コード例 #26
0
void NetworkInstance::visualizeNonInterventionNodes(std::vector<QString> &nonInterventions)
{
    for (QString& item : nonInterventions){
        QString name = item.split(" ")[0];
        if (name == "argmax"){
            name = item.split(" ")[1];
        }
        QColor queryColor;
        queryColor.setHsv(100,30,250);
        nv_->getNode(nc_.getNetwork().getNode(name.toStdString()).getID())->originalState();
        nv_->getNode(nc_.getNetwork().getNode(name.toStdString()).getID())->setColor(queryColor);
    }
}
コード例 #27
0
ファイル: qcolor.cpp プロジェクト: AliYousuf/abanq-port
QColor QColor::dark( int factor ) const
{
    if ( factor <= 0 )				// invalid darkness factor
	return *this;
    else if ( factor < 100 )			// makes color lighter
	return light( 10000/factor );
    int h, s, v;
    hsv( &h, &s, &v );
    v = (v*100)/factor;
    QColor c;
    c.setHsv( h, s, v );
    return c;
}
コード例 #28
0
void StochasticProcessWidget::addQuantile() {
	QTableWidgetItem *item;

	int lastRowIndex = quantileTable->rowCount();
	quantileTable->setRowCount(lastRowIndex + 1);

	double probabilityLimit = quantileEdit->text().toDouble();
	int stateCount = process->getNumStates();


	item = new QTableWidgetItem(quantileEdit->text());
	item->setTextAlignment(Qt::AlignCenter);
	quantileTable->setItem(lastRowIndex, 0, item);
	item = new QTableWidgetItem("[DEL]");
	item->setTextAlignment(Qt::AlignCenter);
	quantileTable->setItem(lastRowIndex, stateCount+1, item);

	for (int stateIndex = 1; stateIndex <= stateCount; stateIndex++) {
		ivector distValues = intervalDists[stateIndex-1];
		real probabilityInf = 0.0;
		real probabilitySup = 0.0;
		int distIndexSup;
		int distIndexInf;
		for (distIndexSup = Lb(distValues); distIndexSup <= Ub(distValues); distIndexSup++) {
			interval distValue = distValues[distIndexSup];
			probabilityInf += Inf(distValue);
			probabilitySup += Sup(distValue);
			if (probabilitySup >= probabilityLimit) {
				if(probabilityInf <probabilityLimit)
					distIndexInf = distIndexSup - 1;
				else
					distIndexInf = distIndexSup;
				break;
			}
		}

		QTableWidgetItem *resultItem = new QTableWidgetItem(QString("[%1..%2]").arg(distIndexInf).arg(distIndexSup));
		resultItem->setTextAlignment(Qt::AlignCenter);
		quantileTable->setItem(lastRowIndex, stateIndex, resultItem);
	}

	int distCount = process->getNumStates();
	QColor quantileCellColor;

	for (int i = 0; i < distCount; i++) {
		int hueValue = (int)round(255.0
				/ ((double)distCount / (double)i));
		quantileCellColor.setHsv(hueValue, 40, 245);
		quantileTable->item(lastRowIndex, i+1)->setBackgroundColor(quantileCellColor);
	}
}
コード例 #29
0
ファイル: kcolordialog.cpp プロジェクト: Geekking/lima
void KColorDialog::KColorDialogPrivate::slotVChanged(int v)
{
    int _h, _s, _v, _r, _g, _b;

    _h = selColor.hue();
    _s = selColor.saturation();
    _v = selColor.value();
    _r = selColor.red();
    _g = selColor.green();
    _b = selColor.blue();


    QColor col;

    switch (chooserMode()) {
    case ChooserHue:
        col.setHsv(v, _s, _v);
        break;
    case ChooserSaturation:
        col.setHsv(_h, v, _v);
        break;
    case ChooserRed:
        col.setRgb(v, _g, _b);
        break;
    case ChooserGreen:
        col.setRgb(_r, v, _b);
        break;
    case ChooserBlue:
        col.setRgb(_r, _g, v);
        break;
    case ChooserValue:
    default:
        col.setHsv(_h, _s, v);
        break;
    }

    _setColor(col);
}
コード例 #30
0
ファイル: ClsFETimePlot.cpp プロジェクト: jeez/iqr
void ClsFETimePlot::DataSinkAdded(string strID, int iColor){
#ifdef DEBUG_CLSFETIMEPLOT
    cout << "ClsFETimePlot::DataSinkAdded(string strID)" << endl;
#endif

//    cout << "strID: " << strID << endl;

    QColor qc;
    qc.setHsv(iColor, 255, 210);
    pair<string, int> pairTemp2(strID, wLinePlot->countTraces());
    mapTraces.insert(pairTemp2);
    wLinePlot->addTrace(QString(""), qc);

};