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


C++ QTransform::reset方法代码示例

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


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

示例1: RectMapTransform

QTransform RectMapTransform( QRectF source, QRectF target )
{
    qreal x1 = source.left();
    qreal y1 = source.top();
    qreal x2 = source.right();
    qreal y2 = source.bottom();
    qreal x1P = target.left();
    qreal y1P = target.top();
    qreal x2P = target.right();
    qreal y2P = target.bottom();

    QTransform matrix;
    if ( ( x1 != x2 ) && ( y1 != y2 ) )
    {
        matrix = QTransform( ( x2P - x1P ) / ( x2 - x1 ), // scale x
                             0,
                             0,
                             ( y2P - y1P ) / ( y2 - y1 ), // scale y
                             ( x1P * x2 - x2P * x1 ) / ( x2 - x1 ),    // dx
                             ( y1P * y2 - y2P * y1 ) / ( y2 - y1 ) );  // dy
    }
    else
    {
        matrix.reset();
    }
    return matrix;
}
开发者ID:biosdaddy,项目名称:pencil,代码行数:27,代码来源:util.cpp

示例2: GetTransformAt

bool ReAnimEntityWidget::GetTransformAt( int _cursor, QTransform& _result, bool _allowExterpolate )
{
	bool isOk = false;

	QPointF translation;
	qreal rotation = 0.0f;
	QPointF scale;

	bool hasTranslation = GetTranslationAt( _cursor, translation, _allowExterpolate );
	bool hasRotation = GetRotationAt( _cursor, rotation, _allowExterpolate );
	bool hasScale = GetScaleAt( _cursor, scale, _allowExterpolate );

	if( hasTranslation || hasRotation || hasScale )
	{		
		_result.reset();

		if( hasScale )
			_result.scale( scale.x(), scale.y() );

		if( hasRotation )
			_result.rotate( rotation );

		if( hasTranslation )
			_result.translate( translation.x(), translation.y() );

		isOk = true;
	}

	return isOk;
}
开发者ID:Abyss116,项目名称:libguiex,代码行数:30,代码来源:ReAnimEntityWidget.cpp

示例3: setFlipLR

void QGraphicsCompositeImageItem::setFlipLR(bool flip) {
    const int w = boundingRect().width();
    QTransform xform;
    xform.reset();
    xform.setMatrix(-1, 0, 0, 0, 1, 0, w, 0, 1);
    setTransform(xform, true);
}
开发者ID:telnet2,项目名称:gradworks,代码行数:7,代码来源:qgraphicscompositeimageitem.cpp

示例4: setFlipUD

void QGraphicsCompositeImageItem::setFlipUD(bool flip) {
    const int h = boundingRect().height();
    QTransform xform;
    xform.reset();
    xform.setMatrix(1, 0, 0, 0, -1, 0, 0, h, 1);
    setTransform(xform, true);
}
开发者ID:telnet2,项目名称:gradworks,代码行数:7,代码来源:qgraphicscompositeimageitem.cpp

示例5: HideRollOutCorners

QImage Rotater::HideRollOutCorners(const QImage image)
{
    QImage destImage = QImage( image);

    QLine hline, vlineR, vlineL;
    int x0, y0, x1, y1;
    if (m_sign < 0)
    {
        x0 = 0, y0 = 0, x1 = m_width, y1 = 0;
    }
    else
    {
        x0 = 0, y0 = m_height, x1 = m_width, y1 = m_height;
    }

    hline = QLine(x0, y0, x1, y1);
    vlineR = QLine(m_width, 0, m_width, m_height);
    vlineL = QLine(0, 0, 0, m_height);

    QLine rvline = m_transform.map(vlineR);
    QPoint pa = get_line_cross_point(hline, rvline);
    QPoint pb = get_line_cross_point(vlineR, rvline);

    QLine rhline = m_transform.map(hline);
    QPoint pc = get_line_cross_point(vlineL, rhline);
    QPoint pd = get_line_cross_point(hline, rhline);

//    destImage = markOnImage( image, pa.x(), pa.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pb.x(), pb.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pc.x(), pc.y(), MarkType::CrossLines);
//    destImage = markOnImage( destImage, pd.x(), pd.y(), MarkType::CrossLines);

    QPolygonF triagle1, triagle2;
    triagle1 << pa << pb << QPointF(x1, y1);
    triagle2 << pc << pd << QPointF(x0, y0);

    QPainterPath myPath;
    myPath.addPolygon(triagle1);
    myPath.addPolygon(triagle2);

    QTransform transform;
    transform.translate(0, m_height * 0.5);
    transform.rotate(180, Qt::XAxis);
    transform.translate(0, -m_height * 0.5);
    QPainterPath myPath1 = transform.map(myPath);

    transform.reset();
    transform.translate(m_width * 0.5, 0);
    transform.rotate(180, Qt::YAxis);
    transform.translate(-m_width * 0.5, 0);
    myPath = transform.map(myPath);
    myPath.addPath(myPath1);

    QPainter painter(&destImage);
    painter.setBrush(Qt::SolidPattern);
    painter.drawPath(myPath);

    return destImage;
}
开发者ID:chenx77,项目名称:MyCodeLab,代码行数:59,代码来源:rotater.cpp

示例6: ellipseOutline

QPainterPath KisPaintOpSettings::ellipseOutline(qreal width, qreal height, qreal scale, qreal rotation) const
{
    QPainterPath path;
    QRectF ellipse(0,0,width * scale,height * scale);
    ellipse.translate(-ellipse.center());
    path.addEllipse(ellipse);
        
    QTransform m;
    m.reset();
    m.rotate( rotation );
    path = m.map(path);
    return path;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:13,代码来源:kis_paintop_settings.cpp

示例7: brushOutline

QPainterPath KisPaintOpSettings::brushOutline(const QPointF& pos, OutlineMode mode, qreal scale, qreal rotation) const
{
    QPainterPath path;
    if (mode == CursorIsOutline){
        QRectF rc(-5,-5, 10, 10);
        path.moveTo(rc.topLeft());
        path.lineTo(rc.bottomRight());
        path.moveTo(rc.topRight());
        path.lineTo(rc.bottomLeft());
        QTransform m;
        m.reset(); m.scale(scale,scale); m.rotateRadians(rotation);
        path = m.map(path);
        path.translate(pos);
    }
    return path;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:16,代码来源:kis_paintop_settings.cpp

示例8: brushOutline

QPainterPath KisGridPaintOpSettings::brushOutline(const QPointF& pos, KisPaintOpSettings::OutlineMode mode, qreal scale, qreal rotation) const
{
    QPainterPath path;
    if (mode == CursorIsOutline) {
        qreal sizex = getInt(GRID_WIDTH) * getDouble(GRID_SCALE) * scale;
        qreal sizey = getInt(GRID_HEIGHT) * getDouble(GRID_SCALE) * scale;
        QRectF rc(0, 0, sizex, sizey);
        rc.translate(-rc.center());
        QTransform m;
        m.reset();
        m.rotate(rotation);
        path = m.map(path);
        path.addRect(rc);
        path.translate(pos);
    }
    return path;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:17,代码来源:kis_grid_paintop_settings.cpp

示例9: strokePens

void CurveBrush::strokePens(QPointF pi1, QPointF pi2, KisPainter &/*painter*/)
{
    if (m_pens.isEmpty()) {
        m_pens.append(Pen(pi1, 0.0, 1.0));
    }

    qreal dx = pi2.x() - pi1.x();
    qreal dy = pi2.y() - pi1.y();
    for (int i = 0; i < m_pens.length(); i++) {
        Pen &pen = m_pens[i];

        QPointF endPoint(dx, dy);

        QPainterPath path;
        path.moveTo(0, 0);
        path.lineTo(dx, dy);

        QTransform transform;
        transform.reset();
        transform.translate(pen.pos.x(), pen.pos.y());
        transform.scale(pen.scale, pen.scale);
        transform.rotate(pen.rotation);

        path = transform.map(path);
        //m_painter->drawPainterPath(path, QPen(Qt::white, 1.0));

        endPoint = transform.map(endPoint);
        m_painter->drawThickLine(pen.pos, endPoint, 1.0, 1.0);
        pen.pos = endPoint;
    }

    qreal branchThreshold = 0.5;
    if ((m_branch * drand48() > branchThreshold) && (m_pens.length() < 1024)) {
        int index = floor(drand48() * (m_pens.length() - 1));

        m_newPen.pos = m_pens.at(index).pos;
        m_newPen.rotation = drand48() * M_PI / 32; //atan(dy/dx) + (drand48() - 0.5) * M_PI/32;
        m_newPen.scale = drand48() * m_pens.at(index).scale;
        m_pens.append(m_newPen);
        dbgKrita << m_pens.length();
        m_branch = 0;
    }
    else {
        m_branch++;
    }
}
开发者ID:ChrisJong,项目名称:krita,代码行数:46,代码来源:curve_brush.cpp

示例10: drawOnGDIplus

void converDemo::drawOnGDIplus(const HDC &hdc)
{
	Q_ASSERT(hdc);
	Graphics graphics(hdc);
	Matrix matrix;
 	QTransform transform;
	transform.translate(0, 20);
	converQTransform2GpMatrix(transform, &matrix);
	graphics.SetTransform(&matrix);

	drawOnNativeGdi(graphics);
	transform.reset();
	transform.translate(210, 20);
	converQTransform2GpMatrix(transform, &matrix);
	graphics.SetTransform(&matrix);
	drawOnTranslateQT(graphics);

}
开发者ID:huangchuqiang,项目名称:converDemo,代码行数:18,代码来源:converdemo.cpp

示例11: updateSize

void CWhiteBoardView::updateSize(const QSize &size)
{
    if(size.width() <= 0 && size.height() <= 0)
    {
        return;
    }
    QSize adjustSize = size;
    if(m_data->m_needScale)
    {
        QRectF sceneRect = m_data->m_baseRect;
        if(sceneRect.width() < 0.001 && sceneRect.height() < 0.001)
        {
            return;
        }

        qreal sx = size.width() /  sceneRect.width();
        qreal sy = size.height() /  sceneRect.height();
        QTransform form = this->transform();
        form.setMatrix(sx,form.m12(),form.m13(),form.m21(),sy,form.m23(),form.m31(),form.m32(),form.m33());
        this->setTransform(form);
        adjustSize = sceneRect.size().toSize();
    }
    else
    {
        QTransform form = this->transform();
        form.reset();
        this->setTransform(form);

        m_data->m_scene->setSceneRect(QRect(0,0,adjustSize.width(),adjustSize.height()));
    }
    if(m_data->m_backgroundColor.alpha() == 0)
    {
        m_data->m_backgroundColor.setAlpha(1);
    }
    QPixmap pixmap(adjustSize);
    pixmap.fill(m_data->m_backgroundColor);
    m_data->m_whiteBoardItem->setPixmap(pixmap);
}
开发者ID:weinkym,项目名称:src_miao,代码行数:38,代码来源:cwhiteboardview.cpp

示例12: setScale

void SCgView::setScale(const QString& sc)
{
    QTransform t = transform();
    //Default transform
    t.reset();

    //Getting percent value
    QString str = sc;
    str.remove("%");
    double d = str.toDouble()/100.0;

    //Checking if value d in proper range
    if (d < SCgWindow::minScale)
        d = SCgWindow::minScale;
    else
        if (d > SCgWindow::maxScale)
            d = SCgWindow::maxScale;

    //Setting transformation
    setTransform(t.scale(d,d),false);

    emit(scaleChanged(transform().mapRect(QRectF(0, 0, 1, 1)).width()));
}
开发者ID:deniskoronchik,项目名称:kbe,代码行数:23,代码来源:scgview.cpp

示例13:

void Box2DRobot::reinitSensor(const twoDModel::view::SensorItem &sensor)
{
	// box2d doesn't rotate or shift elements, which are connected to main robot body via joints in case
	// when we manually use method SetTransform.
	// So we need to handle elements such as sensors by hand.
	// We use this method in case when user shifts or rotates sensor(s).

	auto box2dSensor = mSensors[&sensor];
	box2dSensor->getBody()->SetLinearVelocity({0, 0});
	box2dSensor->getBody()->SetAngularVelocity(0);
	if (const b2JointEdge *jointList = box2dSensor->getBody()->GetJointList()) {
		auto joint = jointList->joint;
		mJoints.removeAll(joint);
		mWorld.DestroyJoint(joint);
	}

	QPolygonF collidingPolygon = sensor.collidingPolygon();
	QPointF localCenter = collidingPolygon.boundingRect().center();

	QPointF deltaToCenter = mModel->rotationCenter() - mModel->position();
	QPointF localPos = sensor.pos() - deltaToCenter;
	QTransform transform;
	QPointF dif = mModel->rotationCenter();
	transform.translate(-dif.x(), -dif.y());
	transform.rotate(mModel->rotation());
	localPos = transform.map(localPos);
	transform.reset();
	transform.translate(dif.x(), dif.y());
	localPos = transform.map(localPos);

	const b2Vec2 pos = mEngine->positionToBox2D(localPos - localCenter + mModel->rotationCenter());
	// IMPORTANT: we connect every sensor with box2d circle item.
	// So rotation of sensor doesn't matter, we set rotation corresponding to robot.
	// if in future it will be changed, you'll see some strange behavior, because of joints. See connectSensor method.
	mSensors[&sensor]->getBody()->SetTransform(pos, mBody->GetAngle());
	connectSensor(*mSensors[&sensor]);
}
开发者ID:ZiminGrigory,项目名称:qreal,代码行数:37,代码来源:box2DRobot.cpp

示例14: paint


//.........这里部分代码省略.........
				painter->setOpacity(curve->lineOpacity());
				painter->drawLine(0, h/2, lineSymbolWidth, h/2);
			}

			//error bars
			if ( (curve->xErrorType() != XYCurve::NoError) || (curve->yErrorType() != XYCurve::NoError) ) {
				painter->setOpacity(curve->errorBarsOpacity());
				painter->setPen(curve->errorBarsPen());

				//curve's error bars for x
				float errorBarsSize = Worksheet::convertToSceneUnits(10, Worksheet::Point);
				if (curve->symbolsStyle()!=Symbol::NoSymbols && errorBarsSize<curve->symbolsSize()*1.4)
					errorBarsSize = curve->symbolsSize()*1.4;

				switch(curve->errorBarsType()) {
					case XYCurve::ErrorBarsSimple:
						//horiz. line
						painter->drawLine(lineSymbolWidth/2-errorBarsSize/2, h/2,
										  lineSymbolWidth/2+errorBarsSize/2, h/2);
						//vert. line
						painter->drawLine(lineSymbolWidth/2, h/2-errorBarsSize/2,
										  lineSymbolWidth/2, h/2+errorBarsSize/2);
						break;
					case XYCurve::ErrorBarsWithEnds: {
						//horiz. line
						painter->drawLine(lineSymbolWidth/2-errorBarsSize/2, h/2,
										  lineSymbolWidth/2+errorBarsSize/2, h/2);

						//vert. line
						painter->drawLine(lineSymbolWidth/2, h/2-errorBarsSize/2,
										  lineSymbolWidth/2, h/2+errorBarsSize/2);

						//caps for the horiz. line
						painter->drawLine(lineSymbolWidth/2-errorBarsSize/2, h/2-errorBarsSize/4,
										  lineSymbolWidth/2-errorBarsSize/2, h/2+errorBarsSize/4);
						painter->drawLine(lineSymbolWidth/2+errorBarsSize/2, h/2-errorBarsSize/4,
										  lineSymbolWidth/2+errorBarsSize/2, h/2+errorBarsSize/4);

						//caps for the vert. line
						painter->drawLine(lineSymbolWidth/2-errorBarsSize/4, h/2-errorBarsSize/2,
										  lineSymbolWidth/2+errorBarsSize/4, h/2-errorBarsSize/2);
						painter->drawLine(lineSymbolWidth/2-errorBarsSize/4, h/2+errorBarsSize/2,
										  lineSymbolWidth/2+errorBarsSize/4, h/2+errorBarsSize/2);
						break;
					}
				}
			}

			//curve's symbol
			if (curve->symbolsStyle()!=Symbol::NoSymbols){
				painter->setOpacity(curve->symbolsOpacity());
				painter->setBrush(curve->symbolsBrush());
				painter->setPen(curve->symbolsPen());

				QPainterPath path = Symbol::pathFromStyle(curve->symbolsStyle());
				QTransform trafo;
				trafo.scale(curve->symbolsSize(), curve->symbolsSize());
				path = trafo.map(path);

				if (curve->symbolsRotationAngle() != 0) {
					trafo.reset();
					trafo.rotate(curve->symbolsRotationAngle());
					path = trafo.map(path);
				}

				painter->translate(QPointF(lineSymbolWidth/2, h/2));
				painter->drawPath(path);
				painter->translate(-QPointF(lineSymbolWidth/2, h/2));
			}

			//curve's name
			painter->setPen(QPen(labelColor));
			painter->setOpacity(1.0);
			painter->drawText(QPoint(lineSymbolWidth+layoutHorizontalSpacing, h), curve->name());
			painter->translate(0,layoutVerticalSpacing+h);
		}

		//translate to the beginning of the next column
		painter->restore();
		int deltaX = lineSymbolWidth+layoutHorizontalSpacing+maxColumnTextWidths.at(c); //the width of the current columns
		deltaX += 2*layoutHorizontalSpacing; //spacing between two columns
		painter->translate(deltaX,0);
		painter->save();
	}

	painter->restore();
	painter->restore();

	if (m_hovered && !isSelected() && !m_printing){
		painter->setPen(q->hoveredPen);
		painter->setOpacity(q->hoveredOpacity);
		painter->drawPath(shape());
	}

	if (isSelected() && !m_printing){
		painter->setPen(q->selectedPen);
		painter->setOpacity(q->selectedOpacity);
		painter->drawPath(shape());
	}
}
开发者ID:asemke,项目名称:labplot,代码行数:101,代码来源:CartesianPlotLegend.cpp

示例15: grabFramesLoop

void grabFramesLoop(bool &streaming, framebufferinfo &info, QQueue<QByteArray> &queue, QOrientationReading::Orientation &orientation)
{
    QImage img(info.scrinfo.xres, info.scrinfo.yres, QImage::Format_RGBA8888);
    QBuffer imgBuffer;

    QElapsedTimer timer;
    timer.start();

    int frames = 0;
    int old = 0;
    int now = 0;
    int line = info.fix_scrinfo.line_length / 4;
    QByteArray ba;
    QTransform transform;

    while(streaming) {

        for (unsigned int y = 0; y < info.scrinfo.yres; ++y)
        {
            QRgb *rowData = (QRgb*)img.scanLine(y);
            for (unsigned int x = 0; x < info.scrinfo.xres; ++x)
            {
                rowData[x] = *((unsigned int *)info.fbmmap + ((x + info.scrinfo.xoffset) + (y + info.scrinfo.yoffset) * line));
            }
        }

        imgBuffer.setBuffer(&ba);
        imgBuffer.open(QIODevice::WriteOnly);

        if(orientation != QOrientationReading::TopUp) {

            switch (orientation) {
                case QOrientationReading::TopDown:
                    img = img.transformed(transform.rotate(180));
                    break;
                case QOrientationReading::LeftUp:
                    img = img.transformed(transform.rotate(90));
                    break;
                case QOrientationReading::RightUp:
                    img = img.transformed(transform.rotate(-90));
                    break;
                default:
                    break;
            }

            img.save(&imgBuffer, "JPG", info.compression);
            transform.reset();
            // reset to original (correct width x height)
            img = QImage(info.scrinfo.xres, info.scrinfo.yres, QImage::Format_RGBA8888);

        } else {
            img.save(&imgBuffer, "JPG", info.compression);
        }

        queue.enqueue(ba);
        imgBuffer.close();

        ++frames;
        now = timer.elapsed();

        if(now > old) {
            info.frametime = now - old;
        }

        old = now;

        // get average fps over the last 50 frames
        if(frames == 50) {
            info.fps = round(50.0 / (timer.restart() / 1000.0));
            frames = 0;
        }
    }
    return;
}
开发者ID:kimmoli,项目名称:SailCast,代码行数:74,代码来源:screenprovider.cpp


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