本文整理汇总了C++中qFloor函数的典型用法代码示例。如果您正苦于以下问题:C++ qFloor函数的具体用法?C++ qFloor怎么用?C++ qFloor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qFloor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getSubLayer
void Layer::dab(int contextId, const Brush &brush, const Point &point)
{
Brush effective_brush = brush;
Layer *l = this;
if(!brush.incremental()) {
// Indirect brush: use a sublayer
l = getSubLayer(contextId, brush.blendingMode(), brush.opacity(1) * 255);
effective_brush.setOpacity(1.0);
effective_brush.setOpacity2(brush.isOpacityVariable() ? 0.0 : 1.0);
effective_brush.setBlendingMode(1);
} else if(contextId<0) {
// Special case: negative context IDs are temporary overlay strokes
l = getSubLayer(contextId, brush.blendingMode(), 255);
effective_brush.setBlendingMode(1);
}
Point p = point;
if(!effective_brush.subpixel()) {
p.setX(qFloor(p.x()));
p.setY(qFloor(p.y()));
}
l->directDab(effective_brush, BrushMaskGenerator::cached(effective_brush), p);
if(_owner)
_owner->notifyAreaChanged();
}
示例3: qFloor
void Grid::pressedSlot(qreal x, qreal y)
{
int x_send = qFloor(x_last + (x - 0.5) * SCREEN_WIDTH);
int y_send = qFloor(y_last + (y - 0.5) * SCREEN_HEIGHT);
qDebug() << (x - x_last) << "\t" << x_last;
qDebug() << "x: " << x << "y: " << y << "\t pressed\t" << "x send: " <<
x_send << "y send: " << y_send;
if ( x_send < 0 || y_send < 0 || x_send > X_MAX || y_send > Y_MAX)
{
qDebug() << "Entered Dead Zone!!!";
return;
}
char writeBuffer[WRITE_BUFFER_LENGTH];
sprintf(writeBuffer,"%d %d\n",x_send,y_send);
qint64 bytesWritten = port->write(writeBuffer);
qDebug() << bytesWritten << "is written.";
x_last += (x - 0.5) * SCREEN_WIDTH;
y_last += (y - 0.5) * SCREEN_HEIGHT;
}
示例4: qFloor
const QString & Transport::getTimeLocalStr() {
timeLocalStr = "";
qreal timeLocalCopy = timeLocal;
quint16 hour = qFloor(timeLocalCopy / 3600);
if(hour < 10) timeLocalStr += "0";
timeLocalStr += QString::number(hour) + ":";
timeLocalCopy -= hour*3600;
quint16 min = qFloor(timeLocalCopy / 60);
if(min < 10) timeLocalStr += "0";
timeLocalStr += QString::number(min) + ":";
timeLocalCopy -= min*60;
quint8 sec = qFloor(timeLocalCopy);
if(sec < 10) timeLocalStr += "0";
timeLocalStr += QString::number(sec) + ":";
timeLocalCopy -= sec;
quint16 milli = (timeLocalCopy - qFloor(timeLocalCopy)) * 1000;
if(milli < 10) timeLocalStr += "00";
else if(milli < 100) timeLocalStr += "0";
timeLocalStr += QString::number(milli);
return timeLocalStr;
}
示例5: qFloor
QColor iA3DObjectVis::getOrientationColor( vtkImageData* oi, size_t objID ) const
{
int ip = qFloor( m_objectTable->GetValue( objID, m_columnMapping->value(iACsvConfig::Phi) ).ToDouble() );
int it = qFloor( m_objectTable->GetValue( objID, m_columnMapping->value(iACsvConfig::Theta) ).ToDouble() );
double *p = static_cast<double *>( oi->GetScalarPointer( it, ip, 0 ) );
return QColor(p[0]*255, p[1]*255, p[2]*255, 255);
}
示例6: qLn
double RasterData::value(double x, double y) const
{
if (x >= 0 && x < Statistic::SCREEN_SIZE &&
y >= 0 && y < Statistic::SCREEN_SIZE)
return d[qFloor(x)][qFloor(y)] > 0 ? qLn(d[qFloor(x)][qFloor(y)]) : 0.0;
return 0.0;
}
示例7: qFloor
bool OsmAnd::Frustum2D31::test(const PointI& p_) const
{
AreaI64 bbox;
bbox.topLeft = bbox.bottomRight = p0;
bbox.enlargeToInclude(p1);
bbox.enlargeToInclude(p2);
bbox.enlargeToInclude(p3);
const auto tilesCount = static_cast<int64_t>(1ull << ZoomLevel31);
const auto xMinK = qFloor(static_cast<double>(bbox.left()) / tilesCount);
const auto xMaxK = qCeil(static_cast<double>(bbox.right()) / tilesCount);
const auto yMinK = qFloor(static_cast<double>(bbox.top()) / tilesCount);
const auto yMaxK = qCeil(static_cast<double>(bbox.bottom()) / tilesCount);
PointI64 dP;
const PointI64 p(p_);
for (auto xK = xMinK; xK <= xMaxK; xK++)
{
dP.x = tilesCount * xK;
for (auto yK = yMinK; yK <= yMaxK; yK++)
{
dP.y = tilesCount * yK;
if (Frustum2DI64::test(p + dP))
return true;
}
}
return false;
}
示例8: drawHist
void drawHist(QGraphicsPixmapItem *pixmapItem, std::vector<int> &hist, int maxLevel)
{
QGraphicsScene *scene = pixmapItem->scene();
QGraphicsView *view = scene->views()[0];
int width = view->contentsRect().width();
int height = view->contentsRect().height();
QColor black(0, 0, 0);
QColor white(255, 255, 255);
QColor red(255, 0, 0);
QImage image(width, height, QImage::Format_ARGB32);
image.fill(white);
QPainter p(&image);
double shift = (double) image.width() / hist.size();
double step = (double) image.height() / maxLevel;
for (unsigned int i = 0; i < hist.size(); ++i)
{
if (i == 0 || i == hist.size() - 1)
{
p.setPen(red);
p.setBrush(QBrush(red));
}
else if (i == 1)
{
p.setPen(black);
p.setBrush(QBrush(black));
}
if (hist[i] == 0)
continue;
int curHeight = hist[i] * step;
p.drawRect(qFloor(i * shift), qFloor(image.height() - curHeight), qFloor(shift), qFloor(curHeight));
}
pixmapItem->setPixmap(QPixmap::fromImage(image));
scene->setSceneRect(QRectF(image.rect()));
}
示例9: findTimeTickIncrement
void PlotAxes::setGeometry(const QRect& rect) {
this->rect = rect;
linX.set(minTime, rect.left(), maxTime, rect.right());
linY.set(min, rect.bottom(), max, rect.top());
qreal tick;
/// time axis:
tick = findTimeTickIncrement(maxTime - minTime, rect.width(), TICK_SPACING_X);
this->timeInterval = tick;
tickCountX = qFloor((maxTime-minTime) / tick) + 1;
this->startTimeTick = tick * qCeil(minTime / tick);
tickX = linX.compose(Util::LinearFunc(tick, startTimeTick));
/// vertical axis:
tick = findTickIncrement(max - min, rect.height(), TICK_SPACING_Y);
this->first = tick * qCeil(min / tick);
tickCountY = qFloor((max - first) / tick) + 1;
tickY = linY.compose(Util::LinearFunc(tick, first));
this->step = tick;
if (min > 0) {
base = rect.bottom();
} else if (max < 0) {
base = rect.top();
} else {
base = linY.get(0);
}
emitGeometryChanged();
}
示例10: QString
void XPLANEFlightSimData::parseInputData(QByteArray InputData)
{
//altitude, latitude, longitude,vertspeed, groundspeed, indicatedairspeed, machspeed, payloadweight, totalweight, fueltotalweight, counter, heading, utc, lcl
QList<QByteArray> newdata = InputData.split(';');
if (newdata.length() < 11)
return;
mfGroundSpeed = QString(newdata.at(4)).toFloat();
mfIAS = QString(newdata.at(5)).toFloat();
mfMach = QString(newdata.at(6)).toFloat();
mdLatitude = QString(newdata.at(1)).toDouble();
mdLongitude = QString(newdata.at(2)).toDouble();
mfAltitude = QString(newdata.at(0)).toFloat();
mfHeading = QString(newdata.at(11)).toFloat();
m_LCLTime = QTime(0,0,0);
m_LCLTime = m_LCLTime.addSecs(qFloor(QString(newdata.at(13)).toFloat()));
m_UTCTime = QTime(0,0,0);
m_UTCTime = m_UTCTime.addSecs(qFloor(QString(newdata.at(12)).toFloat()));
qDebug() << QString(newdata.at(12));
qDebug() << QString(newdata.at(13));
((ACARSSystem*)this->parent())->eventFilter((QObject*)this, ((QEvent*) new ACARSMenuViewEvent(ACARSEVENT::FSUPDATEEVENT)));
}
示例11: r
void SessionsInner::paintEvent(QPaintEvent *e) {
QRect r(e->rect());
Painter p(this);
p.fillRect(r, st::white->b);
p.setFont(st::linkFont->f);
int32 x = st::sessionPadding.left(), xact = st::sessionTerminateSkip + st::sessionTerminate.iconPos.x();// st::sessionTerminateSkip + st::sessionTerminate.width + st::sessionTerminateSkip;
int32 w = width();
int32 from = (r.top() >= 0) ? qFloor(r.top() / st::sessionHeight) : 0, count = _list->size();
if (from < count) {
int32 to = (r.bottom() >= 0 ? qFloor(r.bottom() / st::sessionHeight) : 0) + 1;
if (to > count) to = count;
p.translate(0, from * st::sessionHeight);
for (int32 i = from; i < to; ++i) {
const SessionData &auth(_list->at(i));
p.setFont(st::sessionNameFont->f);
p.setPen(st::black->p);
p.drawTextLeft(x, st::sessionPadding.top(), w, auth.name, auth.nameWidth);
p.setFont(st::sessionActiveFont->f);
p.setPen(st::sessionActiveColor->p);
p.drawTextRight(xact, st::sessionPadding.top(), w, auth.active, auth.activeWidth);
p.setFont(st::sessionInfoFont->f);
p.setPen(st::black->p);
p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, auth.info, auth.infoWidth);
p.setPen(st::sessionInfoColor->p);
p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, auth.ip, auth.ipWidth);
p.translate(0, st::sessionHeight);
}
}
}
示例12: context
void DigitizeStatePointMatch::handleMouseMove (CmdMediator *cmdMediator,
QPointF posScreen)
{
// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::handleMouseMove";
const DocumentModelPointMatch &modelPointMatch = cmdMediator->document().modelPointMatch();
m_outline->setRect (posScreen.x() - modelPointMatch.maxPointSize() / 2.0,
posScreen.y() - modelPointMatch.maxPointSize() / 2.0,
modelPointMatch.maxPointSize(),
modelPointMatch.maxPointSize());
const QImage &img = context().mainWindow().imageFiltered();
int radiusLimit = cmdMediator->document().modelGeneral().cursorSize();
bool pixelShouldBeOn = pixelIsOnInImage (img,
qFloor (posScreen.x()),
qFloor (posScreen.y()),
radiusLimit);
QColor penColorIs = m_outline->pen().color();
bool pixelIsOn = (penColorIs.red () != penColorIs.green()); // Considered on if not gray scale
if (pixelShouldBeOn != pixelIsOn) {
QColor penColorShouldBe (pixelShouldBeOn ? Qt::green : Qt::black);
m_outline->setPen (QPen (penColorShouldBe));
}
}
示例13: qFloor
bool OsmAnd::Frustum2D31::test(const PointI& lp0_, const PointI& lp1_) const
{
AreaI64 bbox;
bbox.topLeft = bbox.bottomRight = p0;
bbox.enlargeToInclude(p1);
bbox.enlargeToInclude(p2);
bbox.enlargeToInclude(p3);
const auto tilesCount = static_cast<int64_t>(1ull << ZoomLevel31);
const auto xMinK = qFloor(static_cast<double>(bbox.left()) / tilesCount);
const auto xMaxK = qCeil(static_cast<double>(bbox.right()) / tilesCount);
const auto yMinK = qFloor(static_cast<double>(bbox.top()) / tilesCount);
const auto yMaxK = qCeil(static_cast<double>(bbox.bottom()) / tilesCount);
// 3+ repeats for world include any point in world
if (qAbs(xMaxK - xMinK) >= 3 && qAbs(yMaxK - yMinK) >= 3)
return true;
PointI64 dP;
const PointI64 lp0(lp0_);
const PointI64 lp1(lp1_);
for (auto xK = xMinK; xK <= xMaxK; xK++)
{
dP.x = tilesCount * xK;
for (auto yK = yMinK; yK <= yMaxK; yK++)
{
dP.y = tilesCount * yK;
if (Frustum2DI64::test(lp0 + dP, lp1 + dP))
return true;
}
}
return false;
}
示例14: value
/*!
\brief Draw the needle
A clock has no single needle but three hands instead. drawNeedle
translates value() into directions for the hands and calls
drawHand().
\param painter Painter
\param center Center of the clock
\param radius Maximum length for the hands
\param dir Dummy, not used.
\param colorGroup ColorGroup
\sa drawHand()
*/
void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF ¢er,
double radius, double dir, QPalette::ColorGroup colorGroup ) const
{
Q_UNUSED( dir );
if ( isValid() )
{
const double hours = value() / ( 60.0 * 60.0 );
const double minutes =
( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0;
const double seconds = value() - qFloor(hours) * 60.0 * 60.0
- qFloor(minutes) * 60.0;
double angle[NHands];
angle[HourHand] = 360.0 * hours / 12.0;
angle[MinuteHand] = 360.0 * minutes / 60.0;
angle[SecondHand] = 360.0 * seconds / 60.0;
for ( int hand = 0; hand < NHands; hand++ )
{
double d = angle[hand];
if ( direction() == Clockwise )
d = 360.0 - d;
d -= origin();
drawHand( painter, ( Hand )hand, center, radius, d, colorGroup );
}
}
}
示例15: QRect
void QSGPainterNode::paint()
{
QRect dirtyRect = m_dirtyRect.isNull() ? QRect(0, 0, m_size.width(), m_size.height()) : m_dirtyRect;
QPainter painter;
if (m_actualRenderTarget == QQuickPaintedItem::Image) {
if (m_image.isNull())
return;
painter.begin(&m_image);
} else {
if (!m_gl_device) {
m_gl_device = new QOpenGLPaintDevice(m_fboSize);
m_gl_device->setPaintFlipped(true);
}
if (m_multisampledFbo)
m_multisampledFbo->bind();
else
m_fbo->bind();
painter.begin(m_gl_device);
}
if (m_smoothPainting) {
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
}
painter.scale(m_contentsScale, m_contentsScale);
QRect sclip(qFloor(dirtyRect.x()/m_contentsScale),
qFloor(dirtyRect.y()/m_contentsScale),
qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)),
qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale)));
if (!m_dirtyRect.isNull())
painter.setClipRect(sclip);
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(sclip, m_fillColor);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
m_item->paint(&painter);
painter.end();
if (m_actualRenderTarget == QQuickPaintedItem::Image) {
m_texture->setImage(m_image);
m_texture->setDirtyRect(dirtyRect);
} else if (m_multisampledFbo) {
QOpenGLFramebufferObject::blitFramebuffer(m_fbo, dirtyRect, m_multisampledFbo, dirtyRect);
}
if (m_multisampledFbo)
m_multisampledFbo->release();
else if (m_fbo)
m_fbo->release();
m_dirtyRect = QRect();
}