本文整理汇总了C++中QColor::setRgbF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setRgbF方法的具体用法?C++ QColor::setRgbF怎么用?C++ QColor::setRgbF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setRgbF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
KnobGuiBool::onLabelChanged()
{
const std::string& label = _knob.lock()->getLabel();
if ( (label == "R") || (label == "r") || (label == "red") ) {
QColor color;
color.setRgbF(0.851643, 0.196936, 0.196936);
_checkBox->setCustomColor(color, true);
} else if ( (label == "G") || (label == "g") || (label == "green") ) {
QColor color;
color.setRgbF(0, 0.654707, 0);
_checkBox->setCustomColor(color, true);
} else if ( (label == "B") || (label == "b") || (label == "blue") ) {
QColor color;
color.setRgbF(0.345293, 0.345293, 1);
_checkBox->setCustomColor(color, true);
} else if ( (label == "A") || (label == "a") || (label == "alpha") ) {
QColor color;
color.setRgbF(0.398979, 0.398979, 0.398979);
_checkBox->setCustomColor(color, true);
} else {
_checkBox->setCustomColor(Qt::black, false);
}
}
示例2: glPointSize
void
Viewer::draw()
{
if(!are_buffers_initialized)
initialize_buffers();
QColor color;
//points
vao[1].bind();
attrib_buffers(this);
rendering_program_points.bind();
color.setRgbF(1.0f, 0.0f, 0.0f);
glPointSize(5);
::glEnable(GL_POINT_SMOOTH);
rendering_program_points.setUniformValue(colorLocation_points, color);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
rendering_program_points.release();
vao[1].release();
//facets
vao[0].bind();
attrib_buffers(this);
rendering_program.bind();
color.setRgbF(0.5f, 1.0f, 0.5f);
rendering_program.setUniformValue(colorLocation, color);
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_poly.size()/3));
rendering_program.release();
vao[0].release();
}
示例3: settingsWidget
QWidget* OrbitalEngine::settingsWidget()
{
if(!m_settingsWidget)
{
m_settingsWidget = new OrbitalSettingsWidget();
connect(m_settingsWidget->orbital1Combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(setOrbital1(int)));
connect(m_settingsWidget->opacitySlider, SIGNAL(valueChanged(int)),
this, SLOT(setOpacity(int)));
connect(m_settingsWidget->renderCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(setRenderMode(int)));
connect(m_settingsWidget->drawBoxCheck, SIGNAL(stateChanged(int)),
this, SLOT(setDrawBox(int)));
connect(m_settingsWidget->posColor, SIGNAL(colorChanged(QColor)),
this, SLOT(setPosColor(QColor)));
connect(m_settingsWidget->negColor, SIGNAL(colorChanged(QColor)),
this, SLOT(setNegColor(QColor)));
connect(m_settingsWidget, SIGNAL(destroyed()),
this, SLOT(settingsWidgetDestroyed()));
// Initialise the widget from saved settings
m_settingsWidget->opacitySlider->setValue(static_cast<int>(m_alpha * 20));
m_settingsWidget->renderCombo->setCurrentIndex(m_renderMode);
m_settingsWidget->drawBoxCheck->setChecked(m_drawBox);
// Initialise the colour buttons
QColor initial;
initial.setRgbF(m_posColor.red(), m_posColor.green(), m_posColor.blue());
m_settingsWidget->posColor->setColor(initial);
initial.setRgbF(m_negColor.red(), m_negColor.green(), m_negColor.blue());
m_settingsWidget->negColor->setColor(initial);
updateOrbitalCombo();
}
示例4: color
QColor Info::color(double value) {
double colorAverage = 0;
double colorDelta = 0.023;
double lowerLimit = colorAverage - colorDelta;
double firstLimit = colorAverage - colorDelta / 2;
double secondLimit = colorAverage;
double thirdLimit = colorAverage + colorDelta / 2;
double upperLimit = colorAverage + colorDelta;
double firstInterval = colorDelta / 2;
double secondInterval = colorDelta / 2;
double thirdInterval = colorDelta / 2;
double fourthInterval = colorDelta / 2;
QColor result;
if (value <= lowerLimit || value >= upperLimit) {
result.setRgbF(1, 1, 1);
} else if (value < firstLimit) {
result.setRgbF(0, (value - lowerLimit) / firstInterval, 1 - (value - lowerLimit) / firstInterval);
} else if (value < secondLimit) {
result.setRgbF((value - firstLimit) / secondInterval, 1, 0);
} else if (value < thirdLimit) {
result.setRgbF(1, 1 - 0.5 * (value - secondLimit) / thirdInterval, 0);
} else {
result.setRgbF(1, 0.5 - 0.5 * (value - thirdLimit) / fourthInterval, 0);
}
return result;
}
示例5: glEnable
void
Viewer::draw()
{
glEnable(GL_DEPTH_TEST);
if(!are_buffers_initialized)
initialize_buffers();
QColor color;
//the points
glEnable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(3.0f,-3.0f);
attrib_buffers(this);
vao[0].bind();
color.setRgbF(1.0f, 0.72f, 0.06f);
rendering_program.bind();
rendering_program.setUniformValue(colorLocation[0], color);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
rendering_program.release();
vao[0].release();
//The Lines
glDisable(GL_POLYGON_OFFSET_FILL);
vao[1].bind();
color.setRgbF(0.27f, 0.51f, 0.7f);
rendering_program.bind();
rendering_program.setUniformValue(colorLocation[0], color);
glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
rendering_program.release();
vao[1].release();
if (scene->eight_copies) {
vao[2].bind();
color.setRgbF(0.69f, 0.77f, 0.87f);
rendering_program.bind();
rendering_program.setUniformValue(colorLocation[0], color);
glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_8lines2D.size()/3));
rendering_program.release();
vao[2].release();
if (!scene->two_dimensional) {
vao[3].bind();
color.setRgbF(0.69f, 0.77f, 0.87f);
rendering_program.bind();
rendering_program.setUniformValue(colorLocation[0], color);
glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_8lines.size()/3));
rendering_program.release();
vao[3].release();
}
}
}
示例6: drawImage
void SoFrameLabel::drawImage()
{
const SbString* s = string.getValues(0);
int num = string.getNum();
if (num == 0) {
this->image = SoSFImage();
return;
}
QFont font(QString::fromAscii(name.getValue()), size.getValue());
QFontMetrics fm(font);
int w = 0;
int h = fm.height() * num;
const SbColor& b = backgroundColor.getValue();
QColor brush;
brush.setRgbF(b[0],b[1],b[2]);
const SbColor& t = textColor.getValue();
QColor front;
front.setRgbF(t[0],t[1],t[2]);
QStringList lines;
for (int i=0; i<num; i++) {
QString line = QString::fromUtf8(s[i].getString());
w = std::max<int>(w, fm.width(line));
lines << line;
}
QImage image(w+10,h+10,QImage::Format_ARGB32_Premultiplied);
image.fill(0x00000000);
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing);
SbBool drawFrame = frame.getValue();
if (drawFrame) {
painter.setPen(QPen(QColor(0,0,127), 2, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.setBrush(QBrush(brush, Qt::SolidPattern));
QRectF rectangle(0.0, 0.0, w+10, h+10);
painter.drawRoundedRect(rectangle, 5, 5);
}
painter.setPen(front);
Qt::Alignment align = Qt::AlignVCenter;
if (justification.getValue() == 0)
align = Qt::AlignVCenter | Qt::AlignLeft;
else if (justification.getValue() == 1)
align = Qt::AlignVCenter | Qt::AlignRight;
else
align = Qt::AlignVCenter | Qt::AlignHCenter;
QString text = lines.join(QLatin1String("\n"));
painter.setFont(font);
painter.drawText(5,5,w,h,align,text);
painter.end();
SoSFImage sfimage;
Gui::BitmapFactory().convert(image, sfimage);
this->image = sfimage;
}
示例7: draw
void Viewer::draw()
{
if(scene)
{
glEnable(GL_DEPTH_TEST);
if(!are_buffers_initialized)
initialize_buffers();
QColor color;
if ( !wireframe )
{
if(flatShading)
{
vao[0].bind();
attrib_buffers(this);
rendering_program.bind();
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
rendering_program.release();
vao[0].release();
}
else
{
vao[1].bind();
attrib_buffers(this);
rendering_program.bind();
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
rendering_program.release();
vao[1].release();
}
}
if(edges)
{
vao[2].bind();
attrib_buffers(this);
color.setRgbF(0.2f, 0.2f, 0.7f);
rendering_program_p_l.bind();
rendering_program_p_l.setAttributeValue(colorLocation,color);
glLineWidth(size_edges);
glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
rendering_program_p_l.release();
vao[2].release();
}
if(vertices)
{
vao[3].bind();
attrib_buffers(this);
color.setRgbF(.2f,.2f,.6f);
rendering_program_p_l.bind();
rendering_program_p_l.setAttributeValue(colorLocation,color);
rendering_program_p_l.setUniformValue("point_size", GLfloat(size_points));
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
rendering_program_p_l.release();
vao[3].release();
}
}
}
示例8: getQRgb
QRgb RGBColor::getQRgb() const
{
QColor color;
double maxValue = 1.0/max(r, max(g, b));
if (maxValue < 1.0)
color.setRgbF ( r*maxValue, g*maxValue, b*maxValue, 1.0 );
else
color.setRgbF ( r, g, b, 1.0 );
return color.rgba();
}
示例9: draw
void Viewer::draw()
{
if(!are_buffers_initialized)
initialize_buffers();
QColor color;
if ( !wireframe )
{
if(flatShading)
{
vao[0].bind();
attrib_buffers(this);
rendering_program.bind();
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
rendering_program.release();
vao[0].release();
}
else
{
vao[1].bind();
attrib_buffers(this);
rendering_program.bind();
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
rendering_program.release();
vao[1].release();
}
}
if(edges)
{
vao[2].bind();
attrib_buffers(this);
color.setRgbF(0.2f, 0.2f, 0.7f);
rendering_program_p_l.bind();
rendering_program_p_l.setAttributeValue(colorLocation,color);
glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(pos_lines.size()/3));
rendering_program_p_l.release();
vao[2].release();
}
if(vertices)
{
::glPointSize(7.f);
vao[3].bind();
attrib_buffers(this);
color.setRgbF(.2f,.2f,.6f);
rendering_program_p_l.bind();
rendering_program_p_l.setAttributeValue(colorLocation,color);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(pos_points.size()/3));
rendering_program_p_l.release();
vao[3].release();
}
}
示例10: color
QColor Surface::color(Sign sign) const
{
QColor color;
switch (sign) {
case Positive:
color.setRgbF(m_colorPositive[0], m_colorPositive[1], m_colorPositive[2]);
break;
case Negative:
color.setRgbF(m_colorNegative[0], m_colorNegative[1], m_colorNegative[2]);
break;
}
return color;
}
示例11: AttributesChanged
void EC_HoveringText::AttributesChanged()
{
if (font.ValueChanged() || fontSize.ValueChanged())
{
SetFont(QFont(font.Get(), fontSize.Get()));
}
if (fontColor.ValueChanged())
{
Color col = fontColor.Get();
textColor_.setRgbF(col.r, col.g, col.b, col.a);
}
if (position.ValueChanged())
{
SetPosition(position.Get());
}
if (gradStart.ValueChanged() || gradEnd.ValueChanged())
{
QColor colStart;
QColor colEnd;
Color col = gradStart.Get();
colStart.setRgbF(col.r, col.g, col.b);
col = gradEnd.Get();
colEnd.setRgbF(col.r, col.g, col.b);
SetBackgroundGradient(colStart, colEnd);
}
if (overlayAlpha.ValueChanged())
SetOverlayAlpha(overlayAlpha.Get());
if (width.ValueChanged() || height.ValueChanged())
SetBillboardSize(width.Get(), height.Get());
if (material.ValueChanged())
{
// Don't render the HoveringText if it's not using a material.
if (billboardSet_)
{
bool isVisible = !material.Get().ref.isEmpty();
billboardSet_->setVisible(isVisible);
}
// If the material was cleared, erase the material from Ogre billboard as well. (we might be deleting the material in Tundra Asset API)
if (material.Get().ref.isEmpty() && billboardSet_)
#if OGRE_VERSION_MAJOR <= 1 && OGRE_VERSION_MINOR <= 7 && OGRE_VERSION_PATCH <= 2
billboardSet_->setMaterialName("BaseWhite"); // BaseWhite is an Ogre-internal default material which always exists.
#else // Ogre::BillboardSet::setMaterial() only available at Ogre 1.7.3 and newer.
billboardSet_->setMaterial(Ogre::MaterialPtr());
#endif
else
materialAsset.HandleAssetRefChange(&material);
}
示例12: platformGradient
QGradient* Gradient::platformGradient()
{
if (m_gradient)
return m_gradient;
if (m_radial)
m_gradient = new QRadialGradient(m_p1.x(), m_p1.y(), m_r1, m_p0.x(), m_p0.y());
else
m_gradient = new QLinearGradient(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y());
QColor stopColor;
Vector<ColorStop>::iterator stopIterator = m_stops.begin();;
qreal lastStop;
const qreal lastStopDiff = 0.0000001;
while (stopIterator != m_stops.end()) {
stopColor.setRgbF(stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha);
if (qFuzzyCompare(lastStop, qreal(stopIterator->stop)))
lastStop = stopIterator->stop + lastStopDiff;
else
lastStop = stopIterator->stop;
if (m_radial && m_r0)
lastStop = m_r0 / m_r1 + lastStop * (1.0f - m_r0 / m_r1);
m_gradient->setColorAt(lastStop, stopColor);
++stopIterator;
}
return m_gradient;
}
示例13: determineColor
QColor Viewport::determineColor(const QColor &basecolor,
float weight, float totalweight,
bool highlighted, bool single)
{
QColor color = basecolor;
qreal alpha;
/* TODO: this is far from optimal yet. challenge is to give a good
view where important information is not lost, yet not clutter
the view with too much low-weight information */
/* logarithm is used to prevent single data points to get lost.
this should be configurable. */
alpha = useralpha;
if (drawLog->isChecked())
alpha *= (0.01 + 0.99*(std::log(weight+1) / std::log(totalweight)));
else
alpha *= (0.01 + 0.99*(weight / totalweight));
color.setAlphaF(std::min(alpha, 1.)); // cap at 1
if (highlighted) {
if (basecolor == Qt::white) {
color = Qt::yellow;
} else {
color.setGreen(std::min(color.green() + 195, 255));
color.setRed(std::min(color.red() + 195, 255));
color.setBlue(color.blue()/2);
}
color.setAlphaF(1.);
}
// recolor singleLabel (and make 100% opaque)
if (single) {
color.setRgbF(1., 1., 0., 1.);
}
return color;
}
示例14: renderText
void QtFontRenderer::renderText(const double x, const double y, const double angle, const QString &string, OGLWidget *widget) {
// rotated text not supported directly;
if (angle != 0) {
bool afb = widget->autoFillBackground();
bool abs = widget->autoBufferSwap();
widget->setAutoBufferSwap(false);
widget->setAutoFillBackground(false);
GLfloat colors[4];
glGetFloatv(GL_CURRENT_COLOR, colors);
mPainter.begin(widget);
if (mPainter.isActive()) {
QColor color;
color.setRgbF(colors[0], colors[1], colors[2], colors[3]);
mPainter.setPen(color);
mPainter.setFont(mFont);
mPainter.translate(x,y);
mPainter.rotate(angle);
mPainter.drawText(0, 0, string);
mPainter.end();
}
widget->setAutoBufferSwap(abs);
widget->setAutoFillBackground(afb);
} else {
widget->renderText(x, y, 0.0, string, mFont);
}
}
示例15: parseUniformVariables
/* This only parses uniform variables between the following lines:
// BEGIN UNIFORM
uniform float x; // default
uniform vec4 color; // red green blue alpha
// END UNIFORM
uniform can be replaced by 'in' and if no default is given the floats default
to 0.0 and the color to white. Comments between the BEGIN and END lines are
ignored.
*/
QVariantMap ShaderLibrary::parseUniformVariables(QString const& vertexShaderPath)
{
QVariantMap map;
QFile file(vertexShaderPath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
Parser2::TextStream textStream(&file);
int n;
bool tf;
double value;
QString line;
QString name;
QColor color;
QStringList tokens;
textStream.seek("BEGIN UNIFORM");
while (!textStream.atEnd()) {
line = textStream.nextLine();
if (line.contains("END UNIFORM")) break;
if (!line.startsWith("//")) {
line = line.replace(";"," ");
line = line.replace(","," ");
line = line.replace("//"," ");
tokens = Parser2::TextStream::tokenize(line);
n = tokens.size();
if (n >= 3 && (tokens[0] == "uniform" || tokens[0] == "in")) {
name = tokens[2];
if (tokens[1] == "float") {
value = (n >= 4) ? tokens[3].toDouble() : 0.0;
map.insert(name, value);
}else if (tokens[1] == "bool") {
tf = (n >= 4) ? tokens[3].toInt() : false;
map.insert(name, tf);
}else if (tokens[1] == "vec4") {
color = Qt::white;
if (n >= 7) {
color.setRgbF(tokens[3].toDouble(), tokens[4].toDouble(),
tokens[5].toDouble(), tokens[6].toDouble());
}
map.insert(name, color);
}else {
qDebug() << "Unknown uniform variable in shader" << tokens[1];
}
}
}
}
file.close();
}
qDebug() << "Parsed the following uniform variables:";
for (QVariantMap::iterator iter = map.begin(); iter != map.end(); ++iter) {
qDebug() << iter.key() << iter.value();
}
return map;
}