• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ qFloor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中qFloor函数的典型用法代码示例。如果您正苦于以下问题:C++ qFloor函数的具体用法?C++ qFloor怎么用?C++ qFloor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了qFloor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Fairly,项目名称:opencor,代码行数:30,代码来源:singlecellviewgraphpanelplotwidget.cpp


示例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();
}
开发者ID:gotomypc,项目名称:Drawpile,代码行数:30,代码来源:layer.cpp


示例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;

}
开发者ID:bijanbina,项目名称:RAIIS,代码行数:27,代码来源:grid.cpp


示例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;
}
开发者ID:aarzhaev,项目名称:IanniX,代码行数:26,代码来源:transport.cpp


示例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);
}
开发者ID:3dct,项目名称:open_iA,代码行数:7,代码来源:iA3DObjectVis.cpp


示例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;
}
开发者ID:SidneyTTW,项目名称:PCHMS-Remake,代码行数:7,代码来源:mousespectrogram.cpp


示例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;
}
开发者ID:SfietKonstantin,项目名称:OsmAnd-core,代码行数:28,代码来源:Frustum2D31.cpp


示例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()));
}
开发者ID:andrew-k-21-12,项目名称:aioi3,代码行数:34,代码来源:mainwindow.cpp


示例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();
}
开发者ID:Sylla,项目名称:updraft,代码行数:32,代码来源:plotaxes.cpp


示例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)));

}
开发者ID:mjoppich,项目名称:ACARSv4.0,代码行数:32,代码来源:XPLANEFlightSimData.cpp


示例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);
		}
	}
}
开发者ID:09120898371,项目名称:tdesktop,代码行数:34,代码来源:sessionsbox.cpp


示例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));
  }
}
开发者ID:markummitchell,项目名称:engauge-digitizer,代码行数:26,代码来源:DigitizeStatePointMatch.cpp


示例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;
}
开发者ID:Zahnstocher,项目名称:OsmAnd-core,代码行数:33,代码来源:Frustum2D31.cpp


示例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 &center,
    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 );
        }
    }
}
开发者ID:EQ4,项目名称:Visore,代码行数:45,代码来源:qwt_analog_clock.cpp


示例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();
}
开发者ID:tizenorg,项目名称:platform.upstream.qtdeclarative,代码行数:58,代码来源:qsgpainternode.cpp


示例16: LOG4CPP_DEBUG_S

int FormatCoordsUnitsStrategyAbstractBase::precisionDigitsForRawNumber (double valueUnformatted,
                                                                        double valueUnformattedOther,
                                                                        bool isXTheta,
                                                                        const DocumentModelGeneral &modelGeneral,
                                                                        const Transformation &transformation) const
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnitsStrategyAbstractBase::precisionDigitsForRawNumber";

  const double PIXEL_SHIFT = 1;
  const int DEFAULT_PRECISION = 5; // Precision used before transformation is available. Equal or greater than x/y pixel counts

  if (transformation.transformIsDefined()) {

    // Measure the resolution if the point is moved some number of pixels in screen coordinates
    QPointF posGraph;
    if (isXTheta) {

      posGraph = QPointF (valueUnformatted,
                          valueUnformattedOther);

    } else {

      posGraph = QPointF (valueUnformattedOther,
                          valueUnformatted);

    }

    QPointF posScreen, posScreenShifted, posGraphShifted;

    transformation.transformRawGraphToScreen (posGraph,
                                              posScreen);

    posScreenShifted = posScreen + QPointF (PIXEL_SHIFT, PIXEL_SHIFT);

    transformation.transformScreenToRawGraph (posScreenShifted,
                                              posGraphShifted);

    double xResolutionPerPixel = (posGraphShifted.x() - posGraph.x()) / PIXEL_SHIFT;
    double yResolutionPerPixel = (posGraphShifted.y() - posGraph.y()) / PIXEL_SHIFT;
    double resolutionPerPixel = (isXTheta ? xResolutionPerPixel : yResolutionPerPixel);

    // Compute number of digits ahead of the decimal point (any single decimal place would work but the decimal point is easiest)
    int powerValue = qFloor (qLn (qAbs (valueUnformatted)) / qLn (10.0));
    int powerResolution = qFloor (qLn (qAbs (resolutionPerPixel)) / qLn (10.0));

    int numberDigitsForResolution = powerValue - powerResolution + 1 + modelGeneral.extraPrecision();

    return numberDigitsForResolution + 1; // Add one just to be safe

  } else {

    return DEFAULT_PRECISION;
  }
}
开发者ID:TobiasWinchen,项目名称:engauge-digitizer,代码行数:54,代码来源:FormatCoordsUnitsStrategyAbstractBase.cpp


示例17: renderLegend

/*!
  Render the legend into a given rectangle.

  \param painter Painter
  \param rect Bounding rectangle
  \param fillBackground When true, fill rect with the widget background 

  \sa renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself
*/
void QwtLegend::renderLegend( QPainter *painter, 
    const QRectF &rect, bool fillBackground ) const
{
    if ( d_data->itemMap.isEmpty() )
        return;

    if ( fillBackground )
    {
        if ( autoFillBackground() ||
            testAttribute( Qt::WA_StyledBackground ) )
        {
            QwtPainter::drawBackgound( painter, rect, this );
        }
    }

    const QwtDynGridLayout *legendLayout = 
        qobject_cast<QwtDynGridLayout *>( contentsWidget()->layout() );
    if ( legendLayout == NULL )
        return;

    int left, right, top, bottom;
    getContentsMargins( &left, &top, &right, &bottom );

    QRect layoutRect; 
    layoutRect.setLeft( qCeil( rect.left() ) + left );
    layoutRect.setTop( qCeil( rect.top() ) + top );
    layoutRect.setRight( qFloor( rect.right() ) - right );
    layoutRect.setBottom( qFloor( rect.bottom() ) - bottom );

    uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
    QList<QRect> itemRects =
        legendLayout->layoutItems( layoutRect, numCols );

    int index = 0;

    for ( int i = 0; i < legendLayout->count(); i++ )
    {
        QLayoutItem *item = legendLayout->itemAt( i );
        QWidget *w = item->widget();
        if ( w )
        {
            painter->save();

            painter->setClipRect( itemRects[index], Qt::IntersectClip );
            renderItem( painter, w, itemRects[index], fillBackground );

            index++;
            painter->restore();
        }
    }
}
开发者ID:151706061,项目名称:sofa,代码行数:60,代码来源:qwt_legend.cpp


示例18: Q_D

void QPicturePaintEngine::writeCmdLength(int pos, const QRectF &r, bool corr)
{
    Q_D(QPicturePaintEngine);
    int newpos = d->pic_d->pictb.pos();            // new position
    int length = newpos - pos;
    QRectF br(r);

    if (length < 255) {                         // write 8-bit length
        d->pic_d->pictb.seek(pos - 1);             // position to right index
        d->s << (quint8)length;
    } else {                                    // write 32-bit length
        d->s << (quint32)0;                    // extend the buffer
        d->pic_d->pictb.seek(pos - 1);             // position to right index
        d->s << (quint8)255;                   // indicate 32-bit length
        char *p = d->pic_d->pictb.buffer().data();
        memmove(p+pos+4, p+pos, length);        // make room for 4 byte
        d->s << (quint32)length;
        newpos += 4;
    }
    d->pic_d->pictb.seek(newpos);                  // set to new position

    if (br.width() > 0.0 || br.height() > 0.0) {
        if (corr) {                             // widen bounding rect
            int w2 = painter()->pen().width() / 2;
            br.setCoords(br.left() - w2, br.top() - w2,
                         br.right() + w2, br.bottom() + w2);
        }
        br = painter()->transform().mapRect(br);
        if (painter()->hasClipping()) {
            QRect cr = painter()->clipRegion().boundingRect();
            br &= cr;
        }

        if (br.width() > 0.0 || br.height() > 0.0) {
            int minx = qFloor(br.left());
            int miny = qFloor(br.top());
            int maxx = qCeil(br.right());
            int maxy = qCeil(br.bottom());

            if (d->pic_d->brect.width() > 0 || d->pic_d->brect.height() > 0) {
                minx = qMin(minx, d->pic_d->brect.left());
                miny = qMin(miny, d->pic_d->brect.top());
                maxx = qMax(maxx, d->pic_d->brect.x() + d->pic_d->brect.width());
                maxy = qMax(maxy, d->pic_d->brect.y() + d->pic_d->brect.height());
                d->pic_d->brect = QRect(minx, miny, maxx - minx, maxy - miny);
            } else {
                d->pic_d->brect = QRect(minx, miny, maxx - minx, maxy - miny);
            }
        }
    }
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:51,代码来源:qpaintengine_pic.cpp


示例19: qwtRenderBackground

/*!
  Render the legend into a given rectangle.

  \param plot Plot widget
  \param painter Painter
  \param rect Bounding rectangle
*/
void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
    QPainter *painter, const QRectF &rect ) const
{
    if ( !plot->legend() || plot->legend()->isEmpty() )
        return;

    if ( !( d_data->discardFlags & DiscardBackground ) )
    {
        if ( plot->legend()->autoFillBackground() ||
            plot->legend()->testAttribute( Qt::WA_StyledBackground ) )
        {
            qwtRenderBackground( painter, rect, plot->legend() );
        }
    }

    const QwtDynGridLayout *legendLayout = qobject_cast<QwtDynGridLayout *>( 
        plot->legend()->contentsWidget()->layout() );
    if ( legendLayout == NULL )
        return;

    int left, right, top, bottom;
    plot->legend()->getContentsMargins( &left, &top, &right, &bottom );

    QRect layoutRect;
    layoutRect.setLeft( qCeil( rect.left() ) + left );
    layoutRect.setTop( qCeil( rect.top() ) + top );
    layoutRect.setRight( qFloor( rect.right() ) - right );
    layoutRect.setBottom( qFloor( rect.bottom() ) - bottom );

    uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
    QList<QRect> itemRects =
        legendLayout->layoutItems( layoutRect, numCols );

    int index = 0;

    for ( int i = 0; i < legendLayout->count(); i++ )
    {
        QLayoutItem *item = legendLayout->itemAt( i );
        QWidget *w = item->widget();
        if ( w )
        {
            painter->save();

            painter->setClipRect( itemRects[index] );
            renderLegendItem( plot, painter, w, itemRects[index] );

            index++;
            painter->restore();
        }
    }
}
开发者ID:nongxiaoming,项目名称:QGroundStation,代码行数:58,代码来源:qwt_plot_renderer.cpp


示例20: RGB_equalization

void RGB_equalization(QImage &image)
{
    int width = image.width();
    int height = image.height();

    int histSize = 256;
    std::vector<double> histR(histSize, 0.0);
    std::vector<double> histG(histSize, 0.0);
    std::vector<double> histB(histSize, 0.0);

    for (int y = 0; y < height; ++y)
        for (int x = 0; x < width; ++x)
        {
            QRgb oldColor = image.pixel(x, y);
            int red = qRed(oldColor);
            int green = qGreen(oldColor);
            int blue = qBlue(oldColor);
            ++histR[red];
            ++histG[green];
            ++histB[blue];
        }

    for (int i = 1; i < histSize; ++i)
    {
        histR[i] += histR[i - 1];
        histG[i] += histG[i - 1];
        histB[i] += histB[i - 1];
    }

    for (int i = 0; i < histSize; ++i)
    {
        histR[i] /= width * height;
        histG[i] /= width * height;
        histB[i] /= width * height;
    }

    for (int y = 0; y < height; ++y)
        for (int x = 0; x < width; ++x)
        {
            QRgb oldColor = image.pixel(x, y);
            int red = qRed(oldColor);
            int green = qGreen(oldColor);
            int blue = qBlue(oldColor);
            int newRed = qMin(qFloor(histSize * histR[red]), histSize - 1);
            int newGreen = qMin(qFloor(histSize * histG[green]), histSize - 1);
            int newBlue = qMin(qFloor(histSize * histB[blue]), histSize - 1);
            image.setPixel(x, y, qRgb(newRed, newGreen, newBlue));
        }
}
开发者ID:andrew-k-21-12,项目名称:aioi3,代码行数:49,代码来源:mainwindow.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qFuzzyCompare函数代码示例发布时间:2022-05-30
下一篇:
C++ qFatal函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap