本文整理汇总了C++中QColor::green方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::green方法的具体用法?C++ QColor::green怎么用?C++ QColor::green使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::green方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: _writeXML
bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) const
{
if ( itemElem.isNull() )
{
return false;
}
QDomElement composerItemElem = doc.createElement( "ComposerItem" );
//frame
if ( mFrame )
{
composerItemElem.setAttribute( "frame", "true" );
}
else
{
composerItemElem.setAttribute( "frame", "false" );
}
//frame
if ( mBackground )
{
composerItemElem.setAttribute( "background", "true" );
}
else
{
composerItemElem.setAttribute( "background", "false" );
}
//scene rect
composerItemElem.setAttribute( "x", QString::number( transform().dx() ) );
composerItemElem.setAttribute( "y", QString::number( transform().dy() ) );
composerItemElem.setAttribute( "width", QString::number( rect().width() ) );
composerItemElem.setAttribute( "height", QString::number( rect().height() ) );
composerItemElem.setAttribute( "positionMode", QString::number(( int ) mLastUsedPositionMode ) );
composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) );
composerItemElem.setAttribute( "rotation", QString::number( mRotation ) );
composerItemElem.setAttribute( "uuid", mUuid );
composerItemElem.setAttribute( "id", mId );
//position lock for mouse moves/resizes
if ( mItemPositionLocked )
{
composerItemElem.setAttribute( "positionLock", "true" );
}
else
{
composerItemElem.setAttribute( "positionLock", "false" );
}
composerItemElem.setAttribute( "lastValidViewScaleFactor", QString::number( mLastValidViewScaleFactor ) );
//frame color
QDomElement frameColorElem = doc.createElement( "FrameColor" );
QColor frameColor = pen().color();
frameColorElem.setAttribute( "red", QString::number( frameColor.red() ) );
frameColorElem.setAttribute( "green", QString::number( frameColor.green() ) );
frameColorElem.setAttribute( "blue", QString::number( frameColor.blue() ) );
frameColorElem.setAttribute( "alpha", QString::number( frameColor.alpha() ) );
composerItemElem.appendChild( frameColorElem );
//background color
QDomElement bgColorElem = doc.createElement( "BackgroundColor" );
QColor bgColor = brush().color();
bgColorElem.setAttribute( "red", QString::number( bgColor.red() ) );
bgColorElem.setAttribute( "green", QString::number( bgColor.green() ) );
bgColorElem.setAttribute( "blue", QString::number( bgColor.blue() ) );
bgColorElem.setAttribute( "alpha", QString::number( bgColor.alpha() ) );
composerItemElem.appendChild( bgColorElem );
//blend mode
composerItemElem.setAttribute( "blendMode", QgsMapRenderer::getBlendModeEnum( mBlendMode ) );
//transparency
composerItemElem.setAttribute( "transparency", QString::number( mTransparency ) );
itemElem.appendChild( composerItemElem );
return true;
}
示例3: col
//.........这里部分代码省略.........
}
//--------------------------------
m_meshLog->moveCursor(QTextCursor::End);
m_meshLog->insertPlainText(" Generating Color ...\n");
for(int ni=0; ni<m_nverts; ni++)
{
m_meshProgress->setValue((int)(100.0*(float)ni/(float)m_nverts));
qApp->processEvents();
float v[3];
v[0] = m_vlist[ni]->x/voxelScaling.x/m_scaleModel;
v[1] = m_vlist[ni]->y/voxelScaling.y/m_scaleModel;
v[2] = m_vlist[ni]->z/voxelScaling.z/m_scaleModel;
if (v[2] > d0 && v[2] <= d1)
{
// QMessageBox::information(0, "", QString("%1 %2 %3\n%4 %5 %6\n%7 %8"). \
// arg(v[0]).arg(v[1]).arg(v[2]). \
// arg(m_vlist[ni]->x).arg(m_vlist[ni]->y).arg(m_vlist[ni]->z). \
// arg(d0).arg(d1));
uchar *volData = extData;
QColor col;
QVector3D pos, normal;
pos = QVector3D(v[0], v[1], v[2]-d0 + nextra);
normal = QVector3D(-m_vlist[ni]->nx,
-m_vlist[ni]->ny,
-m_vlist[ni]->nz);
col = getVRLutColor(volData,
dlen,
depth, nextra,
pos, normal,
lut,
lookInside,
QVector3D(v[0], v[1], v[2]));
if (col.alphaF() > 0)
{
float r = col.red()/255.0f;
float g = col.green()/255.0f;
float b = col.blue()/255.0f;
float a = col.alphaF();
// tinge with lutcolor
QColor col0 = vstops[255*(float)(volnum+1)/(float)nvols].second;
float aa = col0.alphaF();
float tr = col0.red()/255.0f;
float tg = col0.green()/255.0f;
float tb = col0.blue()/255.0f;
r = (1.0-aa)*r + aa*a*tr;
g = (1.0-aa)*g + aa*a*tg;
b = (1.0-aa)*b + aa*a*tb;
vcolor[3*ni+0] = (1-a)*vcolor[3*ni+0] + r;
vcolor[3*ni+1] = (1-a)*vcolor[3*ni+1] + g;
vcolor[3*ni+2] = (1-a)*vcolor[3*ni+2] + b;
}
}
}
m_meshProgress->setValue(100);
delete [] extData;
} // loop over slabs
// if (nvols > 1) // save intermediate files
// {
// QString plyflnm = flnm;
// plyflnm.chop(3);
// plyflnm += QString("%1.ply").arg((int)volnum, (int)nvols/10+2, 10, QChar('0'));
//
// for(int ni=0; ni<m_nverts; ni++)
// {
// m_vlist[ni]->r = 255*vcolor[3*ni+0];
// m_vlist[ni]->g = 255*vcolor[3*ni+1];
// m_vlist[ni]->b = 255*vcolor[3*ni+2];
// }
// savePLY(plyflnm);
// }
}// loop over files
for(int ni=0; ni<m_nverts; ni++)
{
m_vlist[ni]->r = 255*vcolor[3*ni+0];
m_vlist[ni]->g = 255*vcolor[3*ni+1];
m_vlist[ni]->b = 255*vcolor[3*ni+2];
}
savePLY(flnm);
m_meshLog->moveCursor(QTextCursor::End);
m_meshLog->insertPlainText("Mesh saved in "+flnm);
QMessageBox::information(0, "", QString("Mesh saved in "+flnm));
}
示例4: file
void CodeAtlas::RandomWalkClusterer::writeToGephi( char* fileName )
{
ofstream file(fileName);
file <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<gexf xmlns=\"http://www.gexf.net/1.2draft\" version=\"1.2\" xmlns:viz=\"http://www.gexf.net/1.2draft/viz\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd\">\n"
"<meta lastmodifieddate=\"2015-07-06\">\n"
"<creator>Gephi 0.8.1</creator>\n"
"<description></description>\n"
"</meta>\n"
"<graph defaultedgetype=\"directed\" mode=\"static\">\n";
// write nodes
file << " <nodes>\n";
for (int ithNode = 0; ithNode < m_vtx.size(); ++ithNode)
{
char buf[200];
QColor c = QColor::fromHsv((m_vtx[ithNode].m_clusterID * 43)%359, 255, 255);
sprintf(buf,
"<node id=\"%d\" label=\"%d\">\n"
"<attvalues></attvalues>\n"
"<viz:size value=\"1.0\"></viz:size>\n"
"<viz:color r=\"%d\" g=\"%d\" b=\"%d\"></viz:color>\n"
"</node>\n",
ithNode, ithNode,
c.red(), c.green(), c.blue());
file << buf;
}
file << " </nodes>\n";
// write edges
file << " <edges>\n";
int e = 0;
for (int ithNode = 0; ithNode < m_vtx.size(); ++ithNode)
{
char buf[200];
Vertex& v = m_vtx[ithNode];
typedef QHash<int, float> EdgeMap;
/*
for (EdgeMap::Iterator pE = v.m_inEdge.begin(); pE != v.m_inEdge.end(); ++pE, ++e)
{
sprintf(buf,
"<edge source=\"%d\" target=\"%d\" label=\"%d\">\n"
"<attvalues></attvalues>\n"
"</edge>\n", pE.key(), ithNode, e);
file << buf;
}*/
for (EdgeMap::Iterator pE = v.m_outEdge.begin(); pE != v.m_outEdge.end(); ++pE, ++e)
{
sprintf(buf,
"<edge source=\"%d\" target=\"%d\" label=\"%d\">\n"
"<attvalues></attvalues>\n"
"</edge>\n", ithNode, pE.key(), e);
file << buf;
}
}
file << " </edges>\n";
file << " </graph>\n"
"</gexf>";
file.close();
}
示例5: setMaxColour
void ScalarColourRangeMapper::setMaxColour( const QColor& c) { _cols[2] = cv::Vec3b( c.red(), c.green(), c.blue());}
示例6: apply
//when user clicks apply button
void QgsProjectProperties::apply()
{
// Set the map units
// Note. Qt 3.2.3 and greater have a function selectedId() that
// can be used instead of the two part technique here
QGis::UnitType mapUnit;
if ( radMeters->isChecked() )
{
mapUnit = QGis::Meters;
}
else if ( radFeet->isChecked() )
{
mapUnit = QGis::Feet;
}
else if ( radDMS->isChecked() )
{
mapUnit = QGis::DegreesMinutesSeconds;
}
else
{
mapUnit = QGis::Degrees;
}
QgsMapRenderer* myRender = mMapCanvas->mapRenderer();
myRender->setMapUnits( mapUnit );
myRender->setProjectionsEnabled( cbxProjectionEnabled->isChecked() );
// Only change the projection if there is a node in the tree
// selected that has an srid. This prevents error if the user
// selects a top-level node rather than an actual coordinate
// system
long myCRSID = projectionSelector->selectedCrsId();
if ( myCRSID )
{
QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::InternalCrsId );
myRender->setDestinationSrs( srs );
QgsDebugMsg( QString( "Selected CRS " ) + srs.description() );
// write the currently selected projections _proj string_ to project settings
QgsDebugMsg( QString( "SpatialRefSys/ProjectCRSProj4String: %1" ).arg( projectionSelector->selectedProj4String() ) );
QgsProject::instance()->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", projectionSelector->selectedProj4String() );
// Set the map units to the projected coordinates if we are projecting
if ( isProjected() )
{
// If we couldn't get the map units, default to the value in the
// projectproperties dialog box (set above)
if ( srs.mapUnits() != QGis::UnknownUnit )
myRender->setMapUnits( srs.mapUnits() );
}
}
// Set the project title
QgsProject::instance()->title( title() );
// set the mouse display precision method and the
// number of decimal places for the manual option
// Note. Qt 3.2.3 and greater have a function selectedId() that
// can be used instead of the two part technique here
QgsProject::instance()->writeEntry( "PositionPrecision", "/Automatic", radAutomatic->isChecked() );
QgsProject::instance()->writeEntry( "PositionPrecision", "/DecimalPlaces", spinBoxDP->value() );
// Announce that we may have a new display precision setting
emit displayPrecisionChanged();
QgsProject::instance()->writeEntry( "Paths", "/Absolute", cbxAbsolutePath->currentIndex() == 0 );
//set the color for selections
QColor myColor = pbnSelectionColor->color();
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorRedPart", myColor.red() );
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorGreenPart", myColor.green() );
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorBluePart", myColor.blue() );
QgsProject::instance()->writeEntry( "Gui", "/SelectionColorAlphaPart", myColor.alpha() );
QgsRenderer::setSelectionColor( myColor );
//set the color for canvas
myColor = pbnCanvasColor->color();
QgsProject::instance()->writeEntry( "Gui", "/CanvasColorRedPart", myColor.red() );
QgsProject::instance()->writeEntry( "Gui", "/CanvasColorGreenPart", myColor.green() );
QgsProject::instance()->writeEntry( "Gui", "/CanvasColorBluePart", myColor.blue() );
QStringList noIdentifyLayerList;
for ( int i = 0; i < twIdentifyLayers->rowCount(); i++ )
{
QCheckBox *cb = qobject_cast<QCheckBox *>( twIdentifyLayers->cellWidget( i, 2 ) );
if ( cb && !cb->isChecked() )
{
QString id = twIdentifyLayers->item( i, 0 )->data( Qt::UserRole ).toString();
noIdentifyLayerList << id;
}
}
QgsProject::instance()->writeEntry( "Identify", "/disabledLayers", noIdentifyLayerList );
//todo XXX set canvas color
emit refresh();
}
示例7: owner
Color::Color(const QColor &c) : owner(false) {
init(c.red(), c.green(), c.blue(), c.alpha());
}
示例8: 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;
}
示例9: variantToElement
bool DomConvenience::variantToElement(const QVariant& v, QDomElement& e)
{
bool ok = true;
clearAttributes(e);
switch (v.type())
{
case QVariant::String:
e.setTagName("string");
e.setAttribute("value", v.toString().utf8());
break;
case QVariant::CString:
e.setTagName("string");
e.setAttribute("value", v.toCString());
break;
case QVariant::Int:
e.setTagName("int");
e.setAttribute("value", v.toInt());
break;
case QVariant::UInt:
e.setTagName("uint");
e.setAttribute("value", v.toUInt());
break;
case QVariant::Double:
e.setTagName("double");
e.setAttribute("value", v.toDouble());
break;
case QVariant::Bool:
e.setTagName("bool");
e.setAttribute("value", boolString(v.toBool()));
break;
case QVariant::Color:
{
e.setTagName("color");
QColor color = v.toColor();
e.setAttribute("red", color.red());
e.setAttribute("green", color.green());
e.setAttribute("blue", color.blue());
}
break;
case QVariant::Point:
{
e.setTagName("point");
QPoint point = v.toPoint();
e.setAttribute("x", point.x());
e.setAttribute("y", point.y());
}
break;
case QVariant::Rect:
{
e.setTagName("rect");
QRect rect = v.toRect();
e.setAttribute("x", rect.x());
e.setAttribute("y", rect.y());
e.setAttribute("width", rect.width());
e.setAttribute("height", rect.height());
}
break;
case QVariant::Size:
{
e.setTagName("size");
QSize qsize = v.toSize();
e.setAttribute("width", qsize.width());
e.setAttribute("height", qsize.height());
}
break;
case QVariant::Font:
{
e.setTagName("font");
QFont f(v.toFont());
e.setAttribute("family", f.family());
e.setAttribute("pointsize", f.pointSize());
e.setAttribute("bold", boolString(f.bold()));
e.setAttribute("italic", boolString(f.italic()));
e.setAttribute("underline", boolString(f.underline()));
e.setAttribute("strikeout", boolString(f.strikeOut()));
}
break;
case QVariant::SizePolicy:
{
e.setTagName("sizepolicy");
QSizePolicy sp(v.toSizePolicy());
e.setAttribute("hsizetype", sp.horData());
e.setAttribute("vsizetype", sp.verData());
#if (QT_VERSION >= 300)
e.setAttribute("horstretch", sp.horStretch());
e.setAttribute("verstretch", sp.verStretch());
#endif
}
break;
case QVariant::Cursor:
e.setTagName("cursor");
e.setAttribute("shape", v.toCursor().shape());
break;
case QVariant::StringList:
{
e.setTagName("stringlist");
uint j;
//.........这里部分代码省略.........
示例10: 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;
}
示例11: switch
void
AnimatingTextEdit::refreshStylesheet()
{
double bgColor[3];
bool bgColorSet = false;
if (multipleSelection) {
bgColor[0] = bgColor[1] = bgColor[2] = 0;
bgColorSet = true;
}
if (!bgColorSet) {
// draw the background with
// a color reflecting the animation level
switch ((AnimationLevelEnum)animation) {
case eAnimationLevelExpression:
appPTR->getCurrentSettings()->getExprColor(&bgColor[0], &bgColor[1], &bgColor[2]);
bgColorSet = true;
break;
case eAnimationLevelInterpolatedValue:
appPTR->getCurrentSettings()->getInterpolatedColor(&bgColor[0], &bgColor[1], &bgColor[2]);
bgColorSet = true;
break;
case eAnimationLevelOnKeyframe:
appPTR->getCurrentSettings()->getKeyframeColor(&bgColor[0], &bgColor[1], &bgColor[2]);
bgColorSet = true;
break;
case eAnimationLevelNone:
break;
}
}
double fgColor[3];
bool fgColorSet = false;
if (!isEnabled() || isReadOnly() || (AnimationLevelEnum)animation == eAnimationLevelExpression) {
fgColor[0] = fgColor[1] = fgColor[2] = 0.;
fgColorSet = true;
}
QString bgColorStyleSheetStr;
if (bgColorSet) {
QColor bgCol;
bgCol.setRgbF(Image::clamp(bgColor[0], 0., 1.), Image::clamp(bgColor[1], 0., 1.), Image::clamp(bgColor[2], 0., 1.));
bgColorStyleSheetStr = QString::fromUtf8("background-color: rgb(%1, %2, %3);").arg(bgCol.red()).arg(bgCol.green()).arg(bgCol.blue())
;
}
if (fgColorSet) {
QColor fgCol;
fgCol.setRgbF(Image::clamp(fgColor[0], 0., 1.), Image::clamp(fgColor[1], 0., 1.), Image::clamp(fgColor[2], 0., 1.));
setStyleSheet(QString::fromUtf8("QTextEdit {\n"
"color: rgb(%1, %2, %3);\n"
"%4\n"
"}\n").arg(fgCol.red()).arg(fgCol.green()).arg(fgCol.blue()).arg(bgColorStyleSheetStr));
}
style()->unpolish(this);
style()->polish(this);
update();
}
示例12: setRgb
void tst_QColor::setRgb()
{
QColor color;
for (int A = 0; A <= USHRT_MAX; ++A) {
{
// 0-255
int a = A >> 8;
QRgb rgb = qRgba(0, 0, 0, a);
color.setRgb(0, 0, 0, a);
QCOMPARE(color.alpha(), a);
QCOMPARE(color.rgb(), qRgb(0, 0, 0));
color.setRgb(rgb);
QCOMPARE(color.alpha(), 255);
QCOMPARE(color.rgb(), qRgb(0, 0, 0));
int r, g, b, a2;
color.setRgb(0, 0, 0, a);
color.getRgb(&r, &g, &b, &a2);
QCOMPARE(a2, a);
QColor c(0, 0, 0);
c.setAlpha(a);
QCOMPARE(c.alpha(), a);
}
{
// 0.0-1.0
qreal a = A / qreal(USHRT_MAX);
color.setRgbF(0.0, 0.0, 0.0, a);
QCOMPARE(color.alphaF(), a);
qreal r, g, b, a2;
color.getRgbF(&r, &g, &b, &a2);
QCOMPARE(a2, a);
QColor c(0, 0, 0);
c.setAlphaF(a);
QCOMPARE(c.alphaF(), a);
}
}
for (int R = 0; R <= USHRT_MAX; ++R) {
{
// 0-255
int r = R >> 8;
QRgb rgb = qRgb(r, 0, 0);
color.setRgb(r, 0, 0);
QCOMPARE(color.red(), r);
QCOMPARE(color.rgb(), rgb);
color.setRgb(rgb);
QCOMPARE(color.red(), r);
QCOMPARE(color.rgb(), rgb);
int r2, g, b, a;
color.getRgb(&r2, &g, &b, &a);
QCOMPARE(r2, r);
}
{
// 0.0-1.0
qreal r = R / qreal(USHRT_MAX);
color.setRgbF(r, 0.0, 0.0);
QCOMPARE(color.redF(), r);
qreal r2, g, b, a;
color.getRgbF(&r2, &g, &b, &a);
QCOMPARE(r2, r);
}
}
for (int G = 0; G <= USHRT_MAX; ++G) {
{
// 0-255
int g = G >> 8;
QRgb rgb = qRgb(0, g, 0);
color.setRgb(0, g, 0);
QCOMPARE(color.green(), g);
QCOMPARE(color.rgb(), rgb);
color.setRgb(rgb);
QCOMPARE(color.green(), g);
QCOMPARE(color.rgb(), rgb);
int r, g2, b, a;
color.getRgb(&r, &g2, &b, &a);
QCOMPARE(g2, g);
}
{
// 0.0-1.0
qreal g = G / qreal(USHRT_MAX);
color.setRgbF(0.0, g, 0.0);
QCOMPARE(color.greenF(), g);
//.........这里部分代码省略.........
示例13: paintEvent
void BBTCOView::paintEvent( QPaintEvent * )
{
QPainter p( this );
QColor col;
if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() )
{
col = QColor( 160, 160, 160 );
}
else if ( m_bbTCO->m_useStyleColor )
{
col = p.pen().brush().color();
}
else
{
col = m_bbTCO->colorObj();
}
if( isSelected() == true )
{
col.setRgb( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 );
}
QLinearGradient lingrad( 0, 0, 0, height() );
lingrad.setColorAt( 0, col.light( 130 ) );
lingrad.setColorAt( 1, col.light( 70 ) );
p.fillRect( rect(), lingrad );
tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
{
for( int x = static_cast<int>( t * pixelsPerTact() );
x < width()-2;
x += static_cast<int>( t * pixelsPerTact() ) )
{
p.setPen( col.light( 80 ) );
p.drawLine( x, 1, x, 5 );
p.setPen( col.light( 120 ) );
p.drawLine( x, height() - 6, x, height() - 2 );
}
}
p.setPen( col.lighter( 130 ) );
p.drawRect( 1, 1, rect().right()-2, rect().bottom()-2 );
p.setPen( col.darker( 300 ) );
p.drawRect( 0, 0, rect().right(), rect().bottom() );
p.setFont( pointSize<8>( p.font() ) );
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( 4, p.fontMetrics().height()+1, m_bbTCO->name() );
p.setPen( textColor() );
p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() );
if( m_bbTCO->isMuted() )
{
p.drawPixmap( 3, p.fontMetrics().height() + 1,
embed::getIconPixmap( "muted", 16, 16 ) );
}
}
示例14: colorStripes
void MainWindow::colorStripes()
{
QColor color;
int x, y;
int number = 0;
bool onOff = false;
int width = 100;
int height = 100;
int stepSize = 16;
std::default_random_engine generator;
std::normal_distribution<double> onDistribution(30.0,10.0);
std::normal_distribution<double> offDistribution(40.0,20.0);
QVector<QColor*> *colorVector;
colorVector = computeGoldenRatioColors(0.01,0.7,1,100);
motorControl.openShutter();
for (y=0;y!=height;++y) {
for(x=0;x!=width; x++) {
motorControl.setLedColor(color);
if (number<=0) {
if(onOff) {
color.setRed(0);
color.setGreen(0);
color.setBlue(0);
motorControl.setLedColor(color);
onOff = false;
number = int(offDistribution(generator));
} else {
QColor *pColor = colorVector->at(rand() % 100);
color.setRed(pColor->red());
color.setGreen(pColor->green());
color.setBlue(pColor->blue());
motorControl.setLedColor(color);
onOff = true;
number = int(onDistribution(generator));
}
}
motorControl.commandMotor1(3, -stepSize);
number--;
}
motorControl.setLedColor(QColor(0,0,0));
motorControl.commandMotor1(3, stepSize * width);
motorControl.commandMotor2(6, -stepSize);
}
motorControl.closeShutter();
// Reset x axis to initial position if the width is uneven
if( width%2 != 0) {
motorControl.commandMotor1(6, stepSize * width);
}
// Reset y axis to initial position
motorControl.commandMotor2(6, stepSize * height);
motorControl.releaseMotor1();
motorControl.releaseMotor2();
}
示例15: run
void ThumbnailRunnable::run()
{
emit started(this->item);
QColor c;
argv0Array = this->item->getFilePath().toString().toLocal8Bit();
parameters.gb_argv0 = argv0Array.data();
parameters.gb_a_ratio = GB_A_RATIO;
parameters.gb_C_cut = GB_C_CUT;
parameters.gb_h_height = 0;
parameters.gb_I_individual = GB_I_INDIVIDUAL;
parameters.gb_z_seek = GB_Z_SEEK;
parameters.gb_Z_nonseek = GB_Z_NONSEEK;
parameters.gb_s_step = GB_S_STEP;
parameters.gb_O_format = main_window->mpDockConf->getFormatFileCode();
parameters.gb_r_row = main_window->mpDockConf->getRows();
parameters.gb_c_column = main_window->mpDockConf->getColumns();
parameters.gb_w_width = main_window->mpDockConf->getWidth();
parameters.gb_g_gap = main_window->mpDockConf->getGap();
parameters.gb_j_quality = main_window->mpDockConf->getQuality();
parameters.gb_b_blank = main_window->mpDockConf->getBlankSkip();
parameters.gb_D_edge = GB_D_EDGE;
parameters.gb_L_info_location = main_window->mpDockStyles->getInfoTextLocation();
parameters.gb_L_time_location = main_window->mpDockStyles->getTimeStampLocation();
c = main_window->mpDockStyles->getColorBackground();
parameters.gb_k_bcolor = (rgb_color) {c.red(), c.green(), c.blue()};
f_fontnameArray = main_window->mpDockStyles->getFontInfoText(0).toLocal8Bit();
parameters.gb_f_fontname = f_fontnameArray.data();
c = main_window->mpDockStyles->getColorInfoText();
parameters.gb_F_info_color = (rgb_color) {c.red(), c.green(), c.blue()};
parameters.gb_F_info_font_size = main_window->mpDockStyles->getSizeInfoText();
if(main_window->mpDockStyles->isTimeStampChecked())
{
parameters.gb_t_timestamp = 1;
F_ts_fontnameArray = main_window->mpDockStyles->getFontTimeStamp(2).toLocal8Bit();
parameters.gb_F_ts_fontname = F_ts_fontnameArray.data();
c = main_window->mpDockStyles->getColorTimeStamp();
parameters.gb_F_ts_color = (rgb_color) {c.red(), c.green(), c.blue()};
c = main_window->mpDockStyles->getColorShadow();
parameters.gb_F_ts_shadow = (rgb_color) {c.red(), c.green(), c.blue()};
parameters.gb_F_ts_font_size = main_window->mpDockStyles->getSizeTimeStamp();
}
else parameters.gb_t_timestamp = 0;
if(this->modeConversion == ThumbnailEngine::SIMPLEMOD && !main_window->mpDockInputOutput->isSameSourceChecked())
{
O_outdir = main_window->mpDockInputOutput->getPathOutput().toLocal8Bit();
parameters.gb_O_outdir = O_outdir.data();
if(!this->suffix.isEmpty())
{
o_suffixArray = QString(this->suffix + "." + this->main_window->mpDockConf->getFormatFile()).toLocal8Bit();
parameters.gb_o_suffix = o_suffixArray.data();
}
else
{
o_suffixArray = QString("." + this->main_window->mpDockConf->getFormatFile()).toLocal8Bit();
parameters.gb_o_suffix = o_suffixArray.data();
}
}
else if (this->modeConversion == ThumbnailEngine::SIMPLEMOD && main_window->mpDockInputOutput->isSameSourceChecked())
{
O_outdir = QDir::toNativeSeparators(QFileInfo(item->getFilePath().toString()).canonicalPath()).toLocal8Bit();
parameters.gb_O_outdir = O_outdir.data();
if(!this->suffix.isEmpty())
{
o_suffixArray = QString(this->suffix + "." + this->main_window->mpDockConf->getFormatFile()).toLocal8Bit();
parameters.gb_o_suffix = o_suffixArray.data();
}
else
{
o_suffixArray = QString("." + this->main_window->mpDockConf->getFormatFile()).toLocal8Bit();
parameters.gb_o_suffix = o_suffixArray.data();
}
}
else
{
O_outdir = QDir::tempPath().toLocal8Bit();
parameters.gb_O_outdir = O_outdir.data();
o_suffixArray = DEFAULT_TMP_EXTENSION.toLocal8Bit();
parameters.gb_o_suffix = o_suffixArray.data();
}
if(main_window->mpDockStyles->isInfoTextChecked())
parameters.gb_i_info = 1;
else parameters.gb_i_info = 0;
if(!main_window->mpDockStyles->getTitleEdit().isEmpty())
{
T_textArray = main_window->mpDockStyles->getTitleEdit().toLocal8Bit();
parameters.gb_T_text = T_textArray.data();
}
//.........这里部分代码省略.........