本文整理汇总了C++中qCeil函数的典型用法代码示例。如果您正苦于以下问题:C++ qCeil函数的具体用法?C++ qCeil怎么用?C++ qCeil使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qCeil函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: extent
/*!
Calculate the minimum length that is needed to draw the scale
\param font Font used for painting the labels
\sa extent()
*/
int QwtScaleDraw::minLength( const QFont &font ) const
{
int startDist, endDist;
getBorderDistHint( font, startDist, endDist );
const QwtScaleDiv &sd = scaleDiv();
const uint minorCount =
sd.ticks( QwtScaleDiv::MinorTick ).count() +
sd.ticks( QwtScaleDiv::MediumTick ).count();
const uint majorCount =
sd.ticks( QwtScaleDiv::MajorTick ).count();
int lengthForLabels = 0;
if ( hasComponent( QwtAbstractScaleDraw::Labels ) )
{
if ( majorCount >= 2 )
lengthForLabels = minLabelDist( font ) * ( majorCount - 1 );
}
int lengthForTicks = 0;
if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
{
const double pw = qMax( 1, penWidth() ); // penwidth can be zero
lengthForTicks = qCeil( ( majorCount + minorCount ) * ( pw + 1.0 ) );
}
return startDist + endDist + qMax( lengthForLabels, lengthForTicks );
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:36,代码来源:qwt_scale_draw.cpp
示例2: sizeHint
/*!
\return Minimum size hint
\warning The return value depends on the font and the scale.
\sa sizeHint()
*/
QSize QwtThermo::minimumSizeHint() const
{
int w = 0, h = 0;
if ( d_data->scalePosition != NoScale )
{
const int sdExtent = qCeil( scaleDraw()->extent( font() ) );
const int sdLength = scaleDraw()->minLength( font() );
w = sdLength;
h = d_data->pipeWidth + sdExtent + d_data->spacing;
}
else // no scale
{
w = 200;
h = d_data->pipeWidth;
}
if ( d_data->orientation == Qt::Vertical )
qSwap( w, h );
w += 2 * d_data->borderWidth;
h += 2 * d_data->borderWidth;
// finally add the margins
int left, right, top, bottom;
getContentsMargins( &left, &top, &right, &bottom );
w += left + right;
h += top + bottom;
return QSize( w, h );
}
开发者ID:151706061,项目名称:sofa,代码行数:38,代码来源:qwt_thermo.cpp
示例3: qInf
qreal SoftSlider::tickSpan(qreal min, qreal max, qreal space, qreal minsep)
{
if (space == 0)
return qInf();
qreal jmp = minsep * (max - min) / space;
qreal b = 1;
while (b * 10 <= jmp)
b *= 10;
if (jmp > 0)
while (b / 10 >= jmp)
b /= 10;
int q = qCeil(jmp / b);
if (q > 5)
return b * 10;
if (q > 2)
return b * 5;
if (q > 1)
return b * 2;
return b;
}
开发者ID:Michalaq,项目名称:ChromosomeVisualizer,代码行数:29,代码来源:softslider.cpp
示例4: line
void QSGTextNode::addTextDecorations(Decoration decorations, const QPointF &position,
const QColor &color, qreal width, qreal lineThickness,
qreal underlinePos, qreal ascent)
{
QRectF line(position.x(), position.y() - lineThickness / 2.0, width, lineThickness);
if (decorations & Underline) {
int underlinePosition = qCeil(underlinePos);
QRectF underline(line);
underline.translate(0.0, underlinePosition);
appendChildNode(new QSGSimpleRectNode(underline, color));
}
if (decorations & Overline) {
QRectF overline(line);
overline.translate(0.0, -ascent);
appendChildNode(new QSGSimpleRectNode(overline, color));
}
if (decorations & StrikeOut) {
QRectF strikeOut(line);
strikeOut.translate(0.0, ascent / -3.0);
appendChildNode(new QSGSimpleRectNode(strikeOut, color));
}
}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:25,代码来源:qsgtextnode.cpp
示例5: Q_D
void QDeclarativeRectangle::generateRoundedRect()
{
Q_D(QDeclarativeRectangle);
if (d->rectImage.isNull()) {
const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
const int radius = qCeil(d->radius); //ensure odd numbered width/height so we get 1-pixel center
QString key = QLatin1String("q_") % QString::number(pw) % d->color.name() % QString::number(d->color.alpha(), 16) % QLatin1Char('_') % QString::number(radius);
if (d->pen && d->pen->isValid())
key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16);
if (!QPixmapCache::find(key, &d->rectImage)) {
d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
d->rectImage.fill(Qt::transparent);
QPainter p(&(d->rectImage));
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
p.setPen(pn);
} else {
p.setPen(Qt::NoPen);
}
p.setBrush(d->color);
if (pw%2)
p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius);
else
p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius);
// end painting before inserting pixmap
// to pixmap cache to avoid a deep copy
p.end();
QPixmapCache::insert(key, d->rectImage);
}
}
}
开发者ID:maxxant,项目名称:qt,代码行数:35,代码来源:qdeclarativerectangle.cpp
示例6: qCeil
// Set waveform sample rate.
void SpikePlot_CV::setSampleRate(double newSampleRate)
{
// Calculate time step, in msec.
tStepMsec = 1000.0 / newSampleRate;
// Calculate number of time steps in 3 msec sample.
totalTSteps = qCeil(3.0 / tStepMsec) + 1;
// Calculate number of time steps in the 1 msec pre-trigger
// display interval.
preTriggerTSteps = qCeil(1.0 / tStepMsec);
// Clear old waveforms since the sample rate has changed.
numSpikeWaveforms = 0;
startingNewChannel = true;
}
开发者ID:hybridsytemslab,项目名称:intan_cv,代码行数:17,代码来源:spikeplot_cv.cpp
示例7: qCeil
/*virtual*/
int ListItemContainer::maxItemCountInItemBuffer() const
{
int count = AbstractItemContainer::maxItemCountInItemBuffer();
if (count > 0) {
int currentItemCount = m_items.count();
qreal heightOfOneItem = 0;
if (currentItemCount > 0)
{
heightOfOneItem = m_layout->effectiveSizeHint(Qt::PreferredSize).height() / currentItemCount;
}
int guess = 0;
if( heightOfOneItem <= 0 ) {
if (m_prototype) {
heightOfOneItem = m_prototype->effectiveSizeHint(Qt::PreferredSize).height();
}
else
heightOfOneItem = 50; // TODO magic number, do we have better guess if prototype is not set?
}
if (heightOfOneItem > 0) {
guess = qCeil(m_itemView->boundingRect().height() / heightOfOneItem) + m_bufferSize;
if (guess < currentItemCount) {
if( guess > currentItemCount-2) { // TODO magic number here, Can we use buffer size?
guess = currentItemCount;
}
}
}
count = qMin(guess, count);
}
return count;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:33,代码来源:listitemcontainer.cpp
示例8: qCeil
void Downloader::getTags()
{
if (m_sites->empty())
{
std::cerr << "No valid source found" << std::endl;
return;
}
m_waiting = 0;
m_cancelled = false;
for (int i = 0; i < m_sites->size(); ++i)
{
int pages = qCeil((float)m_max / m_perpage);
if (pages <= 0 || m_perpage <= 0 || m_max <= 0)
pages = 1;
Site *site = m_sites->at(i);
connect(site, &Site::finishedLoadingTags, this, &Downloader::finishedLoadingTags);
for (int p = 0; p < pages; ++p)
{
m_pagesP->append(QPair<Site*, int>(site, m_page + p));
m_opagesP->append(QPair<Site*, int>(site, m_page + p));
m_waiting++;
}
}
loadNext();
}
开发者ID:AJKproductions,项目名称:imgbrd-grabber,代码行数:28,代码来源:downloader.cpp
示例9: ceil_with_tolerance
static double ceil_with_tolerance( double value )
{
if ( qAbs( value - qRound( value ) ) < 1e-6 )
return qRound( value );
else
return qCeil( value );
}
开发者ID:giserfly,项目名称:QGIS,代码行数:7,代码来源:qgsalignraster.cpp
示例10: axisScaleEngine
void SingleCellViewGraphPanelPlotWidget::optimiseAxis(const int &pAxisId,
double &pMin,
double &pMax) const
{
// Make sure that the given values are different
if (pMin == pMax) {
// The given values are the same, so update them so that we can properly
// optimise them below
double powerValue = pMin?qFloor(log10(qAbs(pMin)))-1.0:0.0;
pMin = pMin-pow(10.0, powerValue);
pMax = pMax+pow(10.0, powerValue);
}
// Optimise the axis' values so that they fall onto a factor of the axis'
// minor step
uint base = axisScaleEngine(pAxisId)->base();
double majorStep = QwtScaleArithmetic::divideInterval(pMax-pMin,
axisMaxMajor(pAxisId),
base);
double minorStep = QwtScaleArithmetic::divideInterval(majorStep,
axisMaxMinor(pAxisId),
base);
pMin = qFloor(pMin/minorStep)*minorStep;
pMax = qCeil(pMax/minorStep)*minorStep;
}
开发者ID:Fairly,项目名称:opencor,代码行数:30,代码来源:singlecellviewgraphpanelplotwidget.cpp
示例11: qMin
//--------------------------------------------------------------------------------------------------
// FUNCTION: paint
//--------------------------------------------------------------------------------------------------
void QProgressBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
double progress = index.data(QExecutableModel::ProgressRole).toDouble() * 100;
if (std::isnan(progress) || progress <= 0.0 || progress >= 100.0)
{
QStyledItemDelegate::paint(painter, option, index);
}
else
{
const QFontMetrics &fm = option.fontMetrics;
auto height = qMin(qCeil(QFontMetricsF(fm).height()) + 2, option.rect.height());
int adjust = (option.rect.height() - height) / 2;
double progress = index.data(QExecutableModel::ProgressRole).toDouble() * 100;
QStyleOptionProgressBar progressBarOption;
progressBarOption.rect = option.rect.adjusted(2, adjust, -2, -adjust);
progressBarOption.rect.setWidth(option.rect.width() - 2 * 2);
progressBarOption.minimum = 0;
progressBarOption.maximum = 100;
progressBarOption.progress = progress;
if (option.state & QStyle::State_Selected)
{
painter->setBrush(option.palette.highlightedText());
}
QApplication::style()->drawControl(QStyle::CE_ProgressBar,
&progressBarOption, painter);
}
}
开发者ID:kclouden,项目名称:gtest-runner,代码行数:34,代码来源:executableModelDelegate.cpp
示例12: qBound
void LanczosShader::createKernel(float delta, int *size)
{
const float a = 2.0;
// The two outermost samples always fall at points where the lanczos
// function returns 0, so we'll skip them.
const int sampleCount = qBound(3, qCeil(delta * a) * 2 + 1 - 2, 29);
const int center = sampleCount / 2;
const int kernelSize = center + 1;
const float factor = 1.0 / delta;
QVector<float> values(kernelSize);
float sum = 0;
for (int i = 0; i < kernelSize; i++) {
const float val = lanczos(i * factor, a);
sum += i > 0 ? val * 2 : val;
values[i] = val;
}
memset(m_kernel, 0, 16 * sizeof(QVector4D));
// Normalize the kernel
for (int i = 0; i < kernelSize; i++) {
const float val = values[i] / sum;
m_kernel[i] = QVector4D(val, val, val, val);
}
*size = kernelSize;
}
开发者ID:mgottschlag,项目名称:kwin-tiling,代码行数:30,代码来源:lanczosfilter.cpp
示例13: sizeHint
/*!
\brief Return a minimum size hint
\warning The return value depends on the font and the scale.
\sa sizeHint()
*/
QSize QwtThermo::minimumSizeHint() const
{
int w = 0, h = 0;
if ( d_data->scalePos != NoScale )
{
const int sdExtent = qCeil( scaleDraw()->extent( font() ) );
const int sdLength = scaleDraw()->minLength( font() );
w = sdLength;
h = d_data->thermoWidth + sdExtent +
d_data->borderWidth + d_data->scaleDist;
}
else // no scale
{
w = 200;
h = d_data->thermoWidth;
}
if ( d_data->orientation == Qt::Vertical )
qSwap( w, h );
w += 2 * d_data->borderWidth;
h += 2 * d_data->borderWidth;
return QSize( w, h );
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:33,代码来源:qwt_thermo.cpp
示例14: qCeil
void TextDocument::drawBackground(QPainter* painter, const QRect& bounds)
{
if (d.highlights.isEmpty() && d.lowlight == -1)
return;
const int margin = qCeil(documentMargin());
const QAbstractTextDocumentLayout* layout = documentLayout();
static QPointer<TextLowlight> lowlightFrame = 0;
if (!lowlightFrame)
lowlightFrame = new TextLowlight(static_cast<QWidget*>(painter->device()));
static QPointer<TextHighlight> highlightFrame = 0;
if (!highlightFrame)
highlightFrame = new TextHighlight(static_cast<QWidget*>(painter->device()));
if (d.lowlight != -1) {
const QAbstractTextDocumentLayout* layout = documentLayout();
const int margin = qCeil(documentMargin());
const QTextBlock to = findBlockByNumber(d.lowlight);
if (to.isValid()) {
QRect br = layout->blockBoundingRect(to).toAlignedRect();
br.setTop(0);
if (bounds.intersects(br)) {
br.adjust(-margin - 1, 0, margin + 1, 2);
painter->translate(br.topLeft());
lowlightFrame->setGeometry(br);
lowlightFrame->render(painter);
painter->translate(-br.topLeft());
}
}
}
foreach (int highlight, d.highlights) {
QTextBlock block = findBlockByNumber(highlight);
if (block.isValid()) {
QRect br = layout->blockBoundingRect(block).toAlignedRect();
if (bounds.intersects(br)) {
br.adjust(-margin - 1, 0, margin + 1, 2);
painter->translate(br.topLeft());
highlightFrame->setGeometry(br);
highlightFrame->render(painter);
painter->translate(-br.topLeft());
}
}
}
}
开发者ID:rburchell,项目名称:communi-desktop,代码行数:47,代码来源:textdocument.cpp
示例15: QTableWidget
lmcImagePicker::lmcImagePicker(
QWidget *parent,
QList<QString>* source,
int picSize,
int columns,
int* selected,
int actionIndex )
: QTableWidget(parent)
{
setMouseTracking(true);
setBackgroundRole(QPalette::Window);
setIconSize(QSize(picSize, picSize));
setFrameShape(QFrame::NoFrame);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setEditTriggers(QAbstractItemView::NoEditTriggers);
setSelectionMode(QAbstractItemView::NoSelection);
setShowGrid(false);
horizontalHeader()->setVisible(false);
verticalHeader()->setVisible(false);
setStyleSheet("QTableWidget { padding: 4px }"); // padding around table
max_col = columns;
int max_row = qCeil(source->count() / (qreal)max_col);
setColumnCount(max_col);
setRowCount(max_row);
int cellSize = picSize + 8;
verticalHeader()->setDefaultSectionSize(cellSize);
verticalHeader()->setMinimumSectionSize(cellSize);
horizontalHeader()->setDefaultSectionSize(cellSize);
horizontalHeader()->setMinimumSectionSize(cellSize);
// set min and max size of table, with padding included
setMinimumSize(max_col * cellSize + 8, max_row * cellSize + 8);
setMaximumSize(max_col * cellSize + 8, max_row * cellSize + 8);
for(int i = 0; i < max_row; i++) {
for(int j = 0; j < max_col; j++) {
int k = (i * max_col) + j;
QTableWidgetItem* item = new QTableWidgetItem();
item->setData(TypeRole, 0);
if(k < source->count()) {
item->setIcon(QIcon(source->value(k)));
item->setData(TypeRole, 1);
item->setSizeHint(QSize(picSize, picSize));
item->setBackground(this->palette().window());
}
setItem(i, j, item);
}
}
this->actionIndex = actionIndex;
this->selected = selected;
this->hoverItem = NULL;
}
开发者ID:sonic414,项目名称:lmc-clone,代码行数:59,代码来源:imagepicker.cpp
示例16: qCeil
/*!
\brief Return a minimum size hint
\warning The return value of QwtKnob::minimumSizeHint() depends on the
font and the scale.
*/
QSize QwtKnob::minimumSizeHint() const
{
// Add the scale radial thickness to the knobWidth
const int sh = qCeil( scaleDraw()->extent( font() ) );
const int d = 2 * sh + 2 * d_data->scaleDist + d_data->knobWidth;
return QSize( d, d );
}
开发者ID:TheLortex,项目名称:Robotique-MJC-2011,代码行数:13,代码来源:qwt_knob.cpp
示例17: qCeil
void SourceEditor::linesCountChanged()
{
int marginWidth = qCeil( qLn( lines() ) / qLn(10) + 0.000001 );
if (marginWidth != m_marginWidth) {
m_marginWidth = marginWidth;
setMarginWidth(NumberMargin, QString(marginWidth, '3') + ' ');
}
}
开发者ID:olegwtf,项目名称:wside,代码行数:9,代码来源:sourceeditor.cpp
示例18: qFloor
void QSvgAnimateColor::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &)
{
qreal totalTimeElapsed = node->document()->currentElapsed();
if (totalTimeElapsed < m_from || m_finished)
return;
qreal animationFrame = 0;
if (m_totalRunningTime != 0)
animationFrame = (totalTimeElapsed - m_from) / m_totalRunningTime;
if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
m_finished = true;
animationFrame = m_repeatCount;
}
qreal percentOfAnimation = animationFrame;
if (percentOfAnimation > 1) {
percentOfAnimation -= ((int)percentOfAnimation);
}
qreal currentPosition = percentOfAnimation * (m_colors.count() - 1);
int startElem = qFloor(currentPosition);
int endElem = qCeil(currentPosition);
QColor start = m_colors[startElem];
QColor end = m_colors[endElem];
qreal percentOfColorMorph = currentPosition;
if (percentOfColorMorph > 1) {
percentOfColorMorph -= ((int)percentOfColorMorph);
}
// Interpolate between the two fixed colors start and end
qreal aDiff = (end.alpha() - start.alpha()) * percentOfColorMorph;
qreal rDiff = (end.red() - start.red()) * percentOfColorMorph;
qreal gDiff = (end.green() - start.green()) * percentOfColorMorph;
qreal bDiff = (end.blue() - start.blue()) * percentOfColorMorph;
int alpha = int(start.alpha() + aDiff);
int red = int(start.red() + rDiff);
int green = int(start.green() + gDiff);
int blue = int(start.blue() + bDiff);
QColor color(red, green, blue, alpha);
if (m_fill) {
QBrush b = p->brush();
m_oldBrush = b;
b.setColor(color);
p->setBrush(b);
} else {
QPen pen = p->pen();
m_oldPen = pen;
pen.setColor(color);
p->setPen(pen);
}
}
开发者ID:wpbest,项目名称:copperspice,代码行数:57,代码来源:qsvgstyle.cpp
示例19: qwtExpandToPixels
static QRectF qwtExpandToPixels(const QRectF &rect, const QRectF &pixelRect)
{
const double pw = pixelRect.width();
const double ph = pixelRect.height();
const double dx1 = pixelRect.left() - rect.left();
const double dx2 = pixelRect.right() - rect.right();
const double dy1 = pixelRect.top() - rect.top();
const double dy2 = pixelRect.bottom() - rect.bottom();
QRectF r;
r.setLeft( pixelRect.left() - qCeil( dx1 / pw ) * pw );
r.setTop( pixelRect.top() - qCeil( dy1 / ph ) * ph );
r.setRight( pixelRect.right() - qFloor( dx2 / pw ) * pw );
r.setBottom( pixelRect.bottom() - qFloor( dy2 / ph ) * ph );
return r;
}
开发者ID:wangyun123,项目名称:Third,代码行数:18,代码来源:qwt_plot_rasteritem.cpp
示例20: averageCharacterWidth
int averageCharacterWidth(const QFont& font) {
const QFontMetrics metrics(font);
int totalWidth = 0;
for (int i = 32; i < 128; ++i) {
totalWidth += metrics.width(QChar(i));
}
return qCeil(totalWidth/97.);
}
开发者ID:zjucsxxd,项目名称:Cstitch,代码行数:9,代码来源:utility.cpp
注:本文中的qCeil函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论