当前位置: 首页>>代码示例>>C++>>正文


C++ QColor::redF方法代码示例

本文整理汇总了C++中QColor::redF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::redF方法的具体用法?C++ QColor::redF怎么用?C++ QColor::redF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QColor的用法示例。


在下文中一共展示了QColor::redF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: slotChangeAlpha

void QtGradientStopsControllerPrivate::slotChangeAlpha(const QColor &color)
{
    QtGradientStop *stop = m_model->currentStop();
    if (!stop)
        return;
    m_model->changeStop(stop, color);
    QList<QtGradientStop *> stops = m_model->selectedStops();
    QListIterator<QtGradientStop *> itStop(stops);
    while (itStop.hasNext()) {
        QtGradientStop *s = itStop.next();
        if (s != stop) {
            QColor c = s->color();
            if (m_ui->hsvRadioButton->isChecked()) {
                c.setHsvF(c.hueF(), c.saturationF(), c.valueF(), color.alphaF());
                int hue = c.hue();
                if (hue == 360 || hue == -1)
                    c.setHsvF(0.0, c.saturationF(), c.valueF(), c.alphaF());
            } else {
                c.setRgbF(c.redF(), c.greenF(), c.blueF(), color.alphaF());
            }
            m_model->changeStop(s, c);
        }
    }
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:24,代码来源:qtgradientstopscontroller.cpp

示例2: renderMesh

void MonoFaceShader::renderMesh(QColor meshColor,
                                QVector<QVector3D>& vertices,
                                QVector<QVector3D>& normals)
{
    if (vertices.size() != normals.size())
        throw runtime_error("vertex and normal array not same size MonoFaceShader::renderMesh");

    _program->setUniformValue(_uniforms["sourceColor"],
                  meshColor.redF(),
                  meshColor.greenF(),
                  meshColor.blueF(),
                  1.0f);

    GLuint normalAttr = _attributes["normal"];
    GLuint vertexAttr = _attributes["vertex"];

    _program->setAttributeArray(vertexAttr, vertices.constData());
    _program->setAttributeArray(normalAttr, normals.constData());
    _program->enableAttributeArray(normalAttr);
    _program->enableAttributeArray(vertexAttr);
    glDrawArrays(GL_TRIANGLES, 0, vertices.size());
    _program->disableAttributeArray(normalAttr);
    _program->disableAttributeArray(vertexAttr);
}
开发者ID:OpenScadHullModelling,项目名称:ShipCAD,代码行数:24,代码来源:shader.cpp

示例3: setColor

void GLUtils::setColor(const QColor &c)
{
    glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
}
开发者ID:phg1024,项目名称:CSCE641,代码行数:4,代码来源:glutils.cpp

示例4: QColor

ClipInformation
ClipInformation::interpolate(const ClipInformation clipInfo1,
			     const ClipInformation clipInfo2,
			     float frc)
{
  ClipInformation clipInfo;


  clipInfo.show = clipInfo1.show;
  clipInfo.applyFlip = clipInfo1.applyFlip;
  clipInfo.apply = clipInfo1.apply;
  clipInfo.imageName = clipInfo1.imageName;
  clipInfo.captionText = clipInfo1.captionText;
  clipInfo.tfSet = clipInfo1.tfSet;
  clipInfo.solidColor = clipInfo1.solidColor;
  clipInfo.showSlice = clipInfo1.showSlice;
  clipInfo.showOtherSlice = clipInfo1.showOtherSlice;
  clipInfo.showThickness = clipInfo1.showThickness;
  clipInfo.viewportType = clipInfo1.viewportType;

  // interpolate the rest
  for(int ci=0;
      ci<qMin(clipInfo1.pos.size(),
	      clipInfo2.pos.size());
      ci++)
    {
      Vec pos;
      Quaternion rot;
      pos = clipInfo1.pos[ci] + frc*(clipInfo2.pos[ci]-
				     clipInfo1.pos[ci]);
      rot = Quaternion::slerp(clipInfo1.rot[ci], clipInfo2.rot[ci], frc);

      float st, op, scl1, scl2;
      st = clipInfo1.stereo[ci] + frc*(clipInfo2.stereo[ci]-
					clipInfo1.stereo[ci]);
      op = clipInfo1.opacity[ci] + frc*(clipInfo2.opacity[ci]-
					clipInfo1.opacity[ci]);
      scl1 = clipInfo1.scale1[ci] + frc*(clipInfo2.scale1[ci]-
					 clipInfo1.scale1[ci]);
      scl2 = clipInfo1.scale2[ci] + frc*(clipInfo2.scale2[ci]-
					 clipInfo1.scale2[ci]);
      int grdx = clipInfo1.gridX[ci] + frc*(clipInfo2.gridX[ci]-
					    clipInfo1.gridX[ci]);
      int grdy = clipInfo1.gridY[ci] + frc*(clipInfo2.gridY[ci]-
					    clipInfo1.gridY[ci]);

      int frm;
      frm = clipInfo1.imageFrame[ci] + frc*(clipInfo2.imageFrame[ci]-
					    clipInfo1.imageFrame[ci]);

      Vec pcolor;
      pcolor = clipInfo1.color[ci] + frc*(clipInfo2.color[ci]-
					  clipInfo1.color[ci]);

      QVector4D vp;
      vp = clipInfo1.viewport[ci] + frc*(clipInfo2.viewport[ci]-
					 clipInfo1.viewport[ci]);

      float vps;
      vps = clipInfo1.viewportScale[ci] + frc*(clipInfo2.viewportScale[ci]-
					       clipInfo1.viewportScale[ci]);

      int thick;
      thick = clipInfo1.thickness[ci] + frc*(clipInfo2.thickness[ci]-
					     clipInfo1.thickness[ci]);

      QFont cfont = clipInfo1.captionFont[ci];
      QColor ccolor = clipInfo1.captionColor[ci];
      QColor chcolor = clipInfo1.captionHaloColor[ci];
      if (clipInfo1.captionText[ci] == clipInfo2.captionText[ci])
	{
	  QFont cfont2 = clipInfo1.captionFont[ci];

	  if (cfont.family() == cfont2.family())
	    {
	      // interpolate pointsize
	      int pt1 = cfont.pointSize();
	      int pt2 = cfont2.pointSize();
	      int pt = (1-frc)*pt1 + frc*pt2;
	      cfont.setPointSize(pt);
	    }

	  // interpolate color
	  float r1 = ccolor.redF();
	  float g1 = ccolor.greenF();
	  float b1 = ccolor.blueF();
	  float a1 = ccolor.alphaF();	  
	  QColor c = clipInfo2.captionColor[ci];
	  float r2 = c.redF();
	  float g2 = c.greenF();
	  float b2 = c.blueF();
	  float a2 = c.alphaF();	  
	  float r = (1-frc)*r1 + frc*r2;
	  float g = (1-frc)*g1 + frc*g2;
	  float b = (1-frc)*b1 + frc*b2;
	  float a = (1-frc)*a1 + frc*a2;	  	  
	  ccolor = QColor(r*255, g*255, b*255, a*255);


	  r1 = chcolor.redF();
//.........这里部分代码省略.........
开发者ID:imclab,项目名称:drishti,代码行数:101,代码来源:clipinformation.cpp

示例5: if

bool
ClipObject::processCommand(QString cmd)
{
  bool ok;
  cmd = cmd.toLower();
  QStringList list = cmd.split(" ", QString::SkipEmptyParts);
  
  if (list[0] == "mop")
    {
      if (list.size() == 2 && list[1] == "clip")
	{
	  m_mopClip = true;
	  return true;
	}
      else
	return false;
    }
  else if (list[0] == "tfset")
    {
      int tf = 1000;
      if (list.size() == 2) tf = qMax(0, list[1].toInt());
      m_tfset = tf;
      return true;
    }
  else if (list[0] == "reorientcamera")
    {
      m_reorientCamera = true;
      return true;
    }
  else if (list[0] == "color")
    {
      QColor dcolor = QColor::fromRgbF(m_color.x,
				       m_color.y,
				       m_color.z);
      QColor color = DColorDialog::getColor(dcolor);
      if (color.isValid())
	{
	  float r = color.redF();
	  float g = color.greenF();
	  float b = color.blueF();
	  m_color = Vec(r,g,b);
	}
    }
  else if (list[0] == "solidcolor")
    {
      if (list.size() == 2 &&
	  list[1] == "no")
	m_solidColor = false;
      else
	m_solidColor = true;
      return true;
    }
  else if (list[0] == "savesliceimage")
    {
      m_resliceSubsample = 1;
      m_saveSliceImage = true;
      if (list.size() == 2) m_resliceSubsample = qMax(1, list[1].toInt(&ok));
      return true;
    }
  else if (list[0] == "reslice")
    {
      m_resliceSubsample = 1;
      m_resliceTag = -1;
      m_resliceVolume = true;
      if (list.size() > 1) m_resliceSubsample = qMax(1, list[1].toInt(&ok));
      if (list.size() > 2) m_resliceTag = list[2].toInt(&ok);
      return true;
    }
  else if (list[0] == "grid")
    {
      if (list.size() == 1)
	{
	  m_gridX = m_gridY = 10;
	}
      else if (list.size() == 2 && list[1] == "no")
	{
	  m_gridX = m_gridY = 0;
	}
      else if (list.size() == 3)
	{
	  m_gridX = list[1].toInt();
	  m_gridY = list[2].toInt();
	}
      return true;
    }
  else if (list[0] == "image")
    {
      if (list.size() == 2 &&
	  list[1] == "no")
	clearImage();
      else
	loadImage();
      return true;
    }
  else if (list[0] == "imageframe")
    {
      if (list.size() == 2)
	{
	  int frm = list[1].toInt(&ok);
	  if (frm >= 0)
//.........这里部分代码省略.........
开发者ID:Elavina6,项目名称:drishti,代码行数:101,代码来源:clipobject.cpp

示例6: luma

qreal KHCY::luma(const QColor &color)
{
    return lumag(gamma(color.redF()),
                 gamma(color.greenF()),
                 gamma(color.blueF()));
}
开发者ID:KDE,项目名称:kguiaddons,代码行数:6,代码来源:kcolorspaces.cpp

示例7: mask_slot

void Mask::mask_slot(){
    int countSel = gsri->countSelected();
    GObjectInterface *iObj, *endObj=gsri->selected(gsri->countSelected()-1);//создаём контейнер с выделенными рамкой объектами
    qreal k_h, k_w, width_iObj, width_endObj = endObj->boundingRect().width(),
    height_iObj, height_endObj = endObj->boundingRect().height();
    QBrush endObjBrush = endObj->brush();
    if(endObjBrush.style() == Qt::RadialGradientPattern
            || endObjBrush.style() == Qt::ConicalGradientPattern
                || endObjBrush.style() == Qt::LinearGradientPattern){
        for (int i=0; i<countSel-1; i++){
            iObj = gsri->selected(i);
            QBrush inters = iObj->brush();
            qreal iObjAlpha = inters.color().alphaF();
            QGradient qg = *endObjBrush.gradient();
            height_iObj = iObj->boundingRect().height();
            width_iObj = iObj->boundingRect().width();
            k_h = height_endObj/height_iObj;//считаем коэффициенты пропорциональности фигур для умножения-->
            k_w = width_endObj/width_iObj;//-->на точки градиента(чтобы градиенты не зависели от размеров фигур).

            int d_x = iObj->boundingRect().x() - endObj->boundingRect().x();//вычисляем расстояния между левыми краями фигур
            int d_y = iObj->boundingRect().y() - endObj->boundingRect().y();
            qreal k_shift_x = ( d_x / width_endObj) * k_w,//вычисляем коэффициенты сдвига градиента по ширине-->
                    k_shift_y = (d_y / height_endObj) * k_h;//--> и по высотке

            QGradientStops grStops(qg.stops());//копируем точки/цвета задаваемого градиента.

            QColor BrushColor = inters.gradient()->stops()[0].second;

            for(int j=0; j<grStops.count(); j++){
                grStops[j].second.setRgbF( BrushColor.redF(), BrushColor.greenF(), BrushColor.blueF(),
                                           grStops[j].second.alphaF()*iObjAlpha);
            }

            if(qg.type() == QGradient::LinearGradient){
                QLinearGradient qlg = *static_cast<const QLinearGradient *>(endObjBrush.gradient());
                QLinearGradient qlgLinear(qlg.start().x() * k_w - k_shift_x, qlg.start().y() * k_h - k_shift_y,
                                         qlg.finalStop().x() * k_w - k_shift_x, qlg.finalStop().y() * k_h - k_shift_y);
                qlgLinear.setStops(grStops);
                iObj->setBrush(qlgLinear);
            }

            if(qg.type() == QGradient::RadialGradient){
                for(int j=0; j<grStops.count(); j++)
                    grStops[j].first *= k_w;
                QRadialGradient qlg = *static_cast<const QRadialGradient *>(endObjBrush.gradient());
                QRadialGradient qlgRadial(QPointF(qlg.center().x()*k_w - k_shift_x, qlg.center().y()*k_h - k_shift_y),
                     qlg.radius(), QPointF(qlg.focalPoint().x()*k_w - k_shift_x, qlg.focalPoint().y()*k_h - k_shift_y),
                     qlg.focalRadius());
                qlgRadial.setStops(grStops);
                iObj->setBrush(qlgRadial);
            }

            if(qg.type() == QGradient::ConicalGradient){
                QConicalGradient qlg = *static_cast<const QConicalGradient *>(endObjBrush.gradient());
                QConicalGradient qlgConical(QPointF(qlg.center().x()*k_w - k_shift_x, qlg.center().y()*k_h - k_shift_y),
                                          qlg.angle());
                qlgConical.setStops(grStops);
                iObj->setBrush(qlgConical);
            }
        }
        endObj->setVisible(false);
    }
    else{
        QMessageBox m;
        m.setText(tr("upper figure does not contain a gradient"));
        m.exec();
    }
    gsri->reset();

}
开发者ID:5Y5TEM,项目名称:MultiFusion,代码行数:70,代码来源:Mask.cpp

示例8: SetColor

void SurfaceROI::SetColor( const QColor& color )
{
  m_color = color;
  m_actorOutline->GetProperty()->SetColor( color.redF(), color.greenF(), color.blueF() );
  emit ColorChanged( color );
}
开发者ID:ewong718,项目名称:freesurfer,代码行数:6,代码来源:SurfaceROI.cpp

示例9: setSpecularColour

void Viewer::setSpecularColour(const QColor& c) {
  sphereShaders.setUniformValue(specularColourLoc, c.redF(), c.greenF(), c.blueF());
}
开发者ID:WalrusCow,项目名称:gfx,代码行数:3,代码来源:Viewer.cpp

示例10: render

void Renderer::render(xqtgl::window* const  surface, xqtgl::opengl_api* const f)
{
    QColor color = QColor(100, 255, 0);

    QSize viewSize = surface->size();

    f->glViewport(0, 0, viewSize.width() * surface->devicePixelRatio(), viewSize.height() * surface->devicePixelRatio());
    f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    f->glClearColor(m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), m_backgroundColor.alphaF());
    f->glFrontFace(GL_CW);
    f->glCullFace(GL_FRONT);
    f->glEnable(GL_CULL_FACE);
    f->glEnable(GL_DEPTH_TEST);

    std::vector<GLchar const*> const vshader_lines = {
        "#version 420\n",
        "in vec4  vertex;\n",
        "void main(void)\n",
        "{\n",
        "    gl_Position = vertex;\n",
        "}\n",
    };
    GLuint const  vshader = f->glCreateShader(GL_VERTEX_SHADER);
    f->glShaderSource(vshader, (GLsizei)vshader_lines.size(), (GLchar const**)&vshader_lines.at(0), nullptr);
    f->glCompileShader(vshader);
    GLuint const  vshader_program = f->glCreateProgram();
    f->glProgramParameteri(vshader_program, GL_PROGRAM_SEPARABLE, GL_TRUE);
    f->glAttachShader(vshader_program, vshader);
    f->glLinkProgram(vshader_program);
    f->glDetachShader(vshader_program, vshader);
    f->glDeleteShader(vshader);

    std::vector<GLchar const*> const fshader_lines = {
        "#version 420\n",
        "out vec4  out_colour;\n",
        "void main(void)\n",
        "{\n",
        "    out_colour = vec4(1.0f, 1.0f, 1.0f, 1.0f);\n",
        "}\n",
    };
    GLuint const  fshader = f->glCreateShader(GL_FRAGMENT_SHADER);
    f->glShaderSource(fshader, (GLsizei)fshader_lines.size(), (GLchar const**)&fshader_lines.at(0), nullptr);
    f->glCompileShader(fshader);
    GLuint const  fshader_program = f->glCreateProgram();
    f->glProgramParameteri(fshader_program, GL_PROGRAM_SEPARABLE, GL_TRUE);
    f->glAttachShader(fshader_program, fshader);
    f->glLinkProgram(fshader_program);
    f->glDetachShader(fshader_program, fshader);
    f->glDeleteShader(fshader);

    GLuint  pipeline_id = 0;
    f->glGenProgramPipelines(1U, &pipeline_id);
    f->glUseProgramStages(pipeline_id, GL_VERTEX_SHADER_BIT, vshader_program);
    f->glUseProgramStages(pipeline_id, GL_FRAGMENT_SHADER_BIT, fshader_program);
    f->glBindProgramPipeline(pipeline_id);

    GLint const  vdata_position = f->glGetAttribLocation(vshader_program, "vertex");

    std::array<float_32_bit, 12> const  vbuffer_data = {
            0.0f, 0.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
    };

    GLuint  vbuffer_id = 0U;
    f->glGenBuffers(1U, &vbuffer_id);
    f->glBindBuffer(GL_ARRAY_BUFFER, vbuffer_id);
    f->glBufferData(GL_ARRAY_BUFFER,
                    (GLsizeiptr)(vbuffer_data.size() * sizeof(float_32_bit)),
                    (GLvoid const*)vbuffer_data.data(),
                    GL_STATIC_DRAW);

    GLuint  barrays_id = 0;
    f->glGenVertexArrays(1U, &barrays_id);
    f->glBindVertexArray(barrays_id);

    f->glBindBuffer(GL_ARRAY_BUFFER, vbuffer_id);
    f->glEnableVertexAttribArray(vdata_position);
    f->glVertexAttribPointer(
            vdata_position,
            4,
            GL_FLOAT,
            GL_FALSE,
            0U,
            nullptr
            );

    f->glBindVertexArray(barrays_id);

    f->glDrawArrays(GL_TRIANGLES, 0, 3);

    f->glBindProgramPipeline(0);
    f->glBindVertexArray(0);

    f->glDeleteVertexArrays(1U, &barrays_id);
    f->glDeleteBuffers(1U, &vbuffer_id);

    f->glDeleteProgramPipelines(1, &pipeline_id);
    f->glDeleteProgram(vshader_program);
//.........这里部分代码省略.........
开发者ID:trtikm,项目名称:E2,代码行数:101,代码来源:run.cpp

示例11:

bool operator<(const QColor & a, const QColor & b) {
   return a.redF() < b.redF()
       || a.greenF() < b.greenF()
       || a.blueF() < b.blueF()
       || a.alphaF() < b.alphaF();
}
开发者ID:baidut,项目名称:ITS,代码行数:6,代码来源:roaddrawer.cpp

示例12: calculateSpecmap

QImage SpecularmapGenerator::calculateSpecmap(QImage input, double scale, double contrast) {
    QImage result(input.width(), input.height(), QImage::Format_ARGB32);

    //generate contrast lookup table
    unsigned short contrastLookup[256];
    double newValue = 0;

    for(int i = 0; i < 256; i++) {
        newValue = (double)i;
        newValue /= 255.0;
        newValue -= 0.5;
        newValue *= contrast;
        newValue += 0.5;
        newValue *= 255;

        if(newValue < 0)
            newValue = 0;
        if(newValue > 255)
            newValue = 255;

        contrastLookup[i] = (unsigned short)newValue;
    }

    #pragma omp parallel for  // OpenMP
    //for every row of the image
    for(int y = 0; y < result.height(); y++) {
        QRgb *scanline = (QRgb*) result.scanLine(y);

        //for every column of the image
        for(int x = 0; x < result.width(); x++) {
            double r, g, b, a;
            double intensity = 0.0;

            QColor pxColor = QColor(input.pixel(x, y));

            r = pxColor.redF() * redMultiplier;
            g = pxColor.greenF() * greenMultiplier;
            b = pxColor.blueF() * blueMultiplier;
            a = pxColor.alphaF() * alphaMultiplier;

            if(mode == IntensityMap::AVERAGE) {
                //take the average out of all selected channels
                double multiplierSum = (redMultiplier + greenMultiplier + blueMultiplier + alphaMultiplier);

                if(multiplierSum == 0.0)
                    multiplierSum = 1.0;

                intensity = (r + g + b + a) / multiplierSum;
            }
            else if(mode == IntensityMap::MAX) {
                //take the maximum out of all selected channels
                double tempMaxRG = std::max(r, g);
                double tempMaxBA = std::max(b, a);
                intensity = std::max(tempMaxRG, tempMaxBA);
            }

            //apply scale (brightness)
            intensity *= scale;

            if(intensity > 1.0)
                intensity = 1.0;

            //convert intensity to the 0-255 range
            int c = (int)(255.0 * intensity);

            //apply contrast
            c = (int)contrastLookup[c];

            //write color into image pixel
            scanline[x] = qRgba(c, c, c, pxColor.alpha());
        }
    }

    return result;
}
开发者ID:voyager25,项目名称:NormalmapGenerator,代码行数:75,代码来源:specularmapgenerator.cpp

示例13: toRGB

RGB toRGB(QColor& col){
    return RGB(col.redF(), col.greenF(), col.blueF());
}
开发者ID:mogonen,项目名称:Shady-2.5D,代码行数:3,代码来源:ISExporter.cpp

示例14: setUniformVariable

void ShaderLibrary::setUniformVariable(GLuint /*program*/, GLint location, QColor const& color)
{
   glUniform4f(location, color.redF(), color.greenF(), color.blueF(), 
      color.alphaF()); 
}
开发者ID:epifanovsky,项目名称:IQmol,代码行数:5,代码来源:ShaderLibrary.C

示例15: p

void
ScaleSliderQWidget::paintEvent(QPaintEvent* /*e*/)
{
    if (_imp->mustInitializeSliderPosition) {
        centerOn(_imp->minimum, _imp->maximum);
        _imp->mustInitializeSliderPosition = false;
        seekScalePosition(_imp->value);
        _imp->initialized = true;
    }

    ///fill the background with the appropriate style color
    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);

    double txtR,txtG,txtB;
    appPTR->getCurrentSettings()->getTextColor(&txtR, &txtG, &txtB);
    QColor textColor;
    textColor.setRgbF(Natron::clamp(txtR), Natron::clamp(txtG), Natron::clamp(txtB));
    
    QColor scaleColor;
    scaleColor.setRgbF(textColor.redF() / 2., textColor.greenF() / 2., textColor.blueF() / 2.);
    
    QFontMetrics fontM(*_imp->font);
    p.setPen(scaleColor);

    QPointF btmLeft = _imp->zoomCtx.toZoomCoordinates(0,height() - 1);
    QPointF topRight = _imp->zoomCtx.toZoomCoordinates(width() - 1, 0);

    if ( btmLeft.x() == topRight.x() ) {
        return;
    }

    /*drawing X axis*/
    double lineYpos = height() - 1 - fontM.height()  - TICK_HEIGHT / 2;
    p.drawLine(0, lineYpos, width() - 1, lineYpos);

    double tickBottom = _imp->zoomCtx.toZoomCoordinates( 0,height() - 1 - fontM.height() ).y();
    double tickTop = _imp->zoomCtx.toZoomCoordinates(0,height() - 1 - fontM.height()  - TICK_HEIGHT).y();
    const double smallestTickSizePixel = 5.; // tick size (in pixels) for alpha = 0.
    const double largestTickSizePixel = 1000.; // tick size (in pixels) for alpha = 1.
    std::vector<double> acceptedDistances;
    acceptedDistances.push_back(1.);
    acceptedDistances.push_back(5.);
    acceptedDistances.push_back(10.);
    acceptedDistances.push_back(50.);
    const double rangePixel =  width();
    const double range_min = btmLeft.x();
    const double range_max =  topRight.x();
    const double range = range_max - range_min;
    double smallTickSize;
    bool half_tick;
    ticks_size(range_min, range_max, rangePixel, smallestTickSizePixel, &smallTickSize, &half_tick);
    int m1, m2;
    const int ticks_max = 1000;
    double offset;
    ticks_bounds(range_min, range_max, smallTickSize, half_tick, ticks_max, &offset, &m1, &m2);
    std::vector<int> ticks;
    ticks_fill(half_tick, ticks_max, m1, m2, &ticks);
    const double smallestTickSize = range * smallestTickSizePixel / rangePixel;
    const double largestTickSize = range * largestTickSizePixel / rangePixel;
    const double minTickSizeTextPixel = fontM.width( QString("00") ); // AXIS-SPECIFIC
    const double minTickSizeText = range * minTickSizeTextPixel / rangePixel;
    for (int i = m1; i <= m2; ++i) {
        double value = i * smallTickSize + offset;
        const double tickSize = ticks[i - m1] * smallTickSize;
        const double alpha = ticks_alpha(smallestTickSize, largestTickSize, tickSize);
        QColor color(textColor);
        color.setAlphaF(alpha);
        QPen pen(color);
        pen.setWidthF(1.9);
        p.setPen(pen);

        QPointF tickBottomPos = _imp->zoomCtx.toWidgetCoordinates(value, tickBottom);
        QPointF tickTopPos = _imp->zoomCtx.toWidgetCoordinates(value, tickTop);

        p.drawLine(tickBottomPos,tickTopPos);

        bool renderText = _imp->dataType == eDataTypeDouble || std::abs(std::floor(0.5 + value) - value) == 0.;
        if (renderText && tickSize > minTickSizeText) {
            const int tickSizePixel = rangePixel * tickSize / range;
            const QString s = QString::number(value);
            const int sSizePixel =  fontM.width(s);
            if (tickSizePixel > sSizePixel) {
                const int sSizeFullPixel = sSizePixel + minTickSizeTextPixel;
                double alphaText = 1.0; //alpha;
                if (tickSizePixel < sSizeFullPixel) {
                    // when the text size is between sSizePixel and sSizeFullPixel,
                    // draw it with a lower alpha
                    alphaText *= (tickSizePixel - sSizePixel) / (double)minTickSizeTextPixel;
                }
                QColor c = _imp->readOnly || !isEnabled() ? Qt::black : textColor;
                c.setAlphaF(alphaText);
                p.setFont(*_imp->font);
                p.setPen(c);

                QPointF textPos = _imp->zoomCtx.toWidgetCoordinates( value, btmLeft.y() );

                p.drawText(textPos, s);
//.........这里部分代码省略.........
开发者ID:gobomus,项目名称:Natron,代码行数:101,代码来源:ScaleSliderQWidget.cpp


注:本文中的QColor::redF方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。