예제 #1
0
    QVariant tint(const QVariant &baseVar, const QVariant &tintVar) override
    {
        QColor tintColor = tintVar.value<QColor>();

        int tintAlpha = tintColor.alpha();
        if (tintAlpha == 0xFF) {
            return tintVar;
        } else if (tintAlpha == 0x00) {
            return baseVar;
        }

        // tint the base color and return the final color
        QColor baseColor = baseVar.value<QColor>();
        qreal a = tintColor.alphaF();
        qreal inv_a = 1.0 - a;

        qreal r = tintColor.redF() * a + baseColor.redF() * inv_a;
        qreal g = tintColor.greenF() * a + baseColor.greenF() * inv_a;
        qreal b = tintColor.blueF() * a + baseColor.blueF() * inv_a;

        return QVariant::fromValue(QColor::fromRgbF(r, g, b, a + inv_a * baseColor.alphaF()));
    }
예제 #2
0
void setDiffuse(const QColor &diffuse)
{
    GLfloat diffuseMaterial[] = { static_cast<GLfloat>(diffuse.redF()),
                                  static_cast<GLfloat>(diffuse.greenF()),
                                  static_cast<GLfloat>(diffuse.blueF()),
                                  1.0f};

    setMaterial(NO_MATERIAL,
                diffuseMaterial,
                NO_MATERIAL,
                SHININESS_ZERO,
                NO_MATERIAL);
}
예제 #3
0
// set-up the uniform attributes of the shader programs.
void Scene_item::attrib_buffers(CGAL::Three::Viewer_interface* viewer,
                                int program_name) const
{
    viewer->attrib_buffers(program_name);
    QColor c = this->color();
    if(program_name == Scene_item::PROGRAM_WITH_TEXTURE)
    {
       if(is_selected) c = c.lighter(120);
       viewer->getShaderProgram(program_name)->setAttributeValue
         ("color_facets",
          c.redF(),
          c.greenF(),
          c.blueF());
    }
    else if(program_name == PROGRAM_WITH_TEXTURED_EDGES)
    {
        if(is_selected) c = c.lighter(50);
        viewer->getShaderProgram(program_name)->setUniformValue
          ("color_lines",
           QVector3D(c.redF(), c.greenF(), c.blueF()));
    }
}
예제 #4
0
void OSGTextNode::setColor(const QColor &color)
{
    osg::Vec4 osgColor(
        color.redF(),
        color.greenF(),
        color.blueF(),
        color.alphaF());

    if (h->text->getColor() != osgColor) {
        h->text->setColor(osgColor);
        emit colorChanged(color);
    }
}
예제 #5
0
파일: GLWindow.cpp 프로젝트: NCCA/NGL6Demos
void GLWindow::setColour()
{
  QColor colour = QColorDialog::getColor();
  if( colour.isValid())
  {
    ngl::ShaderLib *shader=ngl::ShaderLib::instance();
    (*shader)["Phong"]->use();
    m_colour.m_r=colour.redF();
    m_colour.m_g=colour.greenF();
    m_colour.m_b=colour.blueF();
    updateGL();
  }
}
예제 #6
0
//-----------------------------------------------------------------------------
void ctkVTKColorTransferFunction::setControlPointValue(int index, const QVariant& value)
{
  Q_D(ctkVTKColorTransferFunction);
  Q_ASSERT(value.value<QColor>().isValid());
  QColor rgb = value.value<QColor>();
  double values[6];
  d->ColorTransferFunction->GetNodeValue(index, values);
  values[1] = rgb.redF();
  values[2] = rgb.greenF();
  values[3] = rgb.blueF();
  // setNodeValue should eventually fired the signal changed()
  d->ColorTransferFunction->SetNodeValue(index, values);
}
예제 #7
0
QByteArray BrainSurfaceTreeItem::createCurvatureVertColor(const VectorXf& curvature, const QColor& colSulci, const QColor& colGyri)
{
    QByteArray arrayCurvatureColor;
    arrayCurvatureColor.resize(curvature.rows() * 3 * (int)sizeof(float));
    float *rawColorArray = reinterpret_cast<float *>(arrayCurvatureColor.data());
    int idxColor = 0;

    for(int i = 0; i<curvature.rows(); i++) {
        //Color (this is the default color and will be used until the updateVertColor function was called)
        if(curvature[i] >= 0) {
            rawColorArray[idxColor++] = colSulci.redF();
            rawColorArray[idxColor++] = colSulci.greenF();
            rawColorArray[idxColor++] = colSulci.blueF();
        } else {
            rawColorArray[idxColor++] = colGyri.redF();
            rawColorArray[idxColor++] = colGyri.greenF();
            rawColorArray[idxColor++] = colGyri.blueF();
        }
    }

    return arrayCurvatureColor;
}
// --------------------------------------------------------------------------
void ctkVTKSurfaceMaterialPropertyWidget::onColorChanged(const QColor& newColor)
{
  Q_D(ctkVTKSurfaceMaterialPropertyWidget);
  this->Superclass::onColorChanged(newColor);
  if (d->Property.GetPointer() != 0)
    {
    // the value might have changed since we fired the signal, use the current
    // up-to-date value then.
    const QColor c = this->color();
    // Need to work around a VTK bug of SetColor() that fires event
    // in an unstable state:
    // d->Property->SetColor(c.redF(), c.greenF(), c.blueF());
    d->SettingColor = true;
    d->Property->SetAmbientColor(c.redF(), c.greenF(), c.blueF());
    d->Property->SetDiffuseColor(c.redF(), c.greenF(), c.blueF());
    d->Property->SetSpecularColor(c.redF(), c.greenF(), c.blueF());
    d->SettingColor = false;
    // update just in case something connected to the modified event of the
    // vtkProperty modified any attribute
    this->updateFromProperty();
    }
}
예제 #9
0
void Viewer::drawVertex(const Point_3& p, const QColor& clr, float r)
{
  /* Draw regular points */
  if( m_isFlat ) {
    // disable lighting
    ::glDisable( GL_LIGHTING );

    ::glPointSize(8.0);
    qglColor( clr );

    ::glBegin(GL_POINTS);
    ::glVertex3f( p.x(), p.y(), p.z() );
    ::glEnd();

    // resume lighting
    ::glEnable( GL_LIGHTING );

    return;
  }

  /* Draw vertices as 3D balls */
  GLboolean lighting, colorMaterial;
  ::glGetBooleanv( GL_LIGHTING, &lighting );
  ::glGetBooleanv( GL_COLOR_MATERIAL, &colorMaterial );
  ::glEnable( GL_LIGHTING );
  ::glDisable(GL_COLOR_MATERIAL);

  float color[4];
  color[0] = clr.redF();
  color[1] = clr.greenF();
  color[2] = clr.blueF();
  color[3] = clr.alphaF();

  // move to the point
  ::glPushMatrix();
  ::glTranslatef( p.x(), p.y(), p.z() );

  // draw
  GLUquadricObj* quadratic = ::gluNewQuadric();	// Create A Pointer To The Quadric Object
  ::gluQuadricNormals( quadratic, GLU_SMOOTH );	// Create Smooth Normals
  ::glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color );
  ::gluSphere( quadratic, r, 16, 16 );

  // move back to origin
  ::glPopMatrix();

  if ( colorMaterial )
    ::glEnable( GL_COLOR_MATERIAL );
  if ( !lighting )
    ::glDisable( GL_LIGHTING );
}
예제 #10
0
//-----------------------------------------------------------------------------
int ctkVTKColorTransferFunction::insertControlPoint(const ctkControlPoint& cp)
{
  Q_D(ctkVTKColorTransferFunction);
  int index = -1;
  if (d->ColorTransferFunction.GetPointer() == 0)
    {
    return index;
    }
  QColor rgb = cp.value().value<QColor>();
  const ctkNonLinearControlPoint* nonLinearCp = dynamic_cast<const ctkNonLinearControlPoint*>(&cp);
  if (nonLinearCp)
    {
    // TODO retrieve midpoint & sharpness
    index = d->ColorTransferFunction->AddRGBPoint(
      cp.x(), rgb.redF(), rgb.greenF(), rgb.blueF());
    }
  else
    {
    index = d->ColorTransferFunction->AddRGBPoint(
      cp.x(), rgb.redF(), rgb.greenF(), rgb.blueF());
    }
  return index;
}
예제 #11
0
bool Dataset3D::mousePick( int pickId, QVector3D pos,  Qt::KeyboardModifiers modifiers, QString target )
{
    int paintMode = m_properties["maingl"].get( Fn::Property::D_PAINTMODE ).toInt();
    if ( pickId == 0 ||  paintMode == 0 || !( modifiers & Qt::ControlModifier ) )
    {
        return false;
    }

   QColor paintColorC = m_properties["maingl"].get( Fn::Property::D_PAINTCOLOR ).value<QColor>();
   QVector3D paintValue;
   int type = m_properties["maingl"].get( Fn::Property::D_DATATYPE ).toInt();
   if ( type == DT_UNSIGNED_CHAR )
   {
       paintValue = QVector3D( paintColorC.red(), paintColorC.green(), paintColorC.blue() );
   }
   else
   {
       paintValue = QVector3D( paintColorC.redF(), paintColorC.greenF(), paintColorC.blueF() );
   }

   float dx = m_properties["maingl"].get( Fn::Property::D_DX ).toFloat();
   float dy = m_properties["maingl"].get( Fn::Property::D_DY ).toFloat();
   float dz = m_properties["maingl"].get( Fn::Property::D_DZ ).toFloat();

   m_data[ getIdFromPos( pos.x(), pos.y(), pos.z() ) ] = paintValue;

   int brushSize = m_properties["maingl"].get( Fn::Property::D_PAINTSIZE ).toInt();

   for ( int i = 0; i < brushSize; ++i )
   {
      for ( int j = 0; j < brushSize; ++j )
      {
          for ( int k = 0; k < brushSize; ++k )
          {
              m_data[ getIdFromPos( pos.x() - i * dx, pos.y() - j * dy, pos.z() - k * dz ) ] = paintValue;
              m_data[ getIdFromPos( pos.x() - i * dx, pos.y() - j * dy, pos.z() + k * dz ) ] = paintValue;
              m_data[ getIdFromPos( pos.x() - i * dx, pos.y() + j * dy, pos.z() - k * dz ) ] = paintValue;
              m_data[ getIdFromPos( pos.x() - i * dx, pos.y() + j * dy, pos.z() + k * dz ) ] = paintValue;
              m_data[ getIdFromPos( pos.x() + i * dx, pos.y() - j * dy, pos.z() - k * dz ) ] = paintValue;
              m_data[ getIdFromPos( pos.x() + i * dx, pos.y() - j * dy, pos.z() + k * dz ) ] = paintValue;
              m_data[ getIdFromPos( pos.x() + i * dx, pos.y() + j * dy, pos.z() - k * dz ) ] = paintValue;
              m_data[ getIdFromPos( pos.x() + i * dx, pos.y() + j * dy, pos.z() + k * dz ) ] = paintValue;
          }
      }
   }

   glDeleteTextures( 1, &m_textureGLuint );
   m_textureGLuint = 0;
   return true;
}
예제 #12
0
void BasicOpenGLView::paintGL()
{
    // given our timer, this should be 20
    int elapsed = mAnimationTimer.elapsed();

    float secondsElapsed = elapsed * 0.001f;

	// JB: removed light position/colour change
    mLightPos.x = sin(secondsElapsed) * 20.0f;
    mLightPos.z = cos(secondsElapsed) * 20.0f;
    mLightPos.y = cos(secondsElapsed * 0.5f) * 20.0f;

    QColor curColor;
    curColor.setHsvF(fabs(cos(secondsElapsed / 20.0f)), 1.0, 1.0);

    mLightCol.x = curColor.redF();
    mLightCol.y = curColor.greenF();
    mLightCol.z = curColor.blueF();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if(mRenderOrtho)
    {
        float mAspectRatio = ((float)this->width()) / this->height();
        mProjectionMatrix.ortho(-mDistance,
                                mDistance,
                                mDistance * mAspectRatio,
                                -mDistance * mAspectRatio,
                                -0.1,
                                -500.0);
    }

    std::map<std::string, Geometry *>::iterator it = mGeometries.begin();

    while (it != mGeometries.end())
    {
        it->second->createModelMatrix(mUsePostMultiply);
        it->second->draw(mProjectionMatrix,
                         mViewMatrix,
                         mUsePostMultiply,
                         mLightPos,
                         mLightCol,
                         mTextureHandle,
                         mBumpTextureHandle,
                         mAlphaTextureHandle,
                         mProgram);
        ++it;
    }

}
예제 #13
0
void GLC_WorldTo3dxml::writeLineAttributes(const QColor& color)
{
	m_pOutStream->writeStartElement("LineAttributes");
	m_pOutStream->writeAttribute("lineType", "SOLID");
	m_pOutStream->writeAttribute("thickness", "1");
		m_pOutStream->writeStartElement("Color");
			m_pOutStream->writeAttribute("xsi:type", "RGBAColorType");
			m_pOutStream->writeAttribute("red", QString::number(color.redF()));
			m_pOutStream->writeAttribute("green", QString::number(color.greenF()));
			m_pOutStream->writeAttribute("blue", QString::number(color.blueF()));
			m_pOutStream->writeAttribute("alpha", QString::number(color.alphaF()));
		m_pOutStream->writeEndElement(); // Color
	m_pOutStream->writeEndElement(); // LineAttributes
}
예제 #14
0
void Checkbox::paintEvent(QPaintEvent *e) {
	Painter p(this);

	float64 over = a_over.current(), checked = a_checked.current();
	bool cnone = (over == 0. && checked == 0.), cover = (over == 1. && checked == 0.), cchecked = (checked == 1.);
	bool cbad = !cnone && !cover && !cchecked;
	QColor color;
	if (cbad) {
		float64 onone = (1. - over) * (1. - checked), oover = over * (1. - checked), ochecked = checked;
		color.setRedF(_st.checkFg->c.redF() * onone + _st.checkFgOver->c.redF() * oover + _st.checkFgActive->c.redF() * ochecked);
		color.setGreenF(_st.checkFg->c.greenF() * onone + _st.checkFgOver->c.greenF() * oover + _st.checkFgActive->c.greenF() * ochecked);
		color.setBlueF(_st.checkFg->c.blueF() * onone + _st.checkFgOver->c.blueF() * oover + _st.checkFgActive->c.blueF() * ochecked);
	}

	QRect r(e->rect());
	p.setClipRect(r);
	p.fillRect(r, _st.textBg->b);
	if (_checkRect.intersects(r)) {
		p.setRenderHint(QPainter::HighQualityAntialiasing);

		QPen pen;
		if (cbad) {
			pen = QPen(color);
		} else {
			pen = (cnone ? _st.checkFg : (cover ? _st.checkFgOver : _st.checkFgActive))->p;
			color = (cnone ? _st.checkFg : (cover ? _st.checkFgOver : _st.checkFgActive))->c;
		}
		pen.setWidth(_st.thickness);
		p.setPen(pen);
		if (checked > 0) {
			color.setRedF(color.redF() * checked + st::white->c.redF() * (1. - checked));
			color.setGreenF(color.greenF() * checked + st::white->c.greenF() * (1. - checked));
			color.setBlueF(color.blueF() * checked + st::white->c.blueF() * (1. - checked));
			p.setBrush(color);
		} else {
			p.setBrush(st::white);
		}
		p.drawRoundedRect(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2, _st.thickness / 2, _st.thickness / 2, _st.thickness / 2)), st::msgRadius, st::msgRadius);
		p.setRenderHint(QPainter::HighQualityAntialiasing, false);

		if (checked > 0) {
			p.drawSpriteCenter(_checkRect, _st.checkIcon);
		}
	}
	if (_checkRect.contains(r)) return;

	p.setPen(_st.textFg);
	p.setFont(_st.font);
	p.drawTextLeft(_st.textPosition.x(), _st.textPosition.y(), width(), _text, _textWidth);
}
예제 #15
0
void RobotStateDisplay::changedAttachedBodyColor()
{
  if (robot_)
  {
    QColor color = attached_body_color_property_->getColor();
    std_msgs::ColorRGBA color_msg;
    color_msg.r = color.redF();
    color_msg.g = color.greenF();
    color_msg.b = color.blueF();
    color_msg.a = robot_alpha_property_->getFloat();
    robot_->setDefaultAttachedObjectColor(color_msg);
    update_state_ = true;
  }
}
예제 #16
0
파일: colorlist.cpp 프로젝트: Aconex/pcp
bool
ColorList::findColor(const char *color)
{
    QColor col;

    col.setAllowX11ColorNames(true);
    col.setNamedColor(color);
    if (!col.isValid())
	return false;

    _colors.last()->_list.append(
		new SbColor(col.redF(), col.greenF(), col.blueF()));
    return true;
}
예제 #17
0
void tst_QColor::setBlue()
{
    QColor c = QColor(Qt::red).toHsv();
    c.setBlue(127);
    QCOMPARE(c.red(), 255);
    QCOMPARE(c.green(), 0);
    QCOMPARE(c.blue(), 127);

    c = QColor(Qt::red).toHsv();
    c.setBlueF(0.5);
    QCOMPARE(c.redF(), qreal(1.0));
    QCOMPARE(c.greenF(), qreal(0.0));
    QVERIFY(veryFuzzyCompare(c.blueF(), 0.5));
}
예제 #18
0
// return grayscale
float Exercise123::getGrayColor(const QColor &color)
{
    float gray = 0.0f;

    float wr = 0.299f;
    float wg = 0.587f;
    float wb = 0.114f;

    gray = wr * color.redF()
        + wg * color.greenF()
        + wb * color.blueF();

    return gray;
}
예제 #19
0
QColor QtGradientStopsModel::color(qreal pos) const
{
    PositionStopMap gradStops = stops();
    if (gradStops.isEmpty())
        return QColor::fromRgbF(pos, pos, pos, 1.0);
    if (gradStops.contains(pos))
        return gradStops[pos]->color();

    gradStops[pos] = 0;
    PositionStopMap::ConstIterator itStop = gradStops.constFind(pos);
    if (itStop == gradStops.constBegin()) {
        ++itStop;
        return itStop.value()->color();
    }
    if (itStop == --gradStops.constEnd()) {
        --itStop;
        return itStop.value()->color();
    }
    PositionStopMap::ConstIterator itPrev = itStop;
    PositionStopMap::ConstIterator itNext = itStop;
    --itPrev;
    ++itNext;

    double prevX = itPrev.key();
    double nextX = itNext.key();

    double coefX = (pos - prevX) / (nextX - prevX);
    QColor prevCol = itPrev.value()->color();
    QColor nextCol = itNext.value()->color();

    QColor newColor;
    newColor.setRgbF((nextCol.redF()   - prevCol.redF()  ) * coefX + prevCol.redF(),
                     (nextCol.greenF() - prevCol.greenF()) * coefX + prevCol.greenF(),
                     (nextCol.blueF()  - prevCol.blueF() ) * coefX + prevCol.blueF(),
                     (nextCol.alphaF() - prevCol.alphaF()) * coefX + prevCol.alphaF());
    return newColor;
}
QColor KarbonGradientHelper::colorAt(qreal position, const QGradientStops &stops)
{
    if (! stops.count())
        return QColor();

    if (stops.count() == 1)
        return stops.first().second;

    QGradientStop prevStop(-1.0, QColor());
    QGradientStop nextStop(2.0, QColor());
    // find framing gradient stops
    foreach(const QGradientStop & stop, stops) {
        if (stop.first > prevStop.first && stop.first < position)
            prevStop = stop;
        if (stop.first < nextStop.first && stop.first > position)
            nextStop = stop;
    }

    QColor theColor;

    if (prevStop.first < 0.0) {
        // new stop is before the first stop
        theColor = nextStop.second;
    } else if (nextStop.first > 1.0) {
        // new stop is after the last stop
        theColor = prevStop.second;
    } else {
        // linear interpolate colors between framing stops
        QColor prevColor = prevStop.second, nextColor = nextStop.second;
        qreal colorScale = (position - prevStop.first) / (nextStop.first - prevStop.first);
        theColor.setRedF(prevColor.redF() + colorScale *(nextColor.redF() - prevColor.redF()));
        theColor.setGreenF(prevColor.greenF() + colorScale *(nextColor.greenF() - prevColor.greenF()));
        theColor.setBlueF(prevColor.blueF() + colorScale *(nextColor.blueF() - prevColor.blueF()));
        theColor.setAlphaF(prevColor.alphaF() + colorScale *(nextColor.alphaF() - prevColor.alphaF()));
    }
    return theColor;
}
void CombinedNavRenderer::draw()
{
    QColor color = model()->data( model()->index( (int)Fn::Global::BACKGROUND_COLOR_COMBINED, 0 ) ).value<QColor>();
    glClearColor( color.redF(), color.greenF(), color.blueF(), 1.0 );

    //qDebug() << "combined draw";
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    setupTextures();

    adjustRatios();

    GLFunctions::getShader( "slice" )->bind();
    // Set modelview-projection matrix
    GLFunctions::getShader( "slice" )->setUniformValue( "mvp_matrix", m_mvpMatrix );
    GLFunctions::getShader( "slice" )->setUniformValue( "u_renderMode", 0 );

    initGeometry();

    // Tell OpenGL which VBOs to use
    glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vboIds[ 0 ] );
    glBindBuffer( GL_ARRAY_BUFFER, vboIds[ 1 ] );
    setShaderVars();

    // Draw cube geometry using indices from VBO 0
    glDrawElements( GL_TRIANGLES, 18, GL_UNSIGNED_SHORT, 0 );

    bool renderCrosshairs = model()->data( model()->index( (int)Fn::Global::RENDER_CROSSHAIRS, 0 ) ).toBool();

    if ( renderCrosshairs )
    {
        GLFunctions::getShader( "crosshair" )->bind();
        GLFunctions::getShader( "crosshair" )->setUniformValue( "mvp_matrix", m_mvpMatrix );
        QColor ccolor = model()->data( model()->index( (int)Fn::Global::CROSSHAIR_COLOR, 0 ) ).value<QColor>();
        GLFunctions::getShader( "crosshair" )->setUniformValue( "u_color", ccolor.redF(), ccolor.greenF(), ccolor.blueF(), 1.0 );
        // Tell OpenGL which VBOs to use
        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vboIds[ 2 ] );
        glBindBuffer( GL_ARRAY_BUFFER, vboIds[ 3 ] );

        // Tell OpenGL programmable pipeline how to locate vertex position data
        int vertexLocation = GLFunctions::getShader( "crosshair" )->attributeLocation( "a_position" );
        GLFunctions::getShader( "crosshair" )->enableAttributeArray( vertexLocation );
        glVertexAttribPointer( vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof( VertexData ), 0 );

        glDrawElements( GL_LINES, 12, GL_UNSIGNED_SHORT, 0 );
        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
        glBindBuffer( GL_ARRAY_BUFFER, 0 );
    }
}
예제 #22
0
void LineShader::renderPoints(QVector<QVector3D>& points, QColor color)
{
    _program->setUniformValue(_uniforms["sourceColor"],
                  color.redF(),
                  color.greenF(),
                  color.blueF(),
                  1.0f);

    GLuint posAttr = _attributes["posAttr"];

    _program->setAttributeArray(posAttr, points.constData());
    _program->enableAttributeArray(posAttr);
    glDrawArrays(GL_POINTS, 0, points.size());
    _program->disableAttributeArray(posAttr);
}
예제 #23
0
QByteArray BrainSourceSpaceTreeItem::createVertColor(const MatrixXf& vertices, const QColor& color) const
{
    QByteArray arrayCurvatureColor;
    arrayCurvatureColor.resize(vertices.rows() * 3 * (int)sizeof(float));
    float *rawColorArray = reinterpret_cast<float *>(arrayCurvatureColor.data());
    int idxColor = 0;

    for(int i = 0; i<vertices.rows(); i++) {
        rawColorArray[idxColor++] = color.redF();
        rawColorArray[idxColor++] = color.greenF();
        rawColorArray[idxColor++] = color.blueF();
    }

    return arrayCurvatureColor;
}
예제 #24
0
static void setMaterial(int face, const Material *parameters)
{
    GLfloat params[17];

    QColor mcolor = parameters->ambientColor();
    params[0] = mcolor.redF();
    params[1] = mcolor.greenF();
    params[2] = mcolor.blueF();
    params[3] = mcolor.alphaF();

    mcolor = parameters->diffuseColor();
    params[4] = mcolor.redF();
    params[5] = mcolor.greenF();
    params[6] = mcolor.blueF();
    params[7] = mcolor.alphaF();

    mcolor = parameters->specularColor();
    params[8] = mcolor.redF();
    params[9] = mcolor.greenF();
    params[10] = mcolor.blueF();
    params[11] = mcolor.alphaF();

    mcolor = parameters->emittedLight();
    params[12] = mcolor.redF();
    params[13] = mcolor.greenF();
    params[14] = mcolor.blueF();
    params[15] = mcolor.alphaF();

    params[16] = parameters->shininess();

    glMaterialfv(face, GL_AMBIENT, params);
    glMaterialfv(face, GL_DIFFUSE, params + 4);
    glMaterialfv(face, GL_SPECULAR, params + 8);
    glMaterialfv(face, GL_EMISSION, params + 12);
    glMaterialfv(face, GL_SHININESS, params + 16);
}
예제 #25
0
파일: canvas.cpp 프로젝트: hejtmy/ZSBS
QColor Canvas::modifySelectionColor(const QColor& color)
{
    double colorComponents[3] = {color.redF(), color.greenF(), color.blueF()};

    for (int i = 0; i < 3; ++i)
    {
        colorComponents[i] += colorComponents[i] > 0.5 ? -0.45 : 0.45;
    }

    QColor newColor(color);
    newColor.setRedF(colorComponents[0]);
    newColor.setGreenF(colorComponents[1]);
    newColor.setBlueF(colorComponents[2]);
    return newColor;
}
예제 #26
0
void LineShader::renderLines(QVector<QVector3D>& vertices, QColor lineColor)
{
    _program->setUniformValue(_uniforms["sourceColor"],
                  lineColor.redF(),
                  lineColor.greenF(),
                  lineColor.blueF(),
                  1.0f);

    GLuint posAttr = _attributes["posAttr"];

    _program->setAttributeArray(posAttr, vertices.constData());
    _program->enableAttributeArray(posAttr);
    glDrawArrays(GL_LINES, 0, vertices.size());
    _program->disableAttributeArray(posAttr);
}
예제 #27
0
void ColorUpdater::colorMapChange(pqPipelineRepresentation *repr,
                                  const pqColorMapModel *model)
{
  pqScalarsToColors *lut = repr->getLookupTable();
  // Need the scalar bounds to calculate the color point settings
  QPair<double, double> bounds = lut->getScalarRange();

  vtkSMProxy *lutProxy = lut->getProxy();

  // Set the ColorSpace
  pqSMAdaptor::setElementProperty(lutProxy->GetProperty("ColorSpace"),
                                  model->getColorSpace());
  // Set the NaN color
  QList<QVariant> values;
  QColor nanColor;
  model->getNanColor(nanColor);
  values << nanColor.redF() << nanColor.greenF() << nanColor.blueF();
  pqSMAdaptor::setMultipleElementProperty(lutProxy->GetProperty("NanColor"),
                                          values);

  // Set the RGB points
  QList<QVariant> rgbPoints;
  for(int i = 0; i < model->getNumberOfPoints(); i++)
  {
    QColor rgbPoint;
    pqChartValue fraction;
    model->getPointColor(i, rgbPoint);
    model->getPointValue(i, fraction);
    rgbPoints << fraction.getDoubleValue() * bounds.second << rgbPoint.redF()
              << rgbPoint.greenF() << rgbPoint.blueF();
  }
  pqSMAdaptor::setMultipleElementProperty(lutProxy->GetProperty("RGBPoints"),
                                          rgbPoints);

  lutProxy->UpdateVTKObjects();
}
예제 #28
0
파일: colorlist.cpp 프로젝트: Aconex/pcp
bool
ColorList::findColor(const char *color, float &red, float &green, float &blue)
{
    QColor col;

    col.setAllowX11ColorNames(true);
    col.setNamedColor(color);
    if (!col.isValid())
	return false;

    red = col.redF();
    green = col.greenF();
    blue = col.blueF();
    return true;
}
// Connected to colorChange on the colorWheel_
void TransferFunctionPropertyDialog::setPointColor(QColor color) {
    QList<QGraphicsItem*> selection = tfEditor_->selectedItems();
    vec3 newRgb = vec3(color.redF(), color.greenF(), color.blueF());

    // update Color dialog to reflect the color changes
    setColorDialogColor(color);

    for (auto& elem : selection) {
        TransferFunctionEditorControlPoint* tfcp =
            qgraphicsitem_cast<TransferFunctionEditorControlPoint*>(elem);

        if (tfcp) {
            tfcp->getPoint()->setRGB(newRgb);
        }
    }
}
예제 #30
0
void tst_QColor::setGreen()
{
    DEPENDS_ON(setRgb());

    QColor c = QColor(Qt::blue).toHsv();
    c.setGreen(127);
    QCOMPARE(c.red(), 0);
    QCOMPARE(c.green(), 127);
    QCOMPARE(c.blue(), 255);

    c = QColor(Qt::blue).toHsv();
    c.setGreenF(0.5);
    QCOMPARE(c.redF(), qreal(0.0));
    QVERIFY(veryFuzzyCompare(c.greenF(), 0.5));
    QCOMPARE(c.blueF(), qreal(1.0));
}