本文整理汇总了C++中QColor::setGreenF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setGreenF方法的具体用法?C++ QColor::setGreenF怎么用?C++ QColor::setGreenF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setGreenF方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void Radiobutton::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;
}
pen.setWidth(_st.thickness);
p.setPen(pen);
p.setBrush(Qt::NoBrush);
//int32 skip = qCeil(_st.thickness / 2);
//p.drawEllipse(_checkRect.marginsRemoved(QMargins(skip, skip, skip, skip)));
p.drawEllipse(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2, _st.thickness / 2, _st.thickness / 2, _st.thickness / 2)));
if (checked > 0) {
p.setPen(Qt::NoPen);
if (cbad) {
p.setBrush(color);
} else {
p.setBrush(cnone ? _st.checkFg : (cover ? _st.checkFgOver : _st.checkFgActive));
}
float64 skip0 = _checkRect.width() / 2., skip1 = _st.checkSkip / 10., checkSkip = skip0 * (1. - checked) + skip1 * checked;
p.drawEllipse(QRectF(_checkRect).marginsRemoved(QMarginsF(checkSkip, checkSkip, checkSkip, checkSkip)));
//int32 fskip = qFloor(checkSkip), cskip = qCeil(checkSkip);
//if (2 * fskip < _checkRect.width()) {
// if (fskip != cskip) {
// p.setOpacity(float64(cskip) - checkSkip);
// p.drawEllipse(_checkRect.marginsRemoved(QMargins(fskip, fskip, fskip, fskip)));
// p.setOpacity(1.);
// }
// if (2 * cskip < _checkRect.width()) {
// p.drawEllipse(_checkRect.marginsRemoved(QMargins(cskip, cskip, cskip, cskip)));
// }
//}
}
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
}
if (_checkRect.contains(r)) return;
p.setPen(_st.textFg);
p.setFont(_st.font);
p.drawTextLeft(_st.textPosition.x(), _st.textPosition.y(), width(), _text, _textWidth);
}
示例2: itemChange
QVariant RelationshipView::itemChange(GraphicsItemChange change, const QVariant &value)
{
if(change==ItemPositionChange)
{
this->setFlag(QGraphicsItem::ItemIsMovable, false);
}
else if(change==ItemSelectedHasChanged)
{
unsigned i, count;
QPen pen;
QColor color;
//if(!this->isSelected() && value.toBool())
// this->sel_order=++BaseObjectView::global_sel_order;
this->setSelectionOrder(value.toBool());
pos_info_pol->setVisible(value.toBool());
pos_info_txt->setVisible(value.toBool());
obj_selection->setVisible(value.toBool());
this->configurePositionInfo();
for(i=0; i < 3; i++)
{
if(labels[i])
labels[i]->itemChange(change, value);
}
//Show tha graphical points if 'value' is true
count=graph_points.size();
for(i=0; i < count; i++)
graph_points[i]->setVisible(value.toBool());
//Alter the relationship line color when it is selected
if(value.toBool())
{
QColor cor1=BaseObjectView::getBorderStyle(ParsersAttributes::OBJ_SELECTION).color(),
cor2=BaseObjectView::getBorderStyle(ParsersAttributes::RELATIONSHIP).color();
color.setRedF((cor1.redF() + cor2.greenF())/2.0f);
color.setGreenF((cor1.greenF() + cor2.greenF())/2.0f);
color.setBlueF((cor1.blueF() + cor2.blueF())/2.0f);
}
else
color=BaseObjectView::getBorderStyle(ParsersAttributes::RELATIONSHIP).color();
count=lines.size();
for(i=0; i < count; i++)
{
pen=lines[i]->pen();
pen.setColor(color);
lines[i]->setPen(pen);
}
//Shows/hides the attribute's selection
count=attributes.size();
for(i=0; i < count; i++)
attributes[i]->children().at(3)->setVisible(value.toBool());
emit s_objectSelected(dynamic_cast<BaseGraphicObject *>(this->getSourceObject()),
value.toBool());
}
return(value);
}
示例3: display
//.........这里部分代码省略.........
if (m_partnerKind[index] == EKind::KIND_POST_SYN) {
if (!verified) {
color.setRgb(0, 0, 0);
break;
}
}
}
}
}
color.setAlphaF(alpha);
pen.setColor(color);
pen.setWidthF(pen.widthF() + 0.5);
painter.setPen(pen);
double margin = 0.5;
painter.drawLine(QPointF(center.getX(), center.getY() + radius - margin),
QPointF(center.getX() + radius - margin, center.getY()));
painter.drawLine(QPointF(center.getX(), center.getY() + radius - margin),
QPointF(center.getX() - radius + margin, center.getY()));
}
double conf = getConfidence();
if (conf < 1.0) {
// double lineWidth = radius * conf * 0.5 + 1.0;
double lineWidth = radius * 0.5;
double red = 1.0 - conf;
double green = conf;
QColor color;
color.setRedF(red);
if (getKind() == ZDvidAnnotation::EKind::KIND_POST_SYN) {
color.setBlueF(green);
} else {
color.setGreenF(green);
}
color.setAlphaF(alpha);
painter.setPen(color);
double x = center.getX();
double y = center.getY();
/*
painter.drawLine(QPointF(x - lineWidth, y),
QPointF(x + lineWidth, y));
*/
int startAngle = 0;
int spanAngle = iround((1.0 - conf) * 180) * 16;
painter.drawArc(QRectF(QPointF(x - lineWidth, y - lineWidth),
QPointF(x + lineWidth, y + lineWidth)),
startAngle, spanAngle);
// painter.drawEllipse(QPointF(x, y), lineWidth, lineWidth);
// decorationText += QString(".%1").arg(iround(conf * 10.0));
}
#if 0
int height = iround(getRadius() * 1.5);
int width = decorationText.size() * height;
if (decorationText != m_textDecoration.text()) {
m_textDecoration.setText(decorationText);
m_textDecoration.setTextWidth(width);
}
if (!decorationText.isEmpty()) {
QFont font;
font.setPixelSize(height);
font.setWeight(QFont::Light);
示例4: drawInitialAnimation
void RenderThread::drawInitialAnimation()
{
controller::GameController* controller = glw.getGameController();
model::GameField* field = controller->getGameField();
timeval now = timeOperator->getCurrentTime();
// long ms = timeOperator->getTimeDifference(timestampAnimation, now);
long ms = timeOperator->getTimeSince(timestampAnimation);
if (ms > 3000)
{
initialAnimation = false;
model::AnimationContainer container;
container.objects = controller->getLastGeneratedBalls();
container.timestamp = now;
acontainerGeneratedBalls.push_back(container);
}
//translate into center
int translationX = field->getDimensionX()/2;
int translationY = field->getDimensionY()/2;
float dist = -9;
if (field->getDimensionX() >= field->getDimensionY())
{
dist = field->getDimensionX()*(-1);
}
else
{
dist=field->getDimensionY()*(-1);
}
int count = 0;
//draw each field of the game
for (int i = 0; i< field->getDimensionX(); i++)
{
for (int j = 0; j< field->getDimensionY();j++)
{
//encolor the field
QColor c;
if ((i % 2 == 0 && j % 2 == 0) || (i %2 == 1 && j % 2 == 1) )
{
c.setRedF(0.5f);
c.setGreenF(0.5f);
c.setBlueF(0.5f);
}
else
{
c.setRedF(0.3f);
c.setGreenF(0.3f);
c.setBlueF(0.3f);
}
int name = j*field->getDimensionX()+i;
if (i+j < (float)ms/1000 * (float)(field->getDimensionX()+field->getDimensionY())/2)
{
count ++;
//name the field
glLoadName(name);
//begin actual drawing of the element
float quadcolor[4];
qColorToQuadcolor(c, quadcolor);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, quadcolor);
glMateriali(GL_FRONT, GL_SHININESS, 96);
glTranslatef(i+0.5-translationX,j+0.5-translationY, dist);
float angle = (ms-(float)((i+j)*2000)/(field->getDimensionX()+field->getDimensionY()))*90/1000;
if(angle > 90)
angle = 90;
glRotatef(90-angle,1.0,-1.0,0);
glBegin(GL_QUADS);
glVertex3f(-0.5 , -0.5,0);
glVertex3f(0.5, -0.5,0);
glVertex3f(0.5, 0.5,0);
glVertex3f(-0.5, 0.5,0);
//end drawing
glEnd();
glRotatef(angle-90,1.0,-1.0,0);
glTranslatef(-i-0.5+translationX,-j-0.5+translationY, -dist);
}
}
//.........这里部分代码省略.........
示例5: drawNormalFieldWithAnimation
void RenderThread::drawNormalFieldWithAnimation()
{
controller::GameController* controller = glw.getGameController();
model::GameField* field = controller->getGameField();
if (field == 0)
{
drawIdleSequence();
return;
}
//now
//get path between selected and hovered field
std::vector<model::FieldPosition> path;
if (hoveredField != selectedField && selectedField != -1 && hoveredField != -1)
{
model::FieldPosition pos1;
pos1.posX = selectedField%field->getDimensionX();
pos1.posY = selectedField / field->getDimensionX();
model::FieldPosition pos2;
pos2.posX = hoveredField % field->getDimensionX();
pos2.posY = hoveredField / field->getDimensionX();
path = field->getPath(pos1,pos2);
}
//translate into center
int translationX = field->getDimensionX()/2;
int translationY = field->getDimensionY()/2;
GLfloat dist = -9;
if (field->getDimensionX() >= field->getDimensionY())
{
dist = field->getDimensionX()*(-1);
}
else
{
dist=field->getDimensionY()*(-1);
}
//GLfloat dist = -9;
glRotatef(rotationX, 1.0, 0.0, 0.0);
glRotatef(rotationY, 0.0, 1.0, 0.0);
glRotatef(rotationZ, 0.0, 0.0, 1.0);
glTranslatef(((rotationZ*dist*(-1))/90)*(-rotationX/70),(rotationX*dist)/90, (rotationX*dist)/90);
//draw each field of the game
for (int i = 0; i< field->getDimensionX(); i++)
{
for (int j = 0; j< field->getDimensionY();j++)
{
GLfloat anima_x = 0;
GLfloat anima_y = 0;
GLfloat anima_z = 0;
GLfloat anima_size = 1;
GLfloat anima_color = 0;
calcAnimationTranslation(field,i,j,dist, &anima_x,&anima_y, &anima_z, &anima_color, &anima_size);
//encolor the field
QColor c;
if ((i % 2 == 0 && j % 2 == 0) || (i %2 == 1 && j % 2 == 1) )
{
anima_color += 0.5;
}
else
{
anima_color += 0.3;
}
c.setRedF(anima_color);
c.setGreenF(anima_color);
c.setBlueF(anima_color);
int name = j*field->getDimensionX()+i;
// highlight selected and hovered field
if(name == selectedField)
{
c = Qt::white;
}
else
{
if ((name == hoveredField && path.size() > 1) || (selectedField == -1 && hoveredField == name))
{
c=Qt::lightGray;
}
else
{
if (name == hoveredField && path.size() <= 1)
{
//.........这里部分代码省略.........
示例6: drawNormalField
void RenderThread::drawNormalField()
{
controller::GameController* controller = glw.getGameController();
model::GameField* field = controller->getGameField();
if (field == 0)
{
drawIdleSequence();
return;
}
//get path between selected and hovered field
std::vector<model::FieldPosition> path;
if (hoveredField != selectedField && selectedField != -1 && hoveredField != -1)
{
model::FieldPosition pos1;
pos1.posX = selectedField%field->getDimensionX();
pos1.posY = selectedField / field->getDimensionX();
model::FieldPosition pos2;
pos2.posX = hoveredField % field->getDimensionX();
pos2.posY = hoveredField / field->getDimensionX();
path = field->getPath(pos1,pos2);
}
//translate into center
int translationX = field->getDimensionX()/2;
int translationY = field->getDimensionY()/2;
GLfloat dist = -9;
if (field->getDimensionX() >= field->getDimensionY())
{
dist = field->getDimensionX()*(-1);
}
else
{
dist=field->getDimensionY()*(-1);
}
//GLfloat dist = -9;
glRotatef(rotationX, 1.0, 0.0, 0.0);
glRotatef(rotationY, 0.0, 1.0, 0.0);
glRotatef(rotationZ, 0.0, 0.0, 1.0);
glTranslatef(((rotationZ*dist*(-1))/90)*(-rotationX/70),(rotationX*dist)/90, (rotationX*dist)/90);
//draw each field of the game
for (int i = 0; i< field->getDimensionX(); i++)
{
for (int j = 0; j< field->getDimensionY();j++)
{
//encolor the field
QColor c;
if ((i % 2 == 0 && j % 2 == 0) || (i %2 == 1 && j % 2 == 1) )
{
c.setRedF(0.5f);
c.setGreenF(0.5f);
c.setBlueF(0.5f);
}
else
{
c.setRedF(0.3f);
c.setGreenF(0.3f);
c.setBlueF(0.3f);
}
int name = j*field->getDimensionX()+i;
// highlight selected and hovered field
if(name == selectedField)
{
c = Qt::white;
}
else
{
if ((name == hoveredField && path.size() > 1) || (selectedField == -1 && hoveredField == name))
{
c=Qt::lightGray;
}
else
{
if (name == hoveredField && path.size() <= 1)
{
c=Qt::magenta;
}
else
{
// if (!field->getBallAt(i,j).isNull && !field->getBallAt(i,j).outOfField){
// model::Ball b = field->getBallAt(i,j);
// c.setRed(b.color.getColorR());
// c.setGreen(b.color.getColorG());
// c.setBlue(b.color.getColorB());
//.........这里部分代码省略.........
示例7: SetNodeColorStyle
void VisualClusterTree::SetNodeColorStyle(const QString& style, const QColor& color)
{
Log::Inst().Debug("VisualClusterTree::SetNodeColorStyle(...)");
if(!m_activeSystem || !m_tree)
return;
if(style == "Single colour")
{
m_nodeColorStyle = VisualNode::SINGLE_COLOR;
SetNodeColor(color);
return;
}
else if(style == "Propogate continuous")
m_nodeColorStyle = VisualNode::PROPOGATE_CONTINUOUS_COLOR;
else if(style == "Propogate weighted")
m_nodeColorStyle = VisualNode::PROPOGATE_WEIGHTED_COLOR;
else if(style == "Propogate discrete")
m_nodeColorStyle = VisualNode::PROPOGATE_DISCRETE_COLOR;
// set node colors
QList<VisualNode*> postOrderNodes = m_tree->PostOrder();
if(postOrderNodes.size() == 1)
return; // there is only a root node
foreach(VisualNode* node, postOrderNodes)
{
QColor nodeColor;
if(node->IsLeaf())
{
// set color of node based on legend
Sample sample;
if(!m_activeSystem->GetSamples()->GetSample(node->GetName(), sample))
Log::Inst().Error("Invalid sample specified setting node colour: " + node->GetName());
nodeColor = sample.GetColor();
}
else
{
// set color of node based on color of children
QList<VisualNode*> children = node->GetChildren();
if(m_nodeColorStyle == VisualNode::PROPOGATE_DISCRETE_COLOR)
{
nodeColor = children.at(0)->GetColor();
for(int j = 0; j < children.size(); ++j)
{
if(children.at(j)->GetColor() != nodeColor)
nodeColor = Qt::black;
}
}
else if(m_nodeColorStyle == VisualNode::PROPOGATE_CONTINUOUS_COLOR)
{
float red = 0.0f, green = 0.0f, blue = 0.0f;
for(int j = 0; j < children.size(); ++j)
{
QColor color = children.at(j)->GetColor();
red += color.redF();
green += color.greenF();
blue += color.blueF();
}
nodeColor.setRedF(red / children.size());
nodeColor.setGreenF(green / children.size());
nodeColor.setBlueF(blue / children.size());
}
else // m_nodeColorStyle == VisualNode::PROPOGATE_WEIGHTED_COLOR
{
float red = 0.0f, green = 0.0f, blue = 0.0f;
uint totalWeight = 0;
for(int j = 0; j < children.size(); ++j)
{
uint weight = children.at(j)->GetWeightedNumberOfSeqs();
totalWeight += weight;
QColor color = children.at(j)->GetColor();
red += color.redF() * weight;
green += color.greenF() * weight;
blue += color.blueF() * weight;
}
nodeColor.setRedF(red / totalWeight);
nodeColor.setGreenF(green / totalWeight);
nodeColor.setBlueF(blue / totalWeight);
}
}
node->SetColor(nodeColor);
node->update();
}