Пример #1
0
 void Color::setFromQColor(const QColor &color)
 {
   m_channels[0] = color.redF();
   m_channels[1] = color.greenF();
   m_channels[2] = color.blueF();
   m_channels[3] = color.alphaF();
 }
Пример #2
0
void ColorSelectWidget::setColor(const QColor &color, bool hasAlpha) {
	d->hasAlpha = hasAlpha;
	d->alpha->setVisible(d->hasAlpha);
	d->alpha->setValue(d->hasAlpha ? color.alphaF()*100.0 : 100.0);
	d->alphaLabel->setVisible(d->hasAlpha);
	d->color->setCurrentColor(color.rgb());
}
Пример #3
0
void HeadMesh::setColor(QColor c)
{
    color[0] = c.redF();
    color[1] = c.greenF();
    color[2] = c.blueF();
    color[3] = c.alphaF();
}
void TrajectoryVisualization::setBackwardColor(QColor c)
{
    { boost::mutex::scoped_lock lockit(this->updateMutex);
        backwardColor = osg::Vec4(c.redF(), c.greenF(), c.blueF(), c.alphaF() ); }
    emit propertyChanged("BackwardColor");
    setDirty();
}
Пример #5
0
static inline void qSetColor(float colorVec[], QColor c)
{
    colorVec[0] = c.redF();
    colorVec[1] = c.greenF();
    colorVec[2] = c.blueF();
    colorVec[3] = c.alphaF();
}
Пример #6
0
void QMesh::qSetColor(QColor c)
{
    faceColor[0] = c.redF();
    faceColor[1] = c.greenF();
    faceColor[2] = c.blueF();
    faceColor[3] = c.alphaF();
}
Пример #7
0
void ColorSpinBoxGroup::setColor(const QColor &c)
{
    if(c == color_) return;
    noColorUpdate = true;
    ui->opacityBox->setValue(c.alphaF()*100.0);
    if(isRgbColors){
        ui->RedspinBox->setValue(c.red());
        ui->GreenspinBox->setValue(c.green());
        ui->BluespinBox->setValue(c.blue());
    }else{
        ui->RedspinBox->setValue(
                    qBound(0.0, c.hsvHueF()*359, 359.0)
                    );
        ui->GreenspinBox->setValue(
                    qBound(0.0, c.hsvSaturationF()*100, 100.0)
                    );
        ui->BluespinBox->setValue(
                    qBound(0.0, c.valueF()*100, 100.0)
                    );
    }
    color_ = c;

    QPalette p = ui->label->palette();
    p.setColor(QPalette::Background, color_);
    ui->label->setPalette(p);
    noColorUpdate = false;
}
Пример #8
0
void
KnobGuiColor::onDialogCurrentColorChanged(const QColor & color)
{
    KnobColorPtr knob = _knob.lock();
    if (!knob) {
        return;
    }
    int nDims = knob->getNDimensions();

    std::vector<double> values(nDims);
    values[0] = color.redF();
    convertFromUIToInternalColorspace(&values[0]);
    if (nDims > 1) {
        values[1] =  color.greenF();
        convertFromUIToInternalColorspace(&values[1]);
    }
    if (nDims > 2) {
        values[2] = color.blueF();
        convertFromUIToInternalColorspace(&values[2]);
    }
    if (nDims > 3) {
        values[3] = color.alphaF();
    }

    KnobGuiPtr knobUI = getKnobGui();
    knob->setValueAcrossDimensions(values, DimIdx(0), getView(), eValueChangedReasonUserEdited);
    if ( knobUI->getGui() ) {
        knobUI->getGui()->setDraftRenderEnabled(true);
    }
}
QImage DwarfClipboardPng::getTileFromScreen(DFHack::t_screen screen)
{
    QColor foregroundColor = getForegroundColorFromScreen(screen);
    QColor backgroundColor = getBackgroundColorFromScreen(screen);
    QImage tile = tileSet->copy((screen.symbol % 16)*tileWidth,int(screen.symbol/16)*tileHeight,tileWidth,tileHeight);
    QImage resultImage(tileWidth,tileHeight,QImage::Format_ARGB32);
    for(int x = 0;x< tile.width();x++){
        for(int y =0;y<tile.height();y++){
            QColor color;
            color.setRgba(tile.pixel(x,y));
            if(color == QColor("#FF00FF")){ // FF00FF is magenta
                resultImage.setPixel(x,y,backgroundColor.rgb());
            }
            else{
                QColor newColor;
                qreal alpha = color.alphaF();
                qreal alpha_diff = 1-alpha;
                newColor.setRedF((alpha * (color.redF() * foregroundColor.redF() )) + (alpha_diff * backgroundColor.redF()));
                newColor.setGreenF((alpha * (color.greenF() * foregroundColor.greenF() )) + (alpha_diff * backgroundColor.greenF()));
                newColor.setBlueF((alpha * (color.blueF() * foregroundColor.blueF() )) + (alpha_diff * backgroundColor.blueF()));
                resultImage.setPixel(x,y,newColor.rgb());
            }
        }
    }
    return(resultImage);
}
void RenderThread::qColorToQuadcolor(QColor c, float* result) const
{
    result[0] = c.redF();
    result[1] = c.greenF();
    result[2] = c.blueF();
    result[3] = c.alphaF();
}
QColor alphaColor(QColor color, double alpha)
{
    if (alpha >= 1.0)
        return color;
    color.setAlphaF(qMax(0.0, alpha) * color.alphaF());
    return color;
}
Пример #12
0
void
KnobGuiColor::onDialogCurrentColorChanged(const QColor & color)
{
    KnobColorPtr knob = _knob.lock();
    bool isSimple = _useSimplifiedUI;
    int nDims = knob->getNDimensions();

    std::vector<double> values(nDims);
    values[0] = isSimple ? color.redF() : Color::from_func_srgb( color.redF() );


    if (nDims >= 3) {
        values[1] = isSimple ? color.greenF() : Color::from_func_srgb( color.greenF() );
        values[2] = isSimple ? color.blueF() : Color::from_func_srgb( color.blueF() );
        if (nDims == 4) {
            values[3] = color.alphaF();
        }
    }

    KnobGuiPtr knobUI = getKnobGui();
    knob->setValueAcrossDimensions(values, DimIdx(0), getView(), eValueChangedReasonUserEdited);
    if ( knobUI->getGui() ) {
        knobUI->getGui()->setDraftRenderEnabled(true);
    }
}
Пример #13
0
inline void _FillArray(const QColor& c, float* arr)
{
	arr[0] = c.redF();
	arr[1] = c.greenF();
	arr[2] = c.blueF();
	arr[3] = c.alphaF();
}
Пример #14
0
 Color::Color(const QColor &qcolor) : d(0)
 {
   m_channels[0] = static_cast<float>(qcolor.redF());
   m_channels[1] = static_cast<float>(qcolor.greenF());
   m_channels[2] = static_cast<float>(qcolor.blueF());
   m_channels[3] = static_cast<float>(qcolor.alphaF());
 }
Пример #15
0
void DkPaintToolBar::setPenColor(const QColor& col) {

	penCol = col;
	penColButton->setStyleSheet("QPushButton {background-color: " + nmc::DkUtils::colorToString(penCol) + "; border: 1px solid #888;}");
	penAlpha = col.alpha();
	alphaBox->setValue(col.alphaF()*100);
}
Пример #16
0
Color4f::Color4f( const QColor& qc)
{
    color[0] = qc.redF();
    color[1] = qc.greenF();
    color[2] = qc.blueF();
    color[3] = qc.alphaF();
}
Пример #17
0
//-----------------------------------------------------------------------------
void ctkVTKLookupTable::setControlPointValue(int index, const QVariant& value)
{
  Q_D(ctkVTKLookupTable);
  Q_ASSERT(value.value<QColor>().isValid());
  QColor rgba = value.value<QColor>();
  d->LookupTable->SetTableValue(index, rgba.redF(), rgba.greenF(), rgba.blueF(), rgba.alphaF());
}
Пример #18
0
void ColorInspector::setColor(const QColor &newColor)
{
    if (newColor == m_color)
    {
        return;
    }
    noColorUpdate = true;

    if(isRgbColors)
    {
        ui->RedspinBox->setValue(newColor.red());
        ui->GreenspinBox->setValue(newColor.green());
        ui->BluespinBox->setValue(newColor.blue());
        ui->AlphaspinBox->setValue(newColor.alpha());
    }
    else
    {
        ui->RedspinBox->setValue( qBound(0.0, newColor.hsvHueF() * 359, 359.0) );
        ui->GreenspinBox->setValue( qBound(0.0, newColor.hsvSaturationF() * 100, 100.0) );
        ui->BluespinBox->setValue( qBound(0.0, newColor.valueF() * 100, 100.0) );
        ui->AlphaspinBox->setValue( qBound(0.0, newColor.alphaF() * 100, 100.0) );
    }
    m_color = newColor;

    QPalette p = ui->color->palette();
    p.setColor(QPalette::Background, m_color);
    ui->color->setPalette(p);
    //ui->color->setFixedSize(30,30);
    noColorUpdate = false;
}
Пример #19
0
/**
 * 与えられたポリゴンに基づいて、閉じた領域を描画する。
 * ただし、ポリゴンデータ自体は、閉じていなくて良い。
 */
void Renderer::renderArea(const Polygon2D& area, GLenum lineType, const QColor& color, float height) {
    std::vector<RenderablePtr> renderables;
    renderables.push_back(RenderablePtr(new Renderable(lineType, 3.0f)));
    renderables.push_back(RenderablePtr(new Renderable(GL_POINTS, 10.0f)));

    Vertex v;

    v.color[0] = color.redF();
    v.color[1] = color.greenF();
    v.color[2] = color.blueF();
    v.color[3] = color.alphaF();
    v.normal[0] = 0.0f;
    v.normal[1] = 0.0f;
    v.normal[2] = 1.0f;

    for (int i = 0; i < area.size(); i++) {
        v.location[0] = area[i].x();
        v.location[1] = area[i].y();
        v.location[2] = height;
        renderables[0]->vertices.push_back(v);
        renderables[1]->vertices.push_back(v);
    }

    v.location[0] = area[0].x();
    v.location[1] = area[0].y();
    v.location[2] = height;
    renderables[0]->vertices.push_back(v);

    render(renderables);
}
Пример #20
0
void SourceGroup::setColor( const QColor newColor )
{
    color[ 0 ] = newColor.redF();
    color[ 1 ] = newColor.greenF();
    color[ 2 ] = newColor.blueF();
    color[ 3 ] = newColor.alphaF();
}
Пример #21
0
void TrajectoryVisualization::setColor(QColor color)
{
    { boost::mutex::scoped_lock lockit(this->updateMutex);
        this->color = osg::Vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
    emit propertyChanged("Color");
    setDirty();
}
Пример #22
0
void
KnobGuiColor::onDialogCurrentColorChanged(const QColor & color)
{
    KnobColorPtr knob = _knob.lock();
    bool isSimple = _useSimplifiedUI;
    int nDims = knob->getDimension();

    if (nDims == 1) {
        knob->setValue(color.redF(), ViewSpec::all(), 0);
    } else if (nDims == 3) {
        knob->setValues(isSimple ? color.redF() : Color::from_func_srgb( color.redF() ),
                        isSimple ? color.greenF() : Color::from_func_srgb( color.greenF() ),
                        isSimple ? color.blueF() : Color::from_func_srgb( color.blueF() ),
                        ViewSpec::all(),
                        eValueChangedReasonNatronInternalEdited);
    } else if (nDims == 4) {
        knob->setValues(isSimple ? color.redF() : Color::from_func_srgb( color.redF() ),
                        isSimple ? color.greenF() : Color::from_func_srgb( color.greenF() ),
                        isSimple ? color.blueF() : Color::from_func_srgb( color.blueF() ),
                        color.alphaF(),
                        ViewSpec::all(),
                        eValueChangedReasonNatronInternalEdited);
    }
    if ( getGui() ) {
        getGui()->setDraftRenderEnabled(true);
    }
}
Пример #23
0
static void QColorToFloat(const QColor& col, ccColor::Rgbaf& rgba)
{
	rgba.r = static_cast<float>(col.redF  ());
	rgba.g = static_cast<float>(col.greenF());
	rgba.b = static_cast<float>(col.blueF ());
	rgba.a = static_cast<float>(col.alphaF());
}
Пример #24
0
void functionNode::setColor(QColor color)
{
    faceColor[0]=color.redF();
    faceColor[1]=color.greenF();
    faceColor[2]=color.blueF();
    faceColor[3]=color.alphaF();
}
Пример #25
0
void Patch::qSetColor(float colorVec[], QColor c)
{
    colorVec[0] = c.redF();
    colorVec[1] = c.greenF();
    colorVec[2] = c.blueF();
    colorVec[3] = c.alphaF();
};
Пример #26
0
void PrimitiveObject::setConstraintColor( QColor color )
{
	constraintColor[0] = color.redF();
	constraintColor[1] = color.greenF();
	constraintColor[2] = color.blueF();
	constraintColor[3] = color.alphaF();
}
Пример #27
0
void Actor::setShapes(const QtEntityUtils::ItemList& shapes)
{
    _shapes = shapes;
    _geode->removeDrawables(0, _geode->getNumDrawables());

    for(auto i = shapes.begin(); i != shapes.end(); ++i)
    {
        QtEntityUtils::Item entry = *i;

        osg::ref_ptr<osg::ShapeDrawable> sd = new osg::ShapeDrawable();
        
        using namespace QtEntity;

        QVariantMap val = entry._value.toMap();

        if(entry._prototype == "Box")
        {
            osg::Vec3 hl = toVec(val["HalfLengths"]);
            osg::Vec3 c = toVec(val["Center"]);
            sd->setShape(new osg::Box(c, hl[0],hl[1],hl[2]));
            
        }
        else if(entry._prototype == "Sphere")
        {
            osg::Vec3 c = toVec(val["Center"]);
            float radius = val["Radius"].toFloat();
            sd->setShape(new osg::Sphere(c, radius));
        }
        QColor co = val["Color"].value<QColor>();
        sd->setColor(osg::Vec4(co.redF(), co.greenF(), co.blueF(), co.alphaF()));
        _geode->addDrawable(sd);

    }
}
Пример #28
0
static void setLightModel(const LightModel *lightModel)
{
    GLfloat values[4];
#ifdef GL_LIGHT_MODEL_TWO_SIDE
    if (lightModel->model() == LightModel::TwoSided)
        values[0] = 1.0f;
    else
        values[0] = 0.0f;
    glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, values);
#endif
#ifdef GL_LIGHT_MODEL_COLOR_CONTROL
    if (lightModel->colorControl() == LightModel::SeparateSpecularColor)
        values[0] = GL_SEPARATE_SPECULAR_COLOR;
    else
        values[0] = GL_SINGLE_COLOR;
    glLightModelfv(GL_LIGHT_MODEL_COLOR_CONTROL, values);
#endif
#ifdef GL_LIGHT_MODEL_LOCAL_VIEWER
    if (lightModel->viewerPosition() == LightModel::LocalViewer)
        values[0] = 1.0f;
    else
        values[0] = 0.0f;
    glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, values);
#endif
#ifdef GL_LIGHT_MODEL_AMBIENT
    QColor color = lightModel->ambientSceneColor();
    values[0] = color.redF();
    values[1] = color.blueF();
    values[2] = color.greenF();
    values[3] = color.alphaF();
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, values);
#endif
}
Пример #29
0
void Atom::setVibrationVectorColor(QColor const& color) 
{
   s_vibrationVectorColor[0] = color.redF();
   s_vibrationVectorColor[1] = color.greenF();
   s_vibrationVectorColor[2] = color.blueF();
   s_vibrationVectorColor[3] = color.alphaF();
   s_vibrationColorInitialized = true;
}
QColor QtWaitingSpinner::countTrailColor(int distance, int lines, int trail, int minOpacity, QColor color) {
	if (distance == 0) {
		return color;
	}
	const qreal minAlphaF = (qreal)minOpacity / 100;
	int distanceThreshold = ceil( (lines - 1) * (qreal)trail / 100);
	if (distance > distanceThreshold) {
		color.setAlphaF(minAlphaF);
		return color;
	}
	qreal alphaDiff = color.alphaF() - (qreal)minAlphaF;
	qreal gradation = alphaDiff / (qreal)(distanceThreshold + 1);
	qreal resultAlpha = color.alphaF() - gradation * distance;
	resultAlpha = std::min(1.0, std::max(0.0, resultAlpha)); //if alpha is out of bound, force it to bounds
	color.setAlphaF(resultAlpha);
	return color;
}