本文整理汇总了C++中qBound函数的典型用法代码示例。如果您正苦于以下问题:C++ qBound函数的具体用法?C++ qBound怎么用?C++ qBound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qBound函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: m_name
Theme::Theme(const QString& name)
: m_name(name)
{
if (m_name.isEmpty()) {
QString untitled;
int count = 0;
do {
count++;
untitled = tr("Untitled %1").arg(count);
} while (QFile::exists(filePath(untitled)));
setValue(m_name, untitled);
}
QSettings settings(filePath(m_name), QSettings::IniFormat);
// Load background settings
m_background_type = settings.value("Background/Type", 0).toInt();
m_background_color = settings.value("Background/Color", "#cccccc").toString();
m_background_path = settings.value("Background/Image").toString();
m_background_image = settings.value("Background/ImageFile").toString();
if (!m_background_path.isEmpty() && m_background_image.isEmpty()) {
setValue(m_background_image, copyImage(m_background_path));
}
// Load foreground settings
m_foreground_color = settings.value("Foreground/Color", "#cccccc").toString();
m_foreground_opacity = qBound(0, settings.value("Foreground/Opacity", 100).toInt(), 100);
m_foreground_width = qBound(500, settings.value("Foreground/Width", 700).toInt(), 2000);
m_foreground_rounding = qBound(0, settings.value("Foreground/Rounding", 0).toInt(), 100);
m_foreground_margin = qBound(0, settings.value("Foreground/Margin", 65).toInt(), 250);
m_foreground_padding = qBound(0, settings.value("Foreground/Padding", 0).toInt(), 250);
m_foreground_position = qBound(0, settings.value("Foreground/Position", 1).toInt(), 3);
// Load text settings
m_text_color = settings.value("Text/Color", "#000000").toString();
m_text_font.fromString(settings.value("Text/Font", QFont().toString()).toString());
m_misspelled_color = settings.value("Text/Misspelled", "#ff0000").toString();
QStringList blocktypes;
blocktypes<<"default"<<"H1"<<"H2"<<"H3"<<"H4"<<"H5"<<"BLOCKQUOTE"<<"ATTRIBUTION"<<"DIVIDER1"<<"DIVIDER2"<<"DIVIDER3"<<"DIVIDER4"<<"DIVIDER5"<<"PRE";
QStringListIterator it(blocktypes);
while(it.hasNext())
{
QString thetype=it.next();
QTextBlockFormat format;
if(settings.contains(QString("Styles/")+thetype+QString("/FontWeight")))
{
int weight=settings.value(QString("Styles/")+thetype+QString("/FontWeight")).toInt();
if(weight!=0)
format.setProperty(QTextFormat::FontWeight,QFont::Bold);
}
else if(thetype.startsWith("H")&&thetype.at(1).isDigit())
format.setProperty(QTextFormat::FontWeight,QFont::Bold);
if(settings.contains(QString("Styles/")+thetype+QString("/FontItalic")))
{
bool italic=settings.value(QString("Styles/")+thetype+QString("/FontItalic")).toBool();
if(italic)
format.setProperty(QTextFormat::FontItalic,true);
}
else if(thetype=="BLOCKQUOTE" || thetype=="ATTRIBUTION")
format.setProperty(QTextFormat::FontItalic,true);
if(settings.contains(QString("Styles/")+thetype+QString("/FontSizeAdjustment")))
{
int adjustment=settings.value(QString("Styles/")+thetype+QString("/FontSizeAdjustment")).toInt();
if(adjustment!=0)
format.setProperty(QTextFormat::FontSizeAdjustment,adjustment);
}
else if(thetype.startsWith("H")&&thetype.at(1).isDigit())
format.setProperty(QTextFormat::FontSizeAdjustment,4-QString(thetype.at(1)).toInt());
if(settings.contains(QString("Styles/")+thetype+QString("/BlockLeftMargin")))
{
double margin=settings.value(QString("Styles/")+thetype+QString("/BlockLeftMargin")).toDouble();
if(margin!=0)
format.setProperty(QTextFormat::BlockLeftMargin,margin);
}
else if(thetype=="BLOCKQUOTE" || thetype=="ATTRIBUTION")
format.setProperty(QTextFormat::BlockLeftMargin,50.0);
if(settings.contains(QString("Styles/")+thetype+QString("/BlockRightMargin")))
{
double margin=settings.value(QString("Styles/")+thetype+QString("/BlockRightMargin")).toDouble();
if(margin!=0)
format.setProperty(QTextFormat::BlockRightMargin,margin);
}
else if(thetype=="BLOCKQUOTE" || thetype=="ATTRIBUTION")
format.setProperty(QTextFormat::BlockRightMargin,50.0);
if(settings.contains(QString("Styles/")+thetype+QString("/BlockTopMargin")))
{
double margin=settings.value(QString("Styles/")+thetype+QString("/BlockTopMargin")).toDouble();
if(margin!=0)
format.setProperty(QTextFormat::BlockTopMargin,margin);
}
else if(thetype.startsWith("DIVIDER"))
{
double arr[]={0.0,5.0,5.0,10.0,15.0};
int dl=QString(thetype.at(7)).toInt();
//.........这里部分代码省略.........
开发者ID:quickhand,项目名称:Prosit,代码行数:101,代码来源:theme.cpp
示例2: while
void HeatmapView::paintRow(QPainter& painter, HeatmapRowIterator* itr)
{
bool selection = m_selectionState ? m_selectionState->type != SelectionState::None : false;
while (itr->next())
{
double heat = itr->heat();
int width = itr->width();
int x = itr->step();
/* Gamma correction */
heat = qPow(heat, 1.0 / 2.0);
if (width == 1) {
/* Draw single line */
if (selection) {
double selectedHeat = itr->selectedHeat();
if (selectedHeat >= 0.999) {
heat = 255.0 - qBound(0.0, heat * 255.0, 255.0);
if (itr->isGpu()) {
painter.setPen(QColor(255, heat, heat));
} else {
painter.setPen(QColor(heat, heat, 255));
}
painter.drawLine(x, 0, x, m_rowHeight - 1);
} else {
heat = 255.0 - qBound(0.0, heat * 100.0, 100.0);
painter.setPen(QColor(heat, heat, heat));
painter.drawLine(x, 0, x, m_rowHeight - 1);
if (selectedHeat > 0.001) {
selectedHeat = qPow(selectedHeat, 1.0 / 2.0);
selectedHeat = qBound(0.0, selectedHeat * 255.0, 255.0);
if (itr->isGpu()) {
painter.setPen(QColor(255, 0, 0, selectedHeat));
} else {
painter.setPen(QColor(0, 0, 255, selectedHeat));
}
painter.drawLine(x, 0, x, m_rowHeight - 1);
}
}
} else {
heat = qBound(0.0, heat * 255.0, 255.0);
if (itr->isGpu()) {
painter.setPen(QColor(255, 255 - heat, 255 - heat));
} else {
painter.setPen(QColor(255 - heat, 255 - heat, 255));
}
painter.drawLine(x, 0, x, m_rowHeight - 1);
}
} else {
double selectedHeat = itr->selectedHeat();
if (selection && selectedHeat < 0.9) {
painter.fillRect(x, 0, width, m_rowHeight, QColor(255 - 100, 255 - 100, 255 - 100));
} else if (itr->isGpu()) {
painter.fillRect(x, 0, width, m_rowHeight, QColor(255, 0, 0));
} else {
painter.fillRect(x, 0, width, m_rowHeight, QColor(0, 0, 255));
}
if (width > 6) {
painter.setPen(Qt::white);
QString elided = painter.fontMetrics().elidedText(itr->label(), Qt::ElideRight, width - 1);
painter.drawText(x + 1, 0, width - 1, m_rowHeight - 1,
Qt::AlignLeft | Qt::AlignVCenter,
elided);
}
}
}
}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:79,代码来源:heatmapview.cpp
示例3: qBound
QRectF PanelPageSize::BoundingPageSumme(const int summe)
{
int summetotal = qBound(1,summe,MaximumPages);
const qreal alto = summetotal * G_regt.height();
return QRectF(0,0,G_regt.width(),alto);
}
开发者ID:SorinS,项目名称:fop-miniscribus,代码行数:6,代码来源:qtextpanelmime.cpp
示例4: QT_RESET_GLERROR
void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
QGLFramebufferObject::Attachment attachment,
GLenum texture_target, GLenum internal_format,
GLint samples, bool mipmap)
{
QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
fbo_guard.setContext(ctx);
bool ext_detected = (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject);
if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx)))
return;
size = sz;
target = texture_target;
// texture dimensions
QT_RESET_GLERROR(); // reset error state
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
fbo_guard.setId(fbo);
glDevice.setFBO(q, attachment);
QT_CHECK_GLERROR();
// init texture
if (samples == 0) {
glGenTextures(1, &texture);
glBindTexture(target, texture);
glTexImage2D(target, 0, internal_format, size.width(), size.height(), 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
if (mipmap)
glGenerateMipmap(GL_TEXTURE_2D);
#ifndef QT_OPENGL_ES
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#else
glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#endif
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
target, texture, 0);
QT_CHECK_GLERROR();
valid = checkFramebufferStatus();
glBindTexture(target, 0);
color_buffer = 0;
} else {
mipmap = false;
GLint maxSamples;
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
samples = qBound(0, int(samples), int(maxSamples));
glGenRenderbuffers(1, &color_buffer);
glBindRenderbuffer(GL_RENDERBUFFER_EXT, color_buffer);
if (glRenderbufferStorageMultisampleEXT && samples > 0) {
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples,
internal_format, size.width(), size.height());
} else {
samples = 0;
glRenderbufferStorage(GL_RENDERBUFFER_EXT, internal_format,
size.width(), size.height());
}
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, color_buffer);
QT_CHECK_GLERROR();
valid = checkFramebufferStatus();
if (valid)
glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &samples);
}
// In practice, a combined depth-stencil buffer is supported by all desktop platforms, while a
// separate stencil buffer is not. On embedded devices however, a combined depth-stencil buffer
// might not be supported while separate buffers are, according to QTBUG-12861.
if (attachment == QGLFramebufferObject::CombinedDepthStencil
&& (QGLExtensions::glExtensions() & QGLExtensions::PackedDepthStencil)) {
// depth and stencil buffer needs another extension
glGenRenderbuffers(1, &depth_buffer);
Q_ASSERT(!glIsRenderbuffer(depth_buffer));
glBindRenderbuffer(GL_RENDERBUFFER_EXT, depth_buffer);
Q_ASSERT(glIsRenderbuffer(depth_buffer));
if (samples != 0 && glRenderbufferStorageMultisampleEXT)
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples,
GL_DEPTH24_STENCIL8_EXT, size.width(), size.height());
else
glRenderbufferStorage(GL_RENDERBUFFER_EXT,
GL_DEPTH24_STENCIL8_EXT, size.width(), size.height());
stencil_buffer = depth_buffer;
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
//.........这里部分代码省略.........
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:101,代码来源:qglframebufferobject.cpp
示例5: layoutAboutToBeChanged
void ModelTest::layoutAboutToBeChanged()
{
for (int i = 0; i < qBound(0, model->rowCount(), 100); ++i)
changing.append(QPersistentModelIndex(model->index(i, 0)));
}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:5,代码来源:modeltest.cpp
示例6: resizeBoolVecImage
QVector<bool> resizeBoolVecImage(const QVector<bool>& image, int w, int h, int newWidth, int newHeight, int* askUserResizeMasks, const QString& image_name, const QString& comment) {
if (w==newWidth && h==newHeight) return image;
if (image.size()<w*h) return QVector<bool>();
double ax=double(w)/double(h);
double newax=double(newWidth)/double(newHeight);
bool transform=false;
if (askUserResizeMasks) {
transform=((*askUserResizeMasks)>0);
if ((*askUserResizeMasks)<0) {
int res=QMessageBox::question(NULL, QObject::tr("resize %1").arg(image_name), QObject::tr("%2\nShould the %1 be resized?").arg(image_name).arg(comment), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
if (res==QMessageBox::Yes) {
*askUserResizeMasks=1;
transform=true;
} else if (res==QMessageBox::No) {
*askUserResizeMasks=0;
transform=false;
}
}
} else {
transform=true;
}
if (transform) {
QVector<bool> r;
if (w*h==newWidth*newHeight) {
for (int i=0; i<newWidth*newHeight; i++) {
r<<image[i];
}
} else if (newWidth*newHeight>w*h) {
for (int i=0; i<newWidth*newHeight; i++) {
int x=i%w;
int y=i/w;
int x2=round(double(x)/double(newWidth)*double(w));
int y2=round(double(y)/double(newHeight)*double(h));
int i2=qBound(0, y2*w+x2, w*h);
r<<image[i2];
}
} else if (newWidth*newHeight<w*h) {
QVector<int> rr;
for (int i=0; i<newWidth*newHeight; i++) {
r<<false;
rr<<0;
}
int max=0;
for (int i=0; i<w*h; i++) {
int x=i%w;
int y=i/h;
int x2=round(double(x)/double(w)*double(newWidth));
int y2=round(double(y)/double(h)*double(newHeight));
int i2=y2*newWidth+x2;
if (i2>=0 && i2<w*h && image[i]) {
rr[i2]=rr[i2]+1;
max=qMax(max, rr[i2]);
}
}
for (int i=0; i<newWidth*newHeight; i++) {
r[i]=(rr[i]>=max/2);
}
}
return r;
}
return QVector<bool>();
}
开发者ID:jkriege2,项目名称:QuickFit3,代码行数:64,代码来源:image_tools.cpp
示例7: setZValue
//virtual
QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange) {
if (value.toBool()) setZValue(3);
else setZValue(1);
}
CustomTrackScene *scene = NULL;
if (change == ItemPositionChange && parentItem() == 0) {
scene = projectScene();
}
if (scene) {
// calculate new position.
if (scene->isZooming) {
// For some reason, mouse wheel on selected itm sometimes triggered
// a position change event corrupting timeline, so discard it
return pos();
}
// calculate new position.
const int trackHeight = KdenliveSettings::trackheight();
QPointF start = sceneBoundingRect().topLeft();
QPointF newPos = value.toPointF();
int xpos = projectScene()->getSnapPointForPos((int)(start.x() + newPos.x() - pos().x()), KdenliveSettings::snaptopoints());
xpos = qMax(xpos, 0);
////qDebug()<<"GRP XPOS:"<<xpos<<", START:"<<start.x()<<",NEW:"<<newPos.x()<<"; SCENE:"<<scenePos().x()<<",POS:"<<pos().x();
newPos.setX((int)(pos().x() + xpos - (int) start.x()));
QStringList lockedTracks = property("locked_tracks").toStringList();
int proposedTrack = trackForPos(property("y_absolute").toInt() + newPos.y());
// Check if top item is a clip or a transition
int offset = 0;
int topTrack = -1;
QList<int> groupTracks;
QList<QGraphicsItem *> children = childItems();
for (int i = 0; i < children.count(); ++i) {
int currentTrack = 0;
if (children.at(i)->type() == AVWidget || children.at(i)->type() == TransitionWidget) {
currentTrack = static_cast <AbstractClipItem*> (children.at(i))->track();
if (!groupTracks.contains(currentTrack)) groupTracks.append(currentTrack);
}
else if (children.at(i)->type() == GroupWidget) {
currentTrack = static_cast <AbstractGroupItem*> (children.at(i))->track();
}
else continue;
if (children.at(i)->type() == AVWidget) {
if (topTrack == -1 || currentTrack >= topTrack) {
offset = 0;
topTrack = currentTrack;
}
} else if (children.at(i)->type() == TransitionWidget) {
if (topTrack == -1 || currentTrack > topTrack) {
offset = (int)(trackHeight / 3 * 2 - 1);
topTrack = currentTrack;
}
} else if (children.at(i)->type() == GroupWidget) {
QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
bool clipGroup = false;
for (int j = 0; j < subchildren.count(); ++j) {
if (subchildren.at(j)->type() == AVWidget || subchildren.at(j)->type() == TransitionWidget) {
int subTrack = static_cast <AbstractClipItem*> (subchildren.at(j))->track();
if (!groupTracks.contains(subTrack)) groupTracks.append(subTrack);
clipGroup = true;
}
}
if (clipGroup) {
if (topTrack == -1 || currentTrack >= topTrack) {
offset = 0;
topTrack = currentTrack;
}
} else {
if (topTrack == -1 || currentTrack > topTrack) {
offset = (int)(trackHeight / 3 * 2 - 1);
topTrack = currentTrack;
}
}
}
}
// Check no clip in the group goes outside of existing tracks
int maximumTrack = projectScene()->tracksCount();
int groupHeight = 0;
for (int i = 0; i < groupTracks.count(); ++i) {
int trackOffset = topTrack - groupTracks.at(i) + 1;
if (trackOffset > groupHeight) groupHeight = trackOffset;
}
proposedTrack = qBound(groupHeight, proposedTrack, maximumTrack);
int groupOffset = proposedTrack - topTrack;
if (!lockedTracks.isEmpty()) {
for (int i = 0; i < groupTracks.count(); ++i) {
if (lockedTracks.contains(QString::number(groupTracks.at(i) + groupOffset))) {
return pos();
}
}
}
newPos.setY(posForTrack(proposedTrack) + offset);
//if (newPos == start) return start;
/*if (newPos.x() < 0) {
// If group goes below 0, adjust position to 0
return QPointF(pos().x() - start.x(), pos().y());
//.........这里部分代码省略.........
开发者ID:jessezwd,项目名称:kdenlive,代码行数:101,代码来源:abstractgroupitem.cpp
示例8: qBound
void KNewPasswordWidget::setPasswordStrengthWarningLevel(int warningLevel)
{
d->passwordStrengthWarningLevel = qBound(0, warningLevel, 99);
}
开发者ID:SpiritSPb,项目名称:kwidgetsaddons,代码行数:4,代码来源:knewpasswordwidget.cpp
示例9: col
//.........这里部分代码省略.........
uchar *vslice = m_vfm->getSlice(0);
}
m_meshLog->moveCursor(QTextCursor::End);
m_meshLog->insertPlainText(QString("\nProcessing file %1 of %2 : %3\n").\
arg(volnum+1).arg(nvols).arg(m_vfm->fileName()));
for (int nb=0; nb<nSlabs; nb++)
{
m_meshLog->moveCursor(QTextCursor::End);
m_meshLog->insertPlainText(QString(" Processing slab %1 of %2\n").arg(nb+1).arg(nSlabs));
int d0 = nb*blockStep;
int d1 = qMin(m_nX-1, (nb+1)*blockStep);
int dlen = d1-d0+1;
int d0z = d0 + qRound(m_dataMin.z);
int d1z = d1 + qRound(m_dataMin.z);
uchar *extData;
if (m_voxelType == 0)
extData = new uchar[(dlen+2*nextra)*m_nY*m_nZ];
else
extData = new uchar[2*(dlen+2*nextra)*m_nY*m_nZ]; // ushort
uchar *cropped = new uchar[nbytes];
uchar *tmp = new uchar[nbytes];
int i0 = 0;
for(int i=d0z-nextra; i<=d1z+nextra; i++)
{
m_meshProgress->setValue((int)(100.0*(float)(i0/(float)(dlen+2*nextra))));
qApp->processEvents();
int iv = qBound(0, i, m_depth-1);
uchar *vslice = m_vfm->getSlice(iv);
memset(cropped, 0, nbytes);
if (!trim)
memcpy(tmp, vslice, nbytes);
else
{
int wmin = qRound(m_dataMin.y);
int hmin = qRound(m_dataMin.x);
if (m_voxelType == 0)
{
for(int w=0; w<m_nY; w++)
for(int h=0; h<m_nZ; h++)
tmp[w*m_nZ + h] = vslice[(wmin+w)*m_height + (hmin+h)];
}
else
{
for(int w=0; w<m_nY; w++)
for(int h=0; h<m_nZ; h++)
((ushort*)tmp)[w*m_nZ + h] = ((ushort*)vslice)[(wmin+w)*m_height + (hmin+h)];
}
}
int jk = 0;
for(int j=0; j<m_nY; j++)
for(int k=0; k<m_nZ; k++)
{
Vec po = Vec(m_dataMin.x+k, m_dataMin.y+j, iv);
bool ok = true;
开发者ID:beyondwolfeagle,项目名称:drishti,代码行数:66,代码来源:meshgenerator.cpp
示例10: Vec
QColor
MeshGenerator::getVRLutColor(uchar *volData,
int dlen,
int depth, int nextra,
QVector3D pos,
QVector3D normal,
uchar *lut,
bool lookInside,
QVector3D globalPos)
{
// go a bit deeper and start
QVector3D vpos = pos + normal;
// -- find how far deep we can go
int nd = 0;
for(int n=0; n<=depth; n++)
{
int i = vpos.x();
int j = vpos.y();
int k = vpos.z();
if (i > m_nZ-1 || j > m_nY-1 || k > dlen+2*nextra-1 ||
i < 0 || j < 0 || k < 0) // gone out
break;
nd ++;
vpos += normal;
}
// now start collecting the samples
vpos = pos + normal;
QVector3D gpos = globalPos + normal;
Vec rgb = Vec(0,0,0);
float tota = 0;
for(int ns=0; ns<=nd; ns++)
{
int i = vpos.x();
int j = vpos.y();
int k = vpos.z();
i = qBound(0, i, m_nZ-1);
j = qBound(0, j, m_nY-1);
k = qBound(0, k, dlen+2*nextra-1);
Vec po0 = Vec(m_dataMin.x+gpos.x(), m_dataMin.y+gpos.y(), gpos.z());
Vec po = po0*m_samplingLevel;
bool ok=true;
if (ok)
{
ushort v, gr;
if (m_voxelType == 0)
{
v = volData[k*m_nY*m_nZ + j*m_nZ + i];
gr = 0;
}
else
{
v = ((ushort*)volData)[k*m_nY*m_nZ + j*m_nZ + i];
gr = v%256;
v = v/256;
}
// QMessageBox::information(0, "", QString("vrlut : %1 %2 %3 : %4").\
// arg(i).arg(j).arg(k).arg(v));
float a = lut[4*(256*gr + v)+3]/255.0f;
float r = lut[4*(256*gr + v)+0]*a;
float g = lut[4*(256*gr + v)+1]*a;
float b = lut[4*(256*gr + v)+2]*a;
if (m_blendPresent)
{
for(int ci=0; ci<m_crops.count(); ci++)
{
if (m_crops[ci].cropType() > CropObject::Displace_Displace &&
m_crops[ci].cropType() < CropObject::Glow_Ball)
{
float viewMix = m_crops[ci].checkBlend(po);
int tfSet = m_crops[ci].tfset();
tfSet *= 256*256*4;
float a1 = lut[tfSet+4*(256*gr + v)+3]/255.0f;
float r1 = lut[tfSet+4*(256*gr + v)+0]*a1;
float g1 = lut[tfSet+4*(256*gr + v)+1]*a1;
float b1 = lut[tfSet+4*(256*gr + v)+2]*a1;
r = (1-viewMix)*r + viewMix*r1;
g = (1-viewMix)*g + viewMix*g1;
b = (1-viewMix)*b + viewMix*b1;
a = (1-viewMix)*a + viewMix*a1;
}
}
}
if (m_pathBlendPresent)
{
for(int ci=0; ci<m_paths.count(); ci++)
{
if (m_paths[ci].blend())
{
//.........这里部分代码省略.........
开发者ID:beyondwolfeagle,项目名称:drishti,代码行数:101,代码来源:meshgenerator.cpp
示例11: QRegExp
void PowerDevilRunner::match(Plasma::RunnerContext &context)
{
const QString term = context.query();
if (term.length() < m_shortestCommand) {
return;
}
QList<Plasma::QueryMatch> matches;
QString parameter;
if (parseQuery(term,
QList<QRegExp>() << QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "power profile %1", "(.*)"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword", "power profile"), Qt::CaseInsensitive),
parameter)) {
for (StringStringMap::const_iterator i = m_availableProfiles.constBegin(); i != m_availableProfiles.constEnd(); ++i) {
if (!parameter.isEmpty()) {
if (!i.value().startsWith(parameter, Qt::CaseInsensitive)) {
continue;
}
}
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setIcon(KIcon(m_profileIcon[i.key()]));
match.setText(i18n("Set Profile to '%1'", i.value()));
match.setData(i.key());
match.setRelevance(1);
match.setId("ProfileChange "+ i.key());
matches.append(match);
}
} else if (parseQuery(term,
QList<QRegExp>() << QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "screen brightness %1", "(.*)"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword", "screen brightness"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "dim screen %1", "(.*)"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword", "dim screen"), Qt::CaseInsensitive),
parameter)) {
if (!parameter.isEmpty()) {
bool test;
int b = parameter.toInt(&test);
if (test) {
int brightness = qBound(0, b, 100);
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setIcon(KIcon("preferences-system-power-management"));
match.setText(i18n("Set Brightness to %1", brightness));
match.setData(brightness);
match.setRelevance(1);
match.setId("BrightnessChange");
matches.append(match);
}
} else {
Plasma::QueryMatch match1(this);
match1.setType(Plasma::QueryMatch::ExactMatch);
match1.setIcon(KIcon("preferences-system-power-management"));
match1.setText(i18n("Dim screen totally"));
match1.setRelevance(1);
match1.setId("DimTotal");
matches.append(match1);
Plasma::QueryMatch match2(this);
match2.setType(Plasma::QueryMatch::ExactMatch);
match2.setIcon(KIcon("preferences-system-power-management"));
match2.setText(i18n("Dim screen by half"));
match2.setRelevance(1);
match2.setId("DimHalf");
matches.append(match2);
Plasma::QueryMatch match3(this);
match3.setType(Plasma::QueryMatch::ExactMatch);
match3.setIcon(KIcon("video-display"));
match3.setText(i18n("Turn off screen"));
match3.setRelevance(1);
match3.setId("TurnOffScreen");
matches.append(match3);
}
} else if (term.compare(i18nc("Note this is a KRunner keyword", "suspend"), Qt::CaseInsensitive) == 0) {
QSet< Solid::PowerManagement::SleepState > states = Solid::PowerManagement::supportedSleepStates();
if (states.contains(Solid::PowerManagement::SuspendState)) {
addSuspendMatch(Solid::PowerManagement::SuspendState, matches);
}
if (states.contains(Solid::PowerManagement::HibernateState)) {
addSuspendMatch(Solid::PowerManagement::HibernateState, matches);
}
} else if (term.compare(i18nc("Note this is a KRunner keyword", "sleep"), Qt::CaseInsensitive) == 0 ||
term.compare(i18nc("Note this is a KRunner keyword", "to ram"), Qt::CaseInsensitive) == 0) {
addSuspendMatch(Solid::PowerManagement::SuspendState, matches);
} else if (term.compare(i18nc("Note this is a KRunner keyword", "hibernate"), Qt::CaseInsensitive) == 0 ||
term.compare(i18nc("Note this is a KRunner keyword", "to disk"), Qt::CaseInsensitive) == 0) {
addSuspendMatch(Solid::PowerManagement::HibernateState, matches);
}
if (!matches.isEmpty()) {
context.addMatches(term, matches);
}
}
开发者ID:mgottschlag,项目名称:kwin-tiling,代码行数:97,代码来源:PowerDevilRunner.cpp
示例12: barWidth
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tRepowerMotoringWidgetSimrad::PaintBars( QPainter& painter, QVector< float >& values, bool isLeft )
{
if ( m_pEngineRPMGauge )
{
painter.save();
QRect gaugeRect = m_pEngineRPMGauge->geometry();
const int barWidth( qRound( gaugeRect.height() * 0.05 ) );
const int offsetValue ( qRound( barWidth + ( barWidth * 0.5 ) ) );
const int cStep( offsetValue / 4 ) ;
int totalOffset( int( offsetValue / 1.5 ) );
int count( 0 );
foreach( float value, values )
{
QRect middleRect( gaugeRect );
tDigitalData data( DATA_TYPE_ENGINE_TEMP );
middleRect.adjust( -totalOffset, -totalOffset, totalOffset, totalOffset );
if ( true == isLeft )
{
data = tDigitalData( DATA_TYPE_ENGINE_TRIM );
}
qreal span( ( 45 - ( count * cStep ) ) );
count ++;
int spanForArc( int( span * 16 ) );
qreal leftStartAngle( 180 * 16 );
qreal rightStartAngle( 360 * 16 );
// Red bit
tNOSStyle* pStyle = qobject_cast< tNOSStyle* >( style() );
Assert( pStyle );
QColor redColour( Qt::red );
if ( pStyle )
{
redColour = pStyle->GetColor( tNOSStyle::eNCR_Destructive );
}
painter.setPen( QPen( redColour, barWidth ) );
if ( true == isLeft )
{
painter.drawArc( middleRect, int( leftStartAngle - ( spanForArc / 2 ) ), spanForArc );
}
else
{
painter.drawArc( middleRect, int( rightStartAngle - ( spanForArc / 2 ) ), spanForArc );
}
// Black bit
span -= cRedLineWidth;
int blackSpan( int( span * 16 ) );
painter.setPen( QPen( palette().color( QPalette::Active, QPalette::Background ), barWidth ) );
if ( true == isLeft )
{
painter.translate( QPoint( cRedLineWidth, 0 ) );
painter.drawArc( middleRect, int( leftStartAngle - ( blackSpan / 2 ) ), blackSpan );
}
else
{
painter.translate( QPoint( -cRedLineWidth, 0 ) );
painter.drawArc( middleRect, int( rightStartAngle- ( blackSpan / 2 ) ), blackSpan );
}
// Grey bit.
span -= ( cBlackLineWidth / 3 );
int greyBarWidth( barWidth - ( cBlackLineWidth * 3 ) );
int greySpan( int( span * 16 ) );
QColor greyColour( palette().color( QPalette::Disabled, QPalette::Text ) );
greyColour.setAlpha( 100 );
painter.setPen( QPen( greyColour, greyBarWidth ) );
if ( true == isLeft )
{
painter.translate( QPoint( cBlackLineWidth / 3, 0 ) );
painter.drawArc( middleRect, int( leftStartAngle - ( greySpan / 2 ) ), greySpan );
painter.translate( QPoint( -cBlackLineWidth / 3, 0 ) );
}
else
{
painter.translate( QPoint( -cBlackLineWidth / 3, 0 ) );
painter.drawArc( middleRect, int( rightStartAngle - ( greySpan / 2 ) ), greySpan );
painter.translate( QPoint( cBlackLineWidth / 3, 0 ) );
}
// White bit
if ( value > 0 )
{
painter.setPen( QPen( palette().color( QPalette::Active, QPalette::Text ), greyBarWidth ) );
float fillPercentage( qBound( 0.0f, ( 1 / data.Max() ) * value, 1.0f ) );
int fillSpan( int( span * fillPercentage * 16 ) );
// Adjust the value to take into account the line thickness.
if ( fillSpan > greyBarWidth )
{
fillSpan -= int( greyBarWidth );
//.........这里部分代码省略.........
开发者ID:dulton,项目名称:53_hero,代码行数:101,代码来源:tRepowerMotoringWidgetSimrad.cpp
示例13: function
/*!
\internal
effectiveSizeHint has a quirky behavior, one of the quirkinesses is when the hfw function is
combined with user-specified min/max sizes. The input to hfw function (e.g width) must be within
the min/max width constraint, and the output must be within the min/max height. This sets up a
loose dependency between minimum width and maximum height (or minimum height, depending on the
type of hfw function). Note that its only the concrete subclass that implements that hfw
function that knows if this dependency means that the height will increase or decrease when the
width is increased.
The application should try to ensure that the user-defined sizes are within the range so that
they don't conflict with the hfw function.
Suppose, for instance that the hfw function is:
height = 2000/width
and the item has these user-defined sizes:
min ( 5, 5)
pref(100, 10)
max (500,100)
what is the return value if one calls item->effectiveSizeHint(Qt::MinimumSize, QSizeF(10, -1)); ?
The sizeHint() function would return QSizeF(10, 200), but it would be bounded down to 100 due
to the max value, so it would return (10, 100). This is not what the item expects, since it
really wants that its hfw is respected. If this is a label with wrapped text, this would most
likely lead to that some text is clipped. This is certainly not what the app developer wants.
Now, it would be better if the user changed those constraints to match the hfw function:
min ( 20, 5)
pref(100, 10)
max (500,100)
here, it says that the width cannot be smaller than 20. This is because if it becomes smaller
than 20 the result of the hfw function would violate the max height (100).
However, there is a similar problem if the width passed to the hfw function reaches *max* width:
the sizeHint() function would now return QSizeF(500, 4), but 4 is smaller than the minimum
height (5), so effectiveSizeHint() would return (500, 5), which would leave too much space.
In this case, setting the max width to 400 fixes the problem:
min ( 20, 5)
pref(100, 10)
max (400,100)
The implementor of a hfw widget must be aware of this when sizeHint() is reimplemented, so that
the default min and max sizes works sensible. (unfortunately the implementor does not have the
control over user-set values).
*/
QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint) const
{
Q_Q(const QGraphicsLayoutItem);
QSizeF *sizeHintCache;
const bool hasConstraint = constraint.width() >= 0 || constraint.height() >= 0;
QSizeF adjustedConstraint = constraint;
if (hasConstraint) {
if (!sizeHintWithConstraintCacheDirty && constraint == cachedConstraint)
return cachedSizeHintsWithConstraints;
const QSizeF *hintsWithoutConstraint = effectiveSizeHints(QSizeF(-1,-1));
if (adjustedConstraint.width() >= 0)
adjustedConstraint.setWidth( qBound( hintsWithoutConstraint[Qt::MinimumSize].width(),
adjustedConstraint.width(),
hintsWithoutConstraint[Qt::MaximumSize].width()));
if (adjustedConstraint.height() >= 0)
adjustedConstraint.setHeight( qBound( hintsWithoutConstraint[Qt::MinimumSize].height(),
adjustedConstraint.height(),
hintsWithoutConstraint[Qt::MaximumSize].height()));
if (!sizeHintWithConstraintCacheDirty && adjustedConstraint == cachedConstraint)
return cachedSizeHintsWithConstraints;
sizeHintCache = cachedSizeHintsWithConstraints;
} else {
if (!sizeHintCacheDirty)
return cachedSizeHints;
sizeHintCache = cachedSizeHints;
}
for (int i = 0; i < Qt::NSizeHints; ++i) {
sizeHintCache[i] = adjustedConstraint;
if (userSizeHints)
combineSize(sizeHintCache[i], userSizeHints[i]);
}
QSizeF &minS = sizeHintCache[Qt::MinimumSize];
QSizeF &prefS = sizeHintCache[Qt::PreferredSize];
QSizeF &maxS = sizeHintCache[Qt::MaximumSize];
QSizeF &descentS = sizeHintCache[Qt::MinimumDescent];
normalizeHints(minS.rwidth(), prefS.rwidth(), maxS.rwidth(), descentS.rwidth());
normalizeHints(minS.rheight(), prefS.rheight(), maxS.rheight(), descentS.rheight());
// if the minimum, preferred and maximum sizes contradict each other
// (e.g. the minimum is larger than the maximum) we give priority to
//.........这里部分代码省略.........
开发者ID:Afreeca,项目名称:qt,代码行数:101,代码来源:qgraphicslayoutitem.cpp
示例14: ASSERT
void PropagateUploadFileNG::slotPutFinished()
{
PUTFileJob *job = qobject_cast<PUTFileJob *>(sender());
ASSERT(job);
slotJobDestroyed(job); // remove it from the _jobs list
propagator()->_activeJobList.removeOne(this);
if (_finished) {
// We have sent the finished signal already. We don't need to handle any remaining jobs
return;
}
QNetworkReply::NetworkError err = job->reply()->error();
if (err != QNetworkReply::NoError) {
_item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
commonErrorHandling(job);
return;
}
ENFORCE(_sent <= _item->_size, "can't send more than size");
// Adjust the chunk size for the time taken.
//
// Dynamic chunk sizing is enabled if the server configured a
// target duration for each chunk upload.
double targetDuration = propagator()->syncOptions()._targetChunkUploadDuration;
if (targetDuration > 0) {
double uploadTime = job->msSinceStart() + 1; // add one to avoid div-by-zero
auto predictedGoodSize = static_cast<quint64>(
_currentChunkSize / uploadTime * targetDuration);
// The whole targeting is heuristic. The predictedGoodSize will fluctuate
// quite a bit because of external factors (like available bandwidth)
// and internal factors (like number of parallel uploads).
//
// We use an exponential moving average here as a cheap way of smoothing
// the chunk sizes a bit.
quint64 targetSize = (propagator()->_chunkSize + predictedGoodSize) / 2;
// Adjust the dynamic chunk size _chunkSize used for sizing of the item's chunks to be send
propagator()->_chunkSize = qBound(
propagator()->syncOptions()._minChunkSize,
targetSize,
propagator()->syncOptions()._maxChunkSize);
qCInfo(lcPropagateUpload) << "Chunked upload of" << _currentChunkSize << "bytes took" << uploadTime
<< "ms, desired is" << targetDuration << "ms, expected good chunk size is"
<< predictedGoodSize << "bytes and nudged next chunk size to "
<< propagator()->_chunkSize << "bytes";
}
bool finished = _sent == _item->_size;
// Check if the file still exists
const QString fullFilePath(propagator()->getFilePath(_item->_file));
if (!FileSystem::fileExists(fullFilePath)) {
if (!finished) {
abortWithError(SyncFileItem::SoftError, tr("The local file was removed during sync."));
return;
} else {
propagator()->_anotherSyncNeeded = true;
}
}
// Check whether the file changed since discovery.
if (!FileSystem::verifyFileUnchanged(fullFilePath, _item->_size, _item->_modtime)) {
propagator()->_anotherSyncNeeded = true;
if (!finished) {
abortWithError(SyncFileItem::SoftError, tr("Local file changed during sync."));
return;
}
}
if (!finished) {
// Deletes an existing blacklist entry on successful chunk upload
if (_item->_hasBlacklistEntry) {
propagator()->_journal->wipeErrorBlacklistEntry(_item->_file);
_item->_hasBlacklistEntry = false;
}
// Reset the error count on successful chunk upload
auto uploadInfo = propagator()->_journal->getUploadInfo(_item->_file);
uploadInfo._errorCount = 0;
propagator()->_journal->setUploadInfo(_item->_file, uploadInfo);
propagator()->_journal->commit("Upload info");
}
startNextChunk();
}
开发者ID:uniblockchain,项目名称:client,代码行数:92,代码来源:propagateuploadng.cpp
|
请发表评论