当前位置: 首页>>代码示例>>C++>>正文


C++ QPolygonF::translate方法代码示例

本文整理汇总了C++中QPolygonF::translate方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::translate方法的具体用法?C++ QPolygonF::translate怎么用?C++ QPolygonF::translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPolygonF的用法示例。


在下文中一共展示了QPolygonF::translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw

void WaveformRendererPreroll::draw(QPainter* painter, QPaintEvent* event) {
    Q_UNUSED(event);
    const TrackPointer track = m_waveformRenderer->getTrackInfo();
    if (!track) {
        return;
    }

    double samplesPerPixel = m_waveformRenderer->getVisualSamplePerPixel();
    double numberOfSamples = m_waveformRenderer->getLength() * samplesPerPixel;

    int currentPosition = m_waveformRenderer->getPlayPosVSample();
    //qDebug() << "currentPosition" << currentPosition
    //         << "samplesPerPixel" << samplesPerPixel
    //         << "numberOfSamples" << numberOfSamples;

    // Some of the pre-roll is on screen. Draw little triangles to indicate
    // where the pre-roll is located.
    if (currentPosition < numberOfSamples / 2.0) {
        int index = static_cast<int>(numberOfSamples / 2.0 - currentPosition);
        const int polyLength = static_cast<int>(40.0 / samplesPerPixel);
        const float halfBreadth = m_waveformRenderer->getBreadth()/2.0;
        const float halfPolyBreadth = m_waveformRenderer->getBreadth()/5.0;

        painter->save();
        painter->setRenderHint(QPainter::Antialiasing);
        //painter->setRenderHint(QPainter::HighQualityAntialiasing);
        //painter->setBackgroundMode(Qt::TransparentMode);
        painter->setWorldMatrixEnabled(false);
        painter->setPen(QPen(QBrush(m_color), 1));

        // Rotate if drawing vertical waveforms
        if (m_waveformRenderer->getOrientation() == Qt::Vertical) {
            painter->setTransform(QTransform(0, 1, 1, 0, 0, 0));
        }

        QPolygonF polygon;
        polygon << QPointF(0, halfBreadth)
                << QPointF(-polyLength, halfBreadth - halfPolyBreadth)
                << QPointF(-polyLength, halfBreadth + halfPolyBreadth);

        // Draw at most one not or halve visible polygon at the widget borders
        if (index > (numberOfSamples + ((polyLength + 1) * samplesPerPixel))) {
            int rest = index - numberOfSamples;
            rest %= (int)((polyLength + 1) * samplesPerPixel);
            index = numberOfSamples + rest;
        }

        polygon.translate(((qreal)index) / samplesPerPixel, 0);
        while (index > 0) {
            painter->drawPolygon(polygon);
            polygon.translate(-(polyLength + 1), 0);
            index -= (polyLength + 1) * samplesPerPixel;
        }

        painter->restore();
    }
}
开发者ID:PetrBarborka,项目名称:mixxx,代码行数:57,代码来源:waveformrendererpreroll.cpp

示例2: updateHandles

/**
 * Creates and removes handle instances as necessary to adapt to a new object
 * selection.
 */
void EditPolygonTool::updateHandles()
{
    const QSet<MapObjectItem*> &selection = mapScene()->selectedObjectItems();

    // First destroy the handles for objects that are no longer selected
    QMutableMapIterator<MapObjectItem*, QList<PointHandle*> > i(mHandles);
    while (i.hasNext()) {
        i.next();
        if (!selection.contains(i.key())) {
            const auto &handles = i.value();
            for (PointHandle *handle : handles) {
                if (handle->isSelected())
                    mSelectedHandles.remove(handle);
                delete handle;
            }

            i.remove();
        }
    }

    MapRenderer *renderer = mapDocument()->renderer();

    for (MapObjectItem *item : selection) {
        const MapObject *object = item->mapObject();
        if (!object->cell().isEmpty())
            continue;

        QPolygonF polygon = object->polygon();
        polygon.translate(object->position());

        QList<PointHandle*> pointHandles = mHandles.value(item);

        // Create missing handles
        while (pointHandles.size() < polygon.size()) {
            PointHandle *handle = new PointHandle(item, pointHandles.size());
            pointHandles.append(handle);
            mapScene()->addItem(handle);
        }

        // Remove superfluous handles
        while (pointHandles.size() > polygon.size()) {
            PointHandle *handle = pointHandles.takeLast();
            if (handle->isSelected())
                mSelectedHandles.remove(handle);
            delete handle;
        }

        // Update the position of all handles
        for (int i = 0; i < pointHandles.size(); ++i) {
            const QPointF &point = polygon.at(i);
            const QPointF handlePos = renderer->pixelToScreenCoords(point);
            const QPointF internalHandlePos = handlePos - item->pos();
            pointHandles.at(i)->setPos(item->mapToScene(internalHandlePos));
        }

        mHandles.insert(item, pointHandles);
    }
}
开发者ID:Shorttail,项目名称:tiled,代码行数:62,代码来源:editpolygontool.cpp

示例3: drawMapObject

void IsometricRenderer::drawMapObject(QPainter *painter,
                                      const MapObject *object,
                                      const QColor &color) const
{
    painter->save();

    QPen pen(Qt::black);

    if (object->tile()) {
        const QPixmap &img = object->tile()->image();
        QPointF paintOrigin(-img.width() / 2, -img.height());
        paintOrigin += tileToPixelCoords(object->position()).toPoint();
        painter->drawPixmap(paintOrigin, img);

        pen.setStyle(Qt::SolidLine);
        painter->setPen(pen);
        painter->drawRect(QRectF(paintOrigin, img.size()));
        pen.setStyle(Qt::DotLine);
        pen.setColor(color);
        painter->setPen(pen);
        painter->drawRect(QRectF(paintOrigin, img.size()));
    } else {
        QColor brushColor = color;
        brushColor.setAlpha(50);
        QBrush brush(brushColor);

        pen.setJoinStyle(Qt::RoundJoin);
        pen.setCapStyle(Qt::RoundCap);
        pen.setWidth(2);

        painter->setPen(pen);
        painter->setRenderHint(QPainter::Antialiasing);

        // TODO: Draw the object name
        // TODO: Do something sensible to make null-sized objects usable

        QPolygonF polygon = tileRectToPolygon(object->bounds());

        // Make sure the line aligns nicely on the pixels
        if (pen.width() % 2)
            painter->translate(0.5, 0.5);

        painter->drawPolygon(polygon);
        pen.setColor(color);
        painter->setPen(pen);
        painter->setBrush(brush);
        polygon.translate(0, -1);
        painter->drawPolygon(polygon);
    }

    painter->restore();
}
开发者ID:zorbathut,项目名称:mild,代码行数:52,代码来源:isometricrenderer.cpp

示例4: sipReleaseType

static PyObject *meth_QPolygonF_translate(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QPointF* a0;
        int a0State = 0;
        QPolygonF *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QPolygonF, &sipCpp, sipType_QPointF, &a0, &a0State))
        {
            sipCpp->translate(*a0);
            sipReleaseType(const_cast<QPointF *>(a0),sipType_QPointF,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        qreal a0;
        qreal a1;
        QPolygonF *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bdd", &sipSelf, sipType_QPolygonF, &sipCpp, &a0, &a1))
        {
            sipCpp->translate(a0,a1);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QPolygonF, sipName_translate, doc_QPolygonF_translate);

    return NULL;
}
开发者ID:rff255,项目名称:python-qt5,代码行数:38,代码来源:sipQtGuiQPolygonF.cpp

示例5: modPen

YigModField::YigModField(YigSynthGraphic *synthGraphic, float param, qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent) :
    QGraphicsEllipseItem( x, y, width, height, parent ),
    modArc(this),
    yigAttractor(this),
    modTriangle(this)
{
    //createModCircle();
    parentGraphic = synthGraphic;
    setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2);
    rotationAngle = param * 360;
    setRotation(fmod(rotationAngle+180, 360));
    transformOriginPoint();
    updateParameter(fmod((rotationAngle+180), 360)/360);
    modTriangle.setZValue(99);
    QPolygonF modPolygon;
    modPolygon.append(QPointF(0, 0));
    modPolygon.append(QPointF(5, 15));
    modPolygon.append(QPointF(-5, 15));
    modPolygon.translate(width/2, 0);
    modTriangle.setPolygon(modPolygon);
    QPen modPen(Qt::NoPen);
    modTriangle.setPen(modPen);
    QColor modColor(YigColorKit::background2);
    modColor.setAlpha(200);
    QBrush modBrush(modColor);
    modTriangle.setBrush(modBrush);
    // Mod amount
    /*
    modElectron = new QGraphicsEllipseItem(0, 0, 25, 25, this);
    modElectron->moveBy(0, (boundingRect().width()/2) - 3);
    modElectron->setFlag( QGraphicsItem::ItemIsSelectable, false );
    modElectron->setFlag( QGraphicsItem::ItemIsMovable, false );
    modElectron->setCacheMode( QGraphicsItem::ItemCoordinateCache );
    QColor modColor(YigColorKit::background2);
    modColor.setAlpha(200);
    modElectron->setPen(QPen(modColor));
    modColor.setAlpha(20);
    modElectron->setBrush(modColor);*/

    /*
    QColor modFill(YigColorKit::background2);
    modFill.setAlpha(100);
    QColor modOutline(YigColorKit::background2);
    modOutline.setAlpha(220);
    modArc.setBrush(modFill);
    modArc.setPen(Qt::NoPen);*/
    //redrawArc();
}
开发者ID:ChadMcKinney,项目名称:Yig,代码行数:48,代码来源:yigsynthgraphic.cpp

示例6: path

QPainterPath BallItem::path() const
{
	QPainterPath path;
	QPolygonF collidingPlgn = collidingPolygon();
	QMatrix m;
	m.rotate(rotation());

	QPointF firstP = collidingPlgn.at(0);
	collidingPlgn.translate(-firstP.x(), -firstP.y());

	path.addEllipse(collidingPlgn.boundingRect());
	path = m.map(path);
	path.translate(firstP.x(), firstP.y());

	return path;
}
开发者ID:ZiminGrigory,项目名称:qreal,代码行数:16,代码来源:ballItem.cpp

示例7: translatePolygons

void CylindricalProjectionPrivate::translatePolygons( const QVector<QPolygonF *> &polygons,
                                                      QVector<QPolygonF *> &translatedPolygons,
                                                      qreal xOffset )
{
    // mDebug() << "Translation: " << xOffset;

    QVector<QPolygonF *>::const_iterator itPolygon = polygons.constBegin();
    QVector<QPolygonF *>::const_iterator itEnd = polygons.constEnd();

    for( ; itPolygon != itEnd; ++itPolygon ) {
        QPolygonF * polygon = new QPolygonF;
        *polygon = **itPolygon;
        polygon->translate( xOffset, 0 );
        translatedPolygons.append( polygon );
    }
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:16,代码来源:CylindricalProjection.cpp

示例8: drawIndents

void HorizontalPaintingStrategy::drawIndents(const KoRulerPrivate *d, QPainter &painter)
{
    QPolygonF polygon;

    painter.setBrush(d->ruler->palette().brush(QPalette::Base));
    painter.setRenderHint( QPainter::Antialiasing );

    qreal x;
    // Draw first line start indent
    if (d->rightToLeft)
        x = d->effectiveActiveRangeEnd() - d->firstLineIndent - d->paragraphIndent;
    else
        x = d->effectiveActiveRangeStart() + d->firstLineIndent + d->paragraphIndent;
    // convert and use the +0.5 to go to nearest integer so that the 0.5 added below ensures sharp lines
    x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
    polygon << QPointF(x+6.5, 0.5)
        << QPointF(x+0.5, 8.5)
        << QPointF(x-5.5, 0.5)
        << QPointF(x+5.5, 0.5);
    painter.drawPolygon(polygon);

    // draw the hanging indent.
    if (d->rightToLeft)
        x = d->effectiveActiveRangeStart() + d->endIndent;
    else
        x = d->effectiveActiveRangeStart() + d->paragraphIndent;
    // convert and use the +0.5 to go to nearest integer so that the 0.5 added below ensures sharp lines
    x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
    const int bottom = d->ruler->height();
    polygon.clear();
    polygon << QPointF(x+6.5, bottom - 0.5)
        << QPointF(x+0.5, bottom - 8.5)
        << QPointF(x-5.5, bottom - 0.5)
        << QPointF(x+5.5, bottom - 0.5);
    painter.drawPolygon(polygon);

    // Draw end-indent or paragraph indent if mode is rightToLeft
    qreal diff;
    if (d->rightToLeft)
        diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd()
                     - d->paragraphIndent) + d->offset - x;
    else
        diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd() - d->endIndent)
                + d->offset - x;
    polygon.translate(diff, 0);
    painter.drawPolygon(polygon);
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:47,代码来源:KoRuler.cpp

示例9: mouseMoveEvent

void OnMonitorCornersItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
    /*if (event->buttons() != Qt::NoButton && (event->screenPos() - m_screenClickPoint).manhattanLength() < QApplication::startDragDistance()) {
     *   event->accept();
     *   return;
    }*/

    if (event->buttons() & Qt::LeftButton) {
        QPointF mousePos = mapFromScene(event->scenePos());
        QPolygonF p = polygon();
        switch (m_mode) {
        case Corner:
            p.replace(m_selectedCorner, mousePos);
            m_modified = true;
            break;
        case Move:
            p.translate(mousePos - m_lastPoint);
            m_modified = true;
            break;
        case MoveSide:
            p[m_selectedCorner] += mousePos - m_lastPoint;
            p[(m_selectedCorner + 1) % 4] += mousePos - m_lastPoint;
            m_modified = true;
            break;
        default:
            break;
        }
        m_lastPoint = mousePos;
        setPolygon(p);
    }

    if (m_modified) {
        event->accept();
        if (KdenliveSettings::monitorscene_directupdate()) {
            emit changed();
            m_modified = false;
        }
    } else {
        event->ignore();
    }
}
开发者ID:JongHong,项目名称:kdenlive,代码行数:41,代码来源:onmonitorcornersitem.cpp

示例10: paintEvent

void MainWindow::paintEvent(QPaintEvent *)
{
	QPainter p(this);

	QPolygonF frame;

	frame.append(QPointF(0.0, 0.0));
	frame.append(QPointF(0.0, 50.0));
	frame.append(QPointF(50.0, 50.0));
	frame.append(QPointF(50.0, 0.0));
	frame.append(QPointF(30.0, 0.0));
	frame.append(QPointF(30.0, 10.0));
	frame.append(QPointF(20.0, 10.0));
	frame.append(QPointF(20.0, 0.0));
	frame.append(QPointF(10.0, 0.0));

	qDebug("contains 30.0 30.0 = %d", frame.containsPoint(QPointF(30.0, 30.0), Qt::WindingFill));

	qDebug("contains 25.0 0.0 = %d", frame.containsPoint(QPointF(25.0, 0.0), Qt::WindingFill));






	frame.translate(QPointF(100, 100.0));
	p.setPen(QPen(Qt::red, 1.0));
	p.setBrush(Qt::NoBrush);

	p.drawPolygon(frame, Qt::WindingFill);

	p.setPen(QPen(Qt::blue, 2.0));
	p.setBrush(QBrush(Qt::blue));
	p.drawPoint(QPointF(130.0, 130.0));

	p.setPen(QPen(Qt::green, 2.0));
	p.setBrush(QBrush(Qt::green));
	p.drawPoint(QPointF(125.0, 100.0));

}
开发者ID:cero2k6,项目名称:qt,代码行数:40,代码来源:mainwindow.cpp

示例11: drawTileSelection


//.........这里部分代码省略.........
        QPen colorPen(pen);
        colorPen.setColor(color);

        painter->setPen(pen);
        painter->setRenderHint(QPainter::Antialiasing);

        // TODO: Do something sensible to make null-sized objects usable

        switch (object->shape()) {
        case MapObject::Ellipse: {
            QPolygonF polygon = pixelRectToScreenPolygon(object->bounds());

            qreal tw = map()->tileWidth();
            qreal th = map()->tileHeight();
            QPointF transformScale(1, 1);
            if (tw > th)
                transformScale = QPointF(1, th/tw);
            else
                transformScale = QPointF(tw/th, 1);

            QPointF l1 = polygon.at(1) - polygon.at(0);
            QPointF l2 = polygon.at(3) - polygon.at(0);
            QTransform trans;
            trans.scale(transformScale.x(), transformScale.y());
            trans.rotate(45);
            QTransform iTrans = trans.inverted();
            QPointF l1x = iTrans.map(l1);
            QPointF l2x = iTrans.map(l2);
            QSizeF ellipseSize(l1x.manhattanLength(), l2x.manhattanLength());

            if (ellipseSize.width() > 0 && ellipseSize.height() > 0) {
                painter->save();
                painter->setPen(pen);
                painter->translate(polygon.at(0));
                painter->scale(transformScale.x(), transformScale.y());
                painter->rotate(45);
                painter->drawEllipse(QRectF(QPointF(0, 0), ellipseSize));
                painter->restore();
            }

            painter->setBrush(Qt::NoBrush);
            painter->drawPolygon(polygon);

            painter->setPen(colorPen);
            painter->setBrush(Qt::NoBrush);
            painter->translate(QPointF(0, -shadowOffset));
            painter->drawPolygon(polygon);

            painter->setBrush(brush);
            if (ellipseSize.width() > 0 && ellipseSize.height() > 0) {
                painter->save();
                painter->translate(polygon.at(0));
                painter->scale(transformScale.x(), transformScale.y());
                painter->rotate(45);
                painter->drawEllipse(QRectF(QPointF(0, 0), ellipseSize));
                painter->restore();
            }
            break;
        }
        case MapObject::Point:
            painter->translate(pixelToScreenCoords(object->position()));
            drawPointObject(painter, color);
            break;
        case MapObject::Rectangle: {
            QPolygonF polygon = pixelRectToScreenPolygon(object->bounds());
            painter->drawPolygon(polygon);
开发者ID:ihuangx,项目名称:tiled,代码行数:67,代码来源:isometricrenderer.cpp

示例12: paintEvent

void TimelineWidget::paintEvent(QPaintEvent* event)
{
	if (similar(mStart,mStop))
		return;
	QWidget::paintEvent(event);

	QPainter painter(this);
//  QPen pointPen, pointLinePen;
	painter.setRenderHint(QPainter::Antialiasing);
	painter.setPen(Qt::NoPen);

	QColor gray0(240, 240, 240);
	QColor gray01(220, 220, 220);
	QColor gray1(200, 200, 200);
	QColor gray2(170, 170, 170); // darker
	QColor gray3(150, 150, 150); // even darker
	QColor gray4(100, 100, 100); // even darker
	QColor highlight(110, 214, 255); // color around highlighted circle in qslider on KDE.

	// Fill with white background color and grey plot area background color
	QBrush brush(Qt::SolidPattern); // = painter.brush();
	brush.setColor(gray2);
	painter.setBrush(brush);

	painter.drawRoundedRect(this->mFullArea, 4, 4);
//	brush.setColor(gray01);
	brush.setColor(gray1);
	painter.setBrush(brush);
	painter.drawRoundedRect(this->mPlotArea, 4, 4);

	int margin = 1;

	// draw noncompacted interval
	for (unsigned i = 0; i < mNoncompactedIntervals.size(); ++i)
	{
		int start_p = this->mapTime2PlotX(mNoncompactedIntervals[i].mStartTime);
		int stop_p = this->mapTime2PlotX(mNoncompactedIntervals[i].mEndTime);
		QColor color = gray01;
		painter.fillRect(QRect(start_p, mPlotArea.top(), stop_p - start_p, mPlotArea.height()), color);
	}

	// draw all continous events
	for (unsigned i = 0; i < mEvents.size(); ++i)
	{
		if (!mContinousEvents.contains(mEvents[i].mGroup))
			continue;
		int start_p = this->mapTime2PlotX(mEvents[i].mStartTime);
		int stop_p = this->mapTime2PlotX(mEvents[i].mEndTime);
		int level = std::distance(mContinousEvents.begin(),
						std::find(mContinousEvents.begin(), mContinousEvents.end(), mEvents[i].mGroup));
		int level_max = mContinousEvents.size();
		int thisHeight = (mPlotArea.height()) / level_max - margin * (level_max - 1) / level_max;
		int thisTop = mPlotArea.top() + level * thisHeight + level * margin;

//		QColor color = mEventColors[level % mEventColors.size()];
		QColor color = mEvents[i].mColor;

		painter.fillRect(QRect(start_p, thisTop, stop_p - start_p, thisHeight), color);
	}

	// draw all singular events
	for (unsigned i = 0; i < mEvents.size(); ++i)
	{
		if (mContinousEvents.contains(mEvents[i].mGroup))
			continue;

		int start_p = this->mapTime2PlotX(mEvents[i].mStartTime);
//		int stop_p = this->mapTime2PlotX(mEvents[i].mEndTime);

		int glyphWidth = 3;
		QRect rect(start_p - glyphWidth / 2, mPlotArea.top(), glyphWidth, mPlotArea.height());

		brush.setColor(QColor(50, 50, 50));
		painter.setBrush(brush);
		painter.drawRoundedRect(rect, 2, 2);

//		painter.fillRect(rect, gray4);
		if (rect.width() > 2 && rect.height() > 2)
		{
			rect.adjust(1, 1, -1, -1);
			painter.fillRect(rect, gray2);
		}
	}

	int offset_p = this->mapTime2PlotX(mPos);
	QPolygonF glyph;
	int z = 5;
	int h = mPlotArea.height();
	glyph.push_back(QPointF(-z, 0));
	glyph.push_back(QPointF(z, 0));
	glyph.push_back(QPointF(z, 0.7 * h));
	glyph.push_back(QPointF(0, h));
	glyph.push_back(QPointF(-z, 0.7 * h));
	glyph.translate(offset_p, 0);
	if (this->hasFocus() || mCloseToGlyph)
		painter.setPen(highlight);
	else
		painter.setPen(gray4);
//  QBrush brush(Qt::SolidPattern);// = painter.brush();

//.........这里部分代码省略.........
开发者ID:c0ns0le,项目名称:CustusX,代码行数:101,代码来源:cxTimelineWidget.cpp

示例13: drawMapObjectDecorate

void IsometricRenderer::drawMapObjectDecorate(QPainter *painter,
                                              const MapObject *object,
                                              const QColor &color,
                                              bool decorate) const
{
    painter->save();

    QPen pen(Qt::black);

    if (object->tile()) {
        const QImage img = object->toImage();
        QPointF paintOrigin(-img.width() / 2, -img.height());
        paintOrigin += tileToPixelCoords(object->position()).toPoint();
        painter->drawImage(paintOrigin, img);


        if (decorate) {
            pen.setStyle(Qt::SolidLine);
            painter->setPen(pen);
            painter->drawRect(QRectF(paintOrigin, img.size()));
            pen.setStyle(Qt::DotLine);
            pen.setColor(color);
            painter->setPen(pen);
            painter->drawRect(QRectF(paintOrigin, img.size()));
        }
    } else {
        QColor brushColor = color;
        brushColor.setAlpha(50);
        QBrush brush(brushColor);

        pen.setJoinStyle(Qt::RoundJoin);
        pen.setCapStyle(Qt::RoundCap);
        pen.setWidth(2);

        painter->setPen(pen);
        painter->setRenderHint(QPainter::Antialiasing);

        // TODO: Draw the object name
        // TODO: Do something sensible to make null-sized objects usable

        switch (object->shape()) {
        case MapObject::Rectangle: {
            QPolygonF polygon = tileRectToPolygon(object->bounds());
            painter->drawPolygon(polygon);

            pen.setColor(color);
            painter->setPen(pen);
            painter->setBrush(brush);
            polygon.translate(0, -1);

            painter->drawPolygon(polygon);
            break;
        }
        case MapObject::Polygon: {
            const QPointF &pos = object->position();
            const QPolygonF polygon = object->polygon().translated(pos);
            QPolygonF screenPolygon = tileToPixelCoords(polygon);

            painter->drawPolygon(screenPolygon);

            pen.setColor(color);
            painter->setPen(pen);
            painter->setBrush(brush);
            screenPolygon.translate(0, -1);

            painter->drawPolygon(screenPolygon);
            break;
        }
        case MapObject::Polyline: {
            const QPointF &pos = object->position();
            const QPolygonF polygon = object->polygon().translated(pos);
            QPolygonF screenPolygon = tileToPixelCoords(polygon);

            painter->drawPolyline(screenPolygon);

            pen.setColor(color);
            painter->setPen(pen);
            screenPolygon.translate(0, -1);

            painter->drawPolyline(screenPolygon);
            break;
        }
        }
    }

    painter->restore();
}
开发者ID:Zeitmaus,项目名称:tiled,代码行数:87,代码来源:isometricrenderer.cpp

示例14: drawMapObject


//.........这里部分代码省略.........

            const qreal headerX = bottomLeft.x();
            const qreal headerY = topLeft.y();

            QRectF rect(bottomLeft, topRight);

            const QFontMetrics fm = painter->fontMetrics();
            QString name = fm.elidedText(object->name(), Qt::ElideRight,
                                         rect.width() + 2);

            QPolygonF polygon = pixelRectToScreenPolygon(object->bounds());

            float tw = map()->tileWidth();
            float th = map()->tileHeight();
            QPointF transformScale(1, 1);
            if (tw > th)
                transformScale = QPointF(1, th/tw);
            else
                transformScale = QPointF(tw/th, 1);

            QPointF l1 = polygon.at(1) - polygon.at(0);
            QPointF l2 = polygon.at(3) - polygon.at(0);
            QTransform trans;
            trans.scale(transformScale.x(), transformScale.y());
            trans.rotate(45);
            QTransform iTrans = trans.inverted();
            QPointF l1x = iTrans.map(l1);
            QPointF l2x = iTrans.map(l2);
            QSizeF ellipseSize(l1x.manhattanLength(), l2x.manhattanLength());

            if (ellipseSize.width() > 0 && ellipseSize.height() > 0) {
                painter->save();
                painter->setPen(pen);
                painter->translate(polygon.at(0));
                painter->scale(transformScale.x(), transformScale.y());
                painter->rotate(45);
                painter->drawEllipse(QRectF(QPointF(0, 0), ellipseSize));
                painter->restore();
            }

            painter->setBrush(Qt::NoBrush);
            painter->drawPolygon(polygon);

            if (!name.isEmpty())
                painter->drawText(QPoint(headerX, headerY - 5), name);

            pen.setColor(color);
            painter->setPen(pen);
            painter->setBrush(Qt::NoBrush);
            painter->translate(QPointF(0, -shadowOffset));
            painter->drawPolygon(polygon);

            painter->setBrush(brush);
            if (ellipseSize.width() > 0 && ellipseSize.height() > 0) {
                painter->save();
                painter->translate(polygon.at(0));
                painter->scale(transformScale.x(), transformScale.y());
                painter->rotate(45);
                painter->drawEllipse(QRectF(QPointF(0, 0), ellipseSize));
                painter->restore();
            }

            if (!name.isEmpty())
                painter->drawText(QPoint(headerX, headerY - 5), name);
            break;
        }
开发者ID:Arnaud-Trouche,项目名称:tiled,代码行数:67,代码来源:isometricrenderer.cpp

示例15: translate

int Polygon::translate(lua_State * L) // ( int dx, int dy )
{
	QPolygonF* obj = ValueInstaller2<QPolygonF>::check( L, 1 );
	obj->translate( Util::toDbl( L, 2 ), Util::toDbl( L, 3 ) );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:6,代码来源:QtlPolygon.cpp


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