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


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

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


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

示例1: updateTooltip

void QgsColorSwatchGrid::updateTooltip( const int colorIdx )
{
  if ( colorIdx >= 0 && colorIdx < mColors.length() )
  {
    //if color has an associated name from the color scheme, use that
    QString colorName = mColors.at( colorIdx ).second;
    if ( colorName.isEmpty() )
    {
      //otherwise, build a default string
      QColor color = mColors.at( colorIdx ).first;
      colorName = QString( tr( "rgb(%1, %2, %3)" ) ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
    }
    setToolTip( colorName );
  }
  else
  {
    //clear tooltip
    setToolTip( QString() );
  }
}
开发者ID:Gustry,项目名称:QGIS,代码行数:20,代码来源:qgscolorswatchgrid.cpp

示例2: directory


//.........这里部分代码省略.........
        // Check object start position
        QString pos = objectParams.at(1);
        if (!pos.contains(QRegExp("^(\\d)+;(\\d)+$")) && pos != QString("-1;-1")) {
            qDebug() << "Invalid start position (object" << obj << ")";
            return *environment;
        }
        int x, y;
        if (pos != QString("-1;-1"))
        {
            x = pos.split(";").at(0).toInt(&ok);
            if (!ok) {
                qDebug() << "Invalid start position (object" << obj << ")";
                return *environment;
            }
            y = pos.split(";").at(1).toInt(&ok);
            if (!ok) {
                qDebug() << "Invalid start position (object" << obj << ")";
                return *environment;
            }
            if (x < 0 || y < 0
                    || x >= mapSize.first * REAL_PIXEL_SIZE
                    || y >= mapSize.second * REAL_PIXEL_SIZE) {
                qDebug() << "Start position is out of the map (object" << obj << ")";
                return *environment;
            }
        } else {
            /*
            srand(static_cast<unsigned int>(time(0)));
            x = rand() % (mapSize.first * REAL_PIXEL_SIZE);
            y = rand() % (mapSize.second * REAL_PIXEL_SIZE);
            qDebug() << "Object" << obj << "receives random coordinates (" << x << "," << y << ")";
            */
            // coordinates must be generated in the environment app
            x = 0;
            y = 0;
        }

        // Check if size is a number and is over than zero
        int size = objectParams.at(2).toInt();
        if (size <= 0) {
            qDebug() << "Invalid size (object" << obj << ")";
            return *environment;
        }

        // Check intersection type
        QString intersection = objectParams.at(3);
        if (intersection != "0" && intersection != "1" && intersection != "2") {
            qDebug() << "Invalid intersection type (object" << obj << ")";
            return *environment;
        }

        bool movable;
        if (objectParams.at(4) == QString("0"))
            movable = false;
        else if (objectParams.at(4) == QString("1"))
            movable = true;
        else {
            qDebug() << "Movable parameter can receive only 0 or 1 (object" << obj << ")";
            return *environment;
        }

        // Check orientation
        int orientation = objectParams.at(5).toDouble(&ok);
        if (!ok || orientation < 0) {
            qDebug() << "Invalid orientation (object" << obj << ")";
            return *environment;
        }

        int velocity = objectParams.at(6).toInt();
        if (velocity <= 0) {
            qDebug() << "Invalid velocity (object" << obj << ")";
            return *environment;
        }

        // Check color
        QColor color = QColor(objectParams.at(7));
        if (!color.isValid()) {
            qDebug() << "Invalid color (object" << obj << ")";
            return *environment;
        }

        indexes.push_back(index);
        envObject->setObjectId(index);
        envObject->setCoords(x, y);
        envObject->setSize(size);
        envObject->setIntersection(static_cast<Intersection>(intersection.toInt()));
        envObject->setMovable(movable);
        envObject->setOrientation(orientation);
        envObject->setVelocity(velocity);
        envObject->setColor(Color(color.red(), color.green(), color.blue()));
        environment->push_back(envObject);
    }

    QString command = configStringList.at(0) + QString(" ") + configFilename + QString(" ")
            + QString("%1").arg(mapSize.first) + QString(" ") + QString("%1").arg(mapSize.second);
    qDebug() << "Environment will be called by command" << command;
    //ProcessContainer::getInstance().addApplication(command);

    return *environment;
}
开发者ID:SmirnoffYM,项目名称:AI-simulator,代码行数:101,代码来源:servant.cpp

示例3: if

QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle  const & extent, int width, int height )
{
  QgsRasterBlock *outputBlock = new QgsRasterBlock();
  if ( !mInput || mNColors == 0 )
  {
    return outputBlock;
  }

  QgsRasterBlock *inputBlock = mInput->block( bandNo, extent, width, height );

  if ( !inputBlock || inputBlock->isEmpty() )
  {
    QgsDebugMsg( "No raster data!" );
    delete inputBlock;
    return outputBlock;
  }

  double currentOpacity = mOpacity;

  //rendering is faster without considering user-defined transparency
  bool hasTransparency = usesTransparency();
  QgsRasterBlock *alphaBlock = nullptr;

  if ( mAlphaBand > 0 && mAlphaBand != mBand )
  {
    alphaBlock = mInput->block( mAlphaBand, extent, width, height );
    if ( !alphaBlock || alphaBlock->isEmpty() )
    {
      delete inputBlock;
      delete alphaBlock;
      return outputBlock;
    }
  }
  else if ( mAlphaBand == mBand )
  {
    alphaBlock = inputBlock;
  }

  if ( !outputBlock->reset( QGis::ARGB32_Premultiplied, width, height ) )
  {
    delete inputBlock;
    delete alphaBlock;
    return outputBlock;
  }

  QRgb myDefaultColor = NODATA_COLOR;

  //use direct data access instead of QgsRasterBlock::setValue
  //because of performance
  unsigned int* outputData = ( unsigned int* )( outputBlock->bits() );

  qgssize rasterSize = ( qgssize )width * height;
  for ( qgssize i = 0; i < rasterSize; ++i )
  {
    if ( inputBlock->isNoData( i ) )
    {
      outputData[i] = myDefaultColor;
      continue;
    }
    int val = ( int ) inputBlock->value( i );
    if ( !hasTransparency )
    {
      outputData[i] = mColors[val];
    }
    else
    {
      currentOpacity = mOpacity;
      if ( mRasterTransparency )
      {
        currentOpacity = mRasterTransparency->alphaValue( val, mOpacity * 255 ) / 255.0;
      }
      if ( mAlphaBand > 0 )
      {
        currentOpacity *=  alphaBlock->value( i ) / 255.0;
      }
      QColor currentColor = QColor( mColors[val] );
      outputData[i] = qRgba( currentOpacity * currentColor.red(), currentOpacity * currentColor.green(), currentOpacity * currentColor.blue(), currentOpacity * 255 );
    }
  }

  delete inputBlock;
  if ( mAlphaBand > 0 && mBand != mAlphaBand )
  {
    delete alphaBlock;
  }

  return outputBlock;
}
开发者ID:Benardi-atmadja,项目名称:QGIS,代码行数:88,代码来源:qgspalettedrasterrenderer.cpp

示例4: setCurrentPage

void KviTalWizard::setCurrentPage(KviTalWizardPageData * pData)
{
    m_p->pCurrentPage = pData;

    bool bCancelEnabled = true;
    bool bNextEnabled = false;
    bool bBackEnabled = false;
    bool bHelpEnabled = false;
    bool bFinishEnabled = false;

    QString szTitle;
    QString szSteps;

    bool bHaveNextPage = false;
    bool bHavePrevPage = false;

    if(pData)
    {
        bHavePrevPage = m_p->findPrevEnabledPage(pData->pWidget);
        bHaveNextPage = m_p->findNextEnabledPage(pData->pWidget);

        bNextEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableNext) && bHaveNextPage;
        bBackEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableBack) && bHavePrevPage;

        bCancelEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableCancel);
        bFinishEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableFinish);

        bHelpEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableHelp);

        m_p->pWidgetStack->setCurrentWidget(pData->pWidget);

        szTitle = "<b>";
        szTitle += pData->szTitle;
        szTitle += "</b>";
        QPalette pal = m_p->pStepsLabel->palette();
        QColor clrWin = pal.color(QPalette::Normal, QPalette::Window);
        QColor clrTxt = pal.color(QPalette::Normal, QPalette::WindowText);
        QColor clrMid = qRgb(
                            (clrWin.red() + clrTxt.red()) / 2,
                            (clrWin.green() + clrTxt.green()) / 2,
                            (clrWin.blue() + clrTxt.blue()) / 2);

        szSteps = "<font color=\"";
        szSteps += clrMid.name();
        szSteps += "\"><b>[";
        szSteps += QString("Step %1 of %2").arg(pData->iVisibleIndex).arg(m_p->iEnabledPageCount);
        szSteps += "]</b></font>";
    }

    m_p->pTitleLabel->setText(szTitle);
    m_p->pStepsLabel->setText(szSteps);

    m_p->pNextButton->setEnabled(bNextEnabled);
    if(bHaveNextPage)
    {
        m_p->pNextButton->show();
        m_p->pNextSpacer->show();
        m_p->pNextButton->setDefault(true);
    }
    else
    {
        m_p->pNextButton->hide();
        m_p->pNextSpacer->hide();
        m_p->pNextButton->setDefault(false);
    }

    m_p->pBackButton->setEnabled(bBackEnabled);
    if(bHavePrevPage)
        m_p->pBackButton->show();
    else
        m_p->pBackButton->hide();

    m_p->pHelpButton->setEnabled(bHelpEnabled);
    if(bHelpEnabled)
        m_p->pHelpButton->show();
    else
        m_p->pHelpButton->hide();

    m_p->pCancelButton->setEnabled(bCancelEnabled);
    m_p->pFinishButton->setEnabled(bFinishEnabled);

    if(bFinishEnabled)
    {
        m_p->pFinishButton->show();
        m_p->pFinishSpacer->show();
        m_p->pFinishButton->setDefault(true);
    }
    else
    {
        m_p->pFinishButton->hide();
        m_p->pFinishSpacer->hide();
        m_p->pFinishButton->setDefault(false);
    }
}
开发者ID:kvirc,项目名称:KVIrc,代码行数:94,代码来源:KviTalWizard.cpp

示例5: qWarning

void
KdeIni::setValue(const QString &key, const QVariant &value)
{
   if (localGroup == local.end()) {
      qWarning("KdeIni::setValue(): You must first set a group!");
      return;
   }
   QString val;
   switch(value.type()) {
   case QVariant::Color: {
      QColor c = value.value<QColor>();
      val = QString::number( c.red() ) + ',' + QString::number( c.green() ) + ',' + QString::number( c.blue() );
      break;
   }
   default:
      val = value.toString();
   }
   (*localGroup)[key] = val;
}
开发者ID:thibautquentinjacob,项目名称:BespinMod,代码行数:19,代码来源:kdeini.cpp

示例6: setSpecularColor

void SpotLight::setSpecularColor(QColor color)
{
    specular_light = new Vec4((float)color.red()/255.0,(float)color.green()/255.0,(float)color.blue()/255.0);
}
开发者ID:danilob,项目名称:SceneBuild,代码行数:4,代码来源:spotlight.cpp

示例7: QColor

std::vector<Eigen::Vector3f> ImageReader::toVector(){
    std::vector<Eigen::Vector3f> output;
    for (int i = 0; i < getImageHeight(); i++) {
        for (int j = 0; j < getImageWidth(); j++) {
            QColor pixelColor = QColor(pixelAt(i,j));
            Eigen::Vector3f color = Eigen::Vector3f(float(pixelColor.red()), float(pixelColor.green()), float(pixelColor.blue()));
            output.push_back(color);
        }
    }
    return output;
}
开发者ID:nlindsay19,项目名称:ReallyRealFinal,代码行数:11,代码来源:imagereader.cpp

示例8:

void v3dViewFiberInteractor::validateSelection(const QString &name, const QColor &color)
{
    if (!d->data)
        return;

    double color_d[3] = {(double)color.red()/255.0, (double)color.green()/255.0, (double)color.blue()/255.0};

    d->manager->Validate (name.toAscii().constData(), color_d);

    d->view->renderer2d()->AddActor (d->manager->GetBundleActor(name.toAscii().constData()));

    d->data->addMetaData("BundleList", name);
    d->data->addMetaData("BundleColorList", color.name());

    // reset to initial navigation state
    d->manager->Reset();
    d->view->update();
}
开发者ID:gpasquie,项目名称:medInria-public,代码行数:18,代码来源:v3dViewFiberInteractor.cpp

示例9: fft

void fft(int squareSize, QImage *myImage, QImage *myImageMag, QImage *myImagePhase)
{
    fftw_plan planR, planG, planB;
    fftw_complex *inR, *inG, *inB, *outR, *outG, *outB;
    QColor tempColor;
    int tempCounter = 0;
    double realR, realG, realB,
            imagR, imagG, imagB,
            magR, magG, magB,
            phaseR, phaseG, phaseB,
            magRMax, magGMax, magBMax;


    //    -----------------------------------------------
    //
    //    Alokacja wektorów i egzekucja FFT.
    //
    //    -----------------------------------------------

    inR = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * squareSize * squareSize);
    inG = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * squareSize * squareSize);
    inB = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * squareSize * squareSize);

    outR = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * squareSize * squareSize);
    outG = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * squareSize * squareSize);
    outB = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * squareSize * squareSize);

    planG = fftw_plan_dft_2d(squareSize, squareSize, inG, outG, FFTW_FORWARD, FFTW_ESTIMATE);
    planB = fftw_plan_dft_2d(squareSize, squareSize, inB, outB, FFTW_FORWARD, FFTW_ESTIMATE);
    planR = fftw_plan_dft_2d(squareSize, squareSize, inR, outR, FFTW_FORWARD, FFTW_ESTIMATE);

    for(int i=0; i < squareSize; i++)
    {
        for(int j=0; j < squareSize; j++)
        {
            tempColor.setRgb(myImage->pixel(i, j));
            inR[tempCounter][0] = (double)tempColor.red();
            inG[tempCounter][0] = (double)tempColor.green();
            inB[tempCounter][0] = (double)tempColor.blue();

            tempCounter++;
        }
    }

    fftw_execute(planR);
    fftw_execute(planG);
    fftw_execute(planB);

    //    -----------------------------------------------
    //
    //    Normalizacja wartosci amplitudy FFT
    //
    //    -----------------------------------------------

    tempCounter = 0;
    for(int i=0; i < squareSize * squareSize; i++)
    {
        realR = outR[tempCounter][0] / (double)(squareSize * squareSize);
        imagR = outR[tempCounter][1] / (double)(squareSize * squareSize);

        realG = outG[tempCounter][0] / (double)(squareSize * squareSize);
        imagG = outG[tempCounter][1] / (double)(squareSize * squareSize);

        realB = outB[tempCounter][0] / (double)(squareSize * squareSize);
        imagB = outB[tempCounter][1] / (double)(squareSize * squareSize);

        magR = sqrt((realR * realR) + (imagR * imagR));
        magG = sqrt((realG * realG) + (imagG * imagG));
        magB = sqrt((realB * realB) + (imagB * imagB));

        if(i > 0)
        {
            magRMax = (magR > magRMax ? magR : magRMax);
            magGMax = (magG > magGMax ? magG : magGMax);
            magBMax = (magB > magBMax ? magB : magBMax);
        }

        tempCounter++;
    }

    //    -----------------------------------------------
    //
    //    Wyznaczenie amplitudy i fazy
    //
    //    -----------------------------------------------

    tempCounter = 0;
    for(int i=0; i < squareSize; i++)
    {
        for(int j=0; j < squareSize; j++)
        {

            realR = outR[tempCounter][0] / (double)(squareSize * squareSize);
            imagR = outR[tempCounter][1] / (double)(squareSize * squareSize);

            realG = outG[tempCounter][0] / (double)(squareSize * squareSize);
            imagG = outG[tempCounter][1] / (double)(squareSize * squareSize);

            realB = outB[tempCounter][0] / (double)(squareSize * squareSize);
            imagB = outB[tempCounter][1] / (double)(squareSize * squareSize);
//.........这里部分代码省略.........
开发者ID:Hariver,项目名称:POID,代码行数:101,代码来源:main.cpp

示例10: setBorderColor

/*!
  Set the outline
  */
void QgsRubberBand::setBorderColor( const QColor & color )
{
  QColor penColor( color.red(), color.green(), color.blue(), color.alpha() );
  mPen.setColor( penColor );
}
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:8,代码来源:qgsrubberband.cpp

示例11: transferFromDialogCurrent

void ossimQtVectorEditorDialogController::transferFromDialogCurrent()
{
  if((theCurrentFeatureIdx >= 0)&&
     (theCurrentFeatureIdx < (int)theFeatureInfoList.size())&&
     (theDialog))
    {
      switch(theFeatureInfoList[theCurrentFeatureIdx].theFeatureType)
	{
	case ossimQtVectorEditorFeatureInfoType_POINT:
	  {
	    stringstream radiusStream(theDialog->thePointRadiusInput->text().ascii());
	    
	    radiusStream >> theFeatureInfoList[theCurrentFeatureIdx].thePointRadius.x
			 >> theFeatureInfoList[theCurrentFeatureIdx].thePointRadius.y;
	    
             theFeatureInfoList[theCurrentFeatureIdx].theEnabledFlag = theDialog->thePointEnabledCheckBox->isChecked();
             theFeatureInfoList[theCurrentFeatureIdx].theFillFlag  = theDialog->thePointFilledCheckBox->isChecked();
             QColor qColor = theDialog->thePointColorFrame->paletteBackgroundColor();
             ossimRgbVector color(qColor.red(),
                                  qColor.green(),
                                  qColor.blue());
             theFeatureInfoList[theCurrentFeatureIdx].theColor = color;
             break;
	  }
	case ossimQtVectorEditorFeatureInfoType_LINE:
	  {
 	    theFeatureInfoList[theCurrentFeatureIdx].theEnabledFlag = theDialog->theLineEnabledCheckBox->isChecked();
	    QColor qColor = theDialog->theLineColorFrame->paletteBackgroundColor();
	    ossimRgbVector color(qColor.red(),
				 qColor.green(),
				 qColor.blue());
	    theFeatureInfoList[theCurrentFeatureIdx].theColor = color;
            theFeatureInfoList[theCurrentFeatureIdx].theThickness = theDialog->theLineThicknessInput->value();
	    break;
	  }
	case ossimQtVectorEditorFeatureInfoType_POLYGON:
	  {
             theFeatureInfoList[theCurrentFeatureIdx].theEnabledFlag = theDialog->thePolygonEnabledCheckBox->isChecked();
             theFeatureInfoList[theCurrentFeatureIdx].theFillFlag  = theDialog->thePolygonFilledCheckBox->isChecked();
             QColor qColor = theDialog->thePolygonColorFrame->paletteBackgroundColor();
             ossimRgbVector color(qColor.red(),
                                  qColor.green(),
                                  qColor.blue());
             theFeatureInfoList[theCurrentFeatureIdx].theColor = color;
             theFeatureInfoList[theCurrentFeatureIdx].theThickness = theDialog->thePolygonThicknessInput->value();
	    break;
	  }
	case ossimQtVectorEditorFeatureInfoType_TEXT:
	  {
 	    theFeatureInfoList[theCurrentFeatureIdx].theEnabledFlag = theDialog->theFontEnabledCheckBox->isChecked();
             QColor qColor = theDialog->theFontColorFrame->paletteBackgroundColor();
             ossimRgbVector color(qColor.red(),
                                  qColor.green(),
                                  qColor.blue());
             theFeatureInfoList[theCurrentFeatureIdx].theColor = color;
             theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.thePointSize.x = theDialog->theFontPointSizeSpinBox->value();
             theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.thePointSize.y = theDialog->theFontPointSizeSpinBox->value();
             theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.theRotation    = ossimString(theDialog->theFontRotationInput->text().ascii()).toDouble();
             theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.theStyleName   = ossimString(theDialog->theFontStyleNameComboBox->currentText().ascii());
             theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.theFamilyName  = ossimString(theDialog->theFontFamilyNameComboBox->currentText().ascii());
             std::stringstream scaleStream(theDialog->theFontScaleInput->text().ascii());
             std::stringstream shearStream(theDialog->theFontShearInput->text().ascii());
             scaleStream >> theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.theScale.x
                         >> theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.theScale.y;
             shearStream >> theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.theShear.x
                         >> theFeatureInfoList[theCurrentFeatureIdx].theFontInformation.theShear.y;
	    break;
	  }
	default:
	  {
	    break;
	  }
	}
    }
  if(theDialog->theAutoApplyCheckBox->isChecked())
  {
     apply();
  }
}
开发者ID:renyu310,项目名称:ossim-svn,代码行数:79,代码来源:ossimQtVectorEditorDialogController.cpp

示例12: setFillColor

/*!
  Set the fill color.
  */
void QgsRubberBand::setFillColor( const QColor & color )
{
  QColor fillColor( color.red(), color.green(), color.blue(), color.alpha() );
  mBrush.setColor( fillColor );
}
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:8,代码来源:qgsrubberband.cpp

示例13: setColor

void MarkStateRuleDialog::setColor(QColor color)
{
  m_color = color;
  m_ui.color->setAutoFillBackground(true);
  QString colorString = QString("rgb(") + QString::number(color.red()) + ", " + QString::number(color.green()) + ", " + QString::number(color.blue()) + ")";
  m_ui.color->setStyleSheet(QString("background-color: ") + colorString + "; color: " + colorString + ";");
}
开发者ID:gijskant,项目名称:mcrl2-pmc,代码行数:7,代码来源:markstateruledialog.cpp

示例14: paintText

void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p)
{
    bool preferRichText = textFormat == Qt::RichText
                          || (textFormat == Qt::AutoText && Qt::mightBeRichText(text));

    if (!preferRichText) {
        QTextLayout textLayout;
        textLayout.setText(text);
        textLayout.setFont(font);
        textLayout.setTextOption(textOption);

        qreal leading = QFontMetricsF(font).leading();
        qreal height = -leading;

        textLayout.beginLayout();
        while (1) {
            QTextLine line = textLayout.createLine();
            if (!line.isValid())
                break;

            if (textWidth >= 0.0)
                line.setLineWidth(textWidth);
            height += leading;
            line.setPosition(QPointF(0.0, height));
            height += line.height();
        }
        textLayout.endLayout();

        actualSize = textLayout.boundingRect().size();
        textLayout.draw(p, topLeftPosition);
    } else {
        QTextDocument document;
#ifndef QT_NO_CSSPARSER
        QColor color = p->pen().color();
        document.setDefaultStyleSheet(QString::fromLatin1("body { color: #%1%2%3 }")
                                      .arg(QString::number(color.red(), 16), 2, QLatin1Char('0'))
                                      .arg(QString::number(color.green(), 16), 2, QLatin1Char('0'))
                                      .arg(QString::number(color.blue(), 16), 2, QLatin1Char('0')));
#endif
        document.setDefaultFont(font);
        document.setDocumentMargin(0.0);        
#ifndef QT_NO_TEXTHTMLPARSER
        document.setHtml(text);
#else
        document.setPlainText(text);
#endif
        if (textWidth >= 0.0)
            document.setTextWidth(textWidth);
        else
            document.adjustSize();
        document.setDefaultTextOption(textOption);

        p->save();
        p->translate(topLeftPosition);
        QAbstractTextDocumentLayout::PaintContext ctx;
        ctx.palette.setColor(QPalette::Text, p->pen().color());
        document.documentLayout()->draw(p, ctx);
        p->restore();

        if (textWidth >= 0.0)
            document.adjustSize(); // Find optimal size

        actualSize = document.size();
    }
}
开发者ID:Marforius,项目名称:qt,代码行数:65,代码来源:qstatictext.cpp

示例15: osgColor


//.........这里部分代码省略.........
    vertices->push_back(v3);
    vertices->push_back(v4);
    vertices->push_back(v5);

    // Right triangle face
    vertices->push_back(v2);
    vertices->push_back(v13);
    vertices->push_back(v5);

    // Right quad face t1
    vertices->push_back(v13);
    vertices->push_back(v12);
    vertices->push_back(v6);
    // Right quad face t2
    vertices->push_back(v13);
    vertices->push_back(v6);
    vertices->push_back(v5);

    // Right quad face down t1
    vertices->push_back(v1);
    vertices->push_back(v9);
    vertices->push_back(v12);
    // Right quad face down t2
    vertices->push_back(v1);
    vertices->push_back(v2);
    vertices->push_back(v12);

    // Left triangle face
    vertices->push_back(v3);
    vertices->push_back(v4);
    vertices->push_back(v10);

    // Left quad face t1
    vertices->push_back(v4);
    vertices->push_back(v10);
    vertices->push_back(v11);
    // Left quad face t2
    vertices->push_back(v4);
    vertices->push_back(v7);
    vertices->push_back(v11);

    // Left quad face down t1
    vertices->push_back(v0);
    vertices->push_back(v3);
    vertices->push_back(v8);
    // Left quad face down t2
    vertices->push_back(v3);
    vertices->push_back(v8);
    vertices->push_back(v11);

    // Create tile geometry
    osg::ref_ptr<osg::Geometry> tileGeometry = new osg::Geometry;

    // Match vertices
    tileGeometry->setVertexArray(vertices);

    // Add color (each rectangle has the same color except for the down one which is transparent)
    osg::Vec4 osgColor(static_cast<float>(color.red())/255.0, static_cast<float>(color.green())/255.0, static_cast<float>(color.blue())/255.0, 1.0);
    osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
    // Every face has the same color, so there is only one color
    colors->push_back(osgColor);

    // Match color
    tileGeometry->setColorArray(colors);
    tileGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);

    // Create normals
    osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array;
    normals->push_back(osg::Vec3(1, 0, 0));
    normals->push_back(osg::Vec3(1, 0, 0));
    normals->push_back(osg::Vec3(-1, 0, 0));
    normals->push_back(osg::Vec3(-1, 0, 0));
    normals->push_back(osg::Vec3(0, 0, 1));
    normals->push_back(osg::Vec3(0, 0, 1));
    double w = pw - mwp;
    double h = phm - mh;
    double norm = std::sqrt(w*w + h*h);
    normals->push_back(osg::Vec3(h/norm, 0, -w/norm));
    normals->push_back(osg::Vec3(h/norm, 0, -w/norm));
    normals->push_back(osg::Vec3(0, 1, 0));
    normals->push_back(osg::Vec3(0, 1, 0));
    normals->push_back(osg::Vec3(0, 1, 0));
    normals->push_back(osg::Vec3(0, 1, 0));
    normals->push_back(osg::Vec3(0, 1, 0));
    normals->push_back(osg::Vec3(0, -1, 0));
    normals->push_back(osg::Vec3(0, -1, 0));
    normals->push_back(osg::Vec3(0, -1, 0));
    normals->push_back(osg::Vec3(0, -1, 0));
    normals->push_back(osg::Vec3(0, -1, 0));

    // Match normals
    tileGeometry->setNormalArray(normals);
    tileGeometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);

    // Define tile 18 GL_TRIANGLES with 20*3 vertices
    tileGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, 18*3));

    // Return the tile whithout plot
    return tileGeometry.release();
}
开发者ID:vmichele,项目名称:LEGO_CREATOR,代码行数:101,代码来源:ReverseTileNode.cpp


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