本文整理汇总了C++中QPainter::rotate方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::rotate方法的具体用法?C++ QPainter::rotate怎么用?C++ QPainter::rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::rotate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawForeground
void QamTachymeter::drawForeground(QPainter& painter )
{
float len ; // longueur de l'aiguille orientée 0X+
QVector<QPointF> pts ; // points de construction dans demi-plan 0Y+
QColor white(230,230,230) ; // couleur de la pointe
// aiguille "Rotor"
len = 0.95 * m_radius[ROTOR] ;
pts.clear() ;
pts << QPointF( 0, 15 ) << QPointF( len - 60, 15 ) << QPointF( len, 0 ) ;
painter.save() ;
painter.rotate(m_start[ROTOR] + m_step[ROTOR] * ( value(ROTOR) / 10 ) ) ;
qfiNeedle(painter, white, pts, 30, 0, 0.4 * len ) ;
painter.restore() ;
// aiguille "Turbine" (transparente)
len = 0.8 * m_radius[TURBINE] ;
pts.clear() ;
pts << QPointF( -0.4 * m_radius[TURBINE], 20 ) << QPointF( len - 80, 20 ) << QPointF( len, 0 ) ;
painter.save() ;
painter.rotate(m_start[TURBINE] + m_step[TURBINE] * ( value(TURBINE) / 1000 ) ) ;
qfiNeedle(painter, QColor(200, 200, 200, 120 ), pts, 40, 80 ) ;
painter.restore() ;
// axe central
qfiAxis(painter, 30 ) ;
}
示例2: drawRotatedText
static void drawRotatedText (QPainter &p, int x, int y, float angle, const QString text) {
p.translate(x, y);
p.rotate(angle);
p.drawText(0, 0, text);
p.rotate(-1*angle);
p.translate(-1*x, -1*y);
}
示例3: drawShape
void PicItem::drawShape( QPainter & p )
{
int _x = int(x());
int _y = int(y());
p.setBrush( QColor( 0xef, 0xff, 0xef ) );
p.setFont( font() );
p.drawRoundRect( _x, _y, width(), height(), 2000/width(), 2000/height() );
p.drawText( _x+TopPadding-2, _y, width()-TopPadding+2, TopPadding, Qt::AlignVCenter, i18n("PIC Settings") );
if ( !m_bExpanded )
return;
// Draw rectangle to cut off pins
p.setBrush( QColor( 239, 255, 255 ) );
QRect r( _x+SidePadding, _y+TopPadding, InnerWidth, m_innerHeight );
p.drawRect(r);
// Draw dimple thingy at end of pic
p.drawArc( r.x()+(r.width()-ArcWidth)/2, r.y()+1-ArcWidth/2, ArcWidth, ArcWidth, 180*16, 180*16 );
// Draw vertical text centered in PIC
p.translate( r.width()/2 + r.x(), r.height()/2 + r.y() );
p.rotate(90);
QRect textRect( r.width()/-2, r.height()/-2, r.width(), r.height() );
p.drawText( textRect, Qt::AlignCenter, microSettings->microInfo()->id() );
p.rotate(-90);
p.translate( r.width()/-2 - r.x(), r.height()/-2 - r.y() );
}
示例4: drawEdge
void MaxFlowVisualizer::drawEdge(const Edge &edge, QPainter &painter) const {
QPen pen;
pen.setWidth(3);
// Ребро, которое считается "допустимым" по алгоритму, выделяем черным.
if (relabelToFrontAlgo.getVertexHeight(edge.getFirstVertexIndex())
== relabelToFrontAlgo.getVertexHeight(edge.getSecondVertexIndex()) + 1) {
pen.setColor(Qt::black);
}
else {
pen.setColor(Qt::gray);
}
if (edge.getFlow() != 0) {
pen.setColor(Qt::darkBlue);
}
// Если в последнем действии алгоритма произошло проталкивание по этому ребру,
// то выделим его красным.
if (lastAlgoAction.getType() == AlgoAction::ACTION_PUSH && lastAlgoAction.getEdgeInfo() == edge) {
pen.setColor(Qt::red);
}
painter.setPen(pen);
QPoint pointFrom(verteciesList[edge.getFirstVertexIndex()].getCenterCoordX(),
verteciesList[edge.getFirstVertexIndex()].getCenterCoordY());
QPoint pointTo(verteciesList[edge.getSecondVertexIndex()].getCenterCoordX(),
verteciesList[edge.getSecondVertexIndex()].getCenterCoordY());
double length = sqrt(pow(pointFrom.x() - pointTo.x(), 2)
+ pow(pointFrom.y() - pointTo.y(), 2));
long vertexRaduis = verteciesList[edge.getSecondVertexIndex()].getRadius();
QPoint offsetVector((pointFrom.x() - pointTo.x()) * vertexRaduis / length,
(pointFrom.y() - pointTo.y()) * vertexRaduis / length);
QPoint arrow((pointFrom.x() - pointTo.x()) * 20 / length,
(pointFrom.y() - pointTo.y()) * 20 / length);
// Рисование стрелки (самих маленьких боковых линий).
// Перенесем систему координат в точку конца ребра (ориенированного).
// Возьмем маленький отрезок ребра, и нарисуем его, повернув при этом систуму координат
// на +30 и -30 градусов соответственно относительно исходного ребра.
// Получилась стрелка ->
// После этого восстановим систему координат.
painter.setPen(pen);
painter.drawLine(pointFrom, pointTo);
painter.translate(pointTo.x(), pointTo.y());
// Еще нужно отступить от конца ребра на радиус вершины
// (т.к. ребро идет от центра к центру).
painter.translate(offsetVector.x(), offsetVector.y());
painter.rotate(30);
painter.drawLine(QPoint(0, 0), arrow);
painter.rotate(-60);
painter.drawLine(QPoint(0, 0), arrow);
painter.resetTransform();
// Выводим информацию о ребре (flow | capacity) по середине ребра.
if (state == ALGORITHM_RUN || (state == ALGORITHM_TERM && edge.flow != 0)) {
QPen penForEdgeInfo;
penForEdgeInfo.setColor(Qt::darkGreen);
painter.setPen(penForEdgeInfo);
std::string edgeInfo = "(" + std::to_string(edge.getFlow()) + " | " + std::to_string(edge.getCapacity()) + ")";
painter.drawText(pointFrom.x() + (pointTo.x() - pointFrom.x()) / 2,
pointFrom.y() + (pointTo.y() - pointFrom.y()) / 2,
edgeInfo.c_str());
}
}
示例5: paint
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc)
{
p.setRenderHint(QPainter::Antialiasing, true);
p.setPen(dialColor);
p.setBrush(dialColor);
int dialStartAngle = 225 * 16;
int dialSpanAngle = -270 * 16;
// draw dial arc
p.drawArc(dialRect, dialStartAngle, dialSpanAngle);
// draw ticks
p.save();
p.translate(dialRect.center());
p.rotate(45);
for (uint64_t i = 0; i < _div; i++) {
// draw major ticks
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+8);
// draw minor ticks
for (uint64_t j = 0; (j < 5) && (i < _div - 1); j++) {
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+5);
p.rotate(54.0/(_div-1));
}
}
// draw pointer
p.rotate(90+270.0/(_div-1)*_sel);
p.drawEllipse(-3, -3, 6, 6);
p.drawLine(3, 0, 0, dialRect.width()/2-3);
p.drawLine(-3, 0, 0, dialRect.width()/2-3);
p.restore();
// draw value
uint64_t displayValue = _value[_sel]*_factor;
uint64_t displayIndex = 0;
while(displayValue / _step >= 1) {
displayValue = displayValue / _step;
displayIndex++;
}
QString pText = QString::number(displayValue) + _unit[displayIndex] + "/div";
QFontMetrics fm(p.font());
const QRectF valueRect = QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, dialRect.width(), fm.height());
p.drawText(valueRect, Qt::AlignCenter, pText);
// draw +/-
if (hover) {
const int arcInc = 15;
const QRectF hoverRect = QRectF(dialRect.left()-arcInc, dialRect.top()-arcInc, dialRect.width()+arcInc*2, dialRect.height()+arcInc*2);
const double arcSpan = hoverRect.width()/(2*sqrt(2));
p.drawArc(hoverRect, 135 * 16, -90 * 16);
if (inc)
p.drawLine(hoverRect.center().x()+arcSpan, hoverRect.center().y()-arcSpan,
hoverRect.center().x()+arcSpan-4, hoverRect.center().y()-arcSpan-10);
else
p.drawLine(hoverRect.center().x()-arcSpan, hoverRect.center().y()-arcSpan,
hoverRect.center().x()-arcSpan+4, hoverRect.center().y()-arcSpan-10);
}
}
示例6: drawOutline
void KisColorSelector::drawOutline(QPainter& painter, const QRect& rect)
{
painter.setRenderHint(QPainter::Antialiasing, true);
painter.resetTransform();
painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
painter.scale(rect.width()/2, rect.height()/2);
painter.setPen(QPen(QBrush(Qt::gray), 0.005));
if (getNumPieces() > 1) {
for(int i=0; i<getNumRings(); ++i) {
painter.resetTransform();
painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
painter.scale(rect.width()/2, rect.height()/2);
painter.rotate(-m_colorRings[i].getShift().degrees());
for(int j=0; j<m_colorRings[i].pieced.size(); ++j)
painter.drawPath(m_colorRings[i].pieced[j]);
}
if (m_selectedRing >= 0 && m_selectedPiece >= 0) {
painter.resetTransform();
painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
painter.rotate(-m_colorRings[m_selectedRing].getShift().degrees());
painter.scale(rect.width()/2, rect.height()/2);
painter.setPen(QPen(QBrush(Qt::red), 0.01));
painter.drawPath(m_colorRings[m_selectedRing].pieced[m_selectedPiece]);
}
}
else {
for(int i=0; i<getNumRings(); ++i) {
qreal rad = m_colorRings[i].outerRadius;
painter.drawEllipse(QRectF(-rad, -rad, rad*2.0, rad*2.0));
}
}
if (m_selectedRing >= 0) {
qreal iRad = m_colorRings[m_selectedRing].innerRadius;
qreal oRad = m_colorRings[m_selectedRing].outerRadius;
painter.setPen(QPen(QBrush(Qt::red), 0.005));
painter.drawEllipse(QRectF(-iRad, -iRad, iRad*2.0, iRad*2.0));
painter.drawEllipse(QRectF(-oRad, -oRad, oRad*2.0, oRad*2.0));
if (getNumPieces() <= 1) {
float c = std::cos(-m_selectedColor.getH() * PI2);
float s = std::sin(-m_selectedColor.getH() * PI2);
painter.drawLine(QPointF(c*iRad, s*iRad), QPointF(c*oRad, s*oRad));
}
}
}
示例7: outputOffset
void QgsFontMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
QPainter *p = context.renderContext().painter();
if ( !p )
return;
QColor penColor = context.selected() ? context.renderContext().selectionColor() : mColor;
penColor.setAlphaF( mColor.alphaF() * context.alpha() );
p->setPen( penColor );
p->setFont( mFont );
p->save();
//offset
double offsetX = 0;
double offsetY = 0;
markerOffset( context, offsetX, offsetY );
QPointF outputOffset( offsetX, offsetY );
if ( mAngle )
outputOffset = _rotatedOffset( outputOffset, mAngle );
p->translate( point + outputOffset );
if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
{
double s = mSize / mOrigSize;
p->scale( s, s );
}
if ( mAngle != 0 )
p->rotate( mAngle );
p->drawText( -mChrOffset, mChr );
p->restore();
}
示例8: transformPainter
void RenderArea::transformPainter(QPainter &painter)
{
for (int i = 0; i < operations.size(); ++i)
{
switch (operations[i])
{
case mover:
painter.translate(20.0, 20.0);
break;
case Crecer:
painter.scale(1.5, 1.5);
break;
case Decrecer:
painter.scale(0.5, 0.5);
break;
case Rotar:
painter.rotate(125);
break;
/*Al decrecerlo, se gira en el eje x-z en un sistema tridimensional imaginario,
pero también se podría hacer desde una matriz.*/
case MirrorXAxis:
painter.scale(1,-1);
break;
case MirrorYAxis:
painter.scale(-1,1);
break;
case MirrorDouble:
painter.scale(-1,-1);
break;
case Default:
default:
;
}
}
}
示例9: DrawThrusterIcon
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tBoatWidget::DrawThrusterIcon( QPainter& painter, int yPos )
{
painter.save();
QColor thrusterColor = tSystemSettings::Instance()->NightMode() ? Qt::darkGray : Qt::black;
int w_2 = width()/2;
painter.translate( QPointF(w_2, yPos) );
painter.setRenderHint(QPainter::Antialiasing, false);
painter.setPen( QPen(thrusterColor, 1) );
painter.drawLine(-5,0,5,0);
painter.drawLine(0,-5,0,5);
painter.setRenderHint(QPainter::Antialiasing, true);
for(int i=0;i<4;i++)
{
painter.save();
painter.translate(QPointF(0.5, 0.5));
painter.rotate(i*90);
QPainterPath p1;
p1.lineTo( QPointF( -4.5, -13 ) );
p1.lineTo( QPointF( 4.5, -13 ) );
painter.fillPath( p1, thrusterColor );
painter.restore();
}
painter.setPen( QPen(thrusterColor, 3.5) );
painter.drawEllipse(QPointF(0.5,0.5),13.0, 13.0);
painter.restore();
}
示例10: setShapePainter
void KPaintShape::setShapePainter(QPainter &painter, QPointF ¢ralPoint, float angle, bool bScale)
{
if (angle >= g_cfNearZero || angle <= -g_cfNearZero)
{
if (bScale)
{
//painter.translate(m_pointOldShapeCenterPoint);
}
else
{
painter.translate(centralPoint);
}
painter.rotate(angle);
if (bScale)
{
//painter.translate(-m_pointOldShapeCenterPoint);
}
else
{
painter.translate(-centralPoint);
}
}
}
示例11: valueAxisTitle
void CMeter2DGraphView::UpdateValueAxisTitle()
{
TRACE_FUN( Frequently, "CMeter2DGraphView::UpdateValueAxisTitle" );
QString valueAxisTitle( QString::fromUtf8( model()->valueAxisTitle().c_str() ) );
QRect valueAxisTitleRect( QFontMetrics( _boldFont ).boundingRect( 0, 0, _meshArea.height(), 0, Qt::AlignCenter | Qt::TextWordWrap,
valueAxisTitle ) );
_meshArea.setLeft( 0 );
_meshArea.adjust( valueAxisTitleRect.height(), 0, 0, 0 );
SRaster& raster( _rasterContainer[ CMeter2DGraphView::rtValueAxisTitle ] );
raster._x = _meshArea.x() - valueAxisTitleRect.height();
raster._y = _meshArea.y() + _meshArea.height() / 2 + valueAxisTitleRect.width() / 2;
raster._image = QImage( valueAxisTitleRect.height(), valueAxisTitleRect.width(), QImage::Format_ARGB32 );
QPainter painter;
InitializeRasterRenderer( painter, raster._image );
painter.setFont( _boldFont );
painter.rotate( -90 );
painter.drawText( -valueAxisTitleRect.width(), 0,
valueAxisTitleRect.width(), valueAxisTitleRect.height(),
Qt::AlignCenter | Qt::TextWordWrap, valueAxisTitle );
}
示例12: Draw
void Needle::Draw(
QPainter& P, //! The painter object
qreal fAngleDeg //! Needle angle given in degrees.
)
{
P.save();
P.rotate(-fAngleDeg);
if(m_eType != tPlain && m_eType != tPlainLabel) {
bool bActive = P.testRenderHint(QPainter::SmoothPixmapTransform);
if(!bActive)
P.setRenderHint(QPainter::SmoothPixmapTransform, true);
P.drawPixmap(QPointF(0.0,-m_size.height()/2.0), m_px);
if(!bActive)
P.setRenderHint(QPainter::SmoothPixmapTransform, false);
}
else {
P.setPen(QPen(Qt::white, m_size.height()));
P.drawLine(m_iOffset, 0, m_size.width(), 0);
}
if(m_eType == tPlainLabel) {
qreal fH = 9;
P.setPen(QPen(Qt::white, 2));
P.drawEllipse(0.5*m_size.width()-fH/2, -fH/2, fH,fH);
}
P.restore();
}
示例13: transformPainter
void RenderArea::transformPainter(QPainter &painter)
{
for (int i = 0; i < operations.size(); ++i)
{
switch (operations[i])
{
case Translate:
painter.translate(20.0, 20.0);
break;
case ZoomIn:
painter.scale(1.5, 1.5);
break;
case ZoomOut:
painter.scale(0.5, 0.5);
break;
case Rotate:
painter.rotate(125);
break;
case ReflectionX:
painter.scale(1,-1);
break;
case ReflectionY:
painter.scale(-1,1);
break;
case Reflection:
painter.scale(-1,-1);
break;
case NoTransformation:
default:
;
}
}
}
示例14: height
//***************************************************************************
void Kwave::ScaleWidget::paintEvent(QPaintEvent *)
{
bool inverse = false;
int h = height();
int w = width();
QPainter p;
p.begin(this);
p.save();
p.setPen(palette().light().color());
p.drawLine(0, 0, w, 0);
if (h > w) {
p.setWindow(-w, 0, w, h);
p.rotate(-90);
h = width();
w = height();
inverse = true;
}
(m_logmode) ? drawLog(p, w, h, inverse) : drawLinear(p, w, h, inverse);
p.restore();
p.end();
}
示例15: setRotate
void Interface::setRotate( int r)
{
if (r < 360) { /* -360 - 360 */
rotazione = r;
/////QPixmap base(origImageFilename);
QImage base(origImageFilename);
int massimo = QMAX(base.width(),base.height()); /* find max cube from image */
int fotox = (massimo / 2) - (base.width() / 2);
int fotoy = (massimo / 2) - (base.height() / 2);
QPixmap nuovo(massimo,massimo);
QPainter painter;
painter.begin(&nuovo);
painter.setRenderHint(QPainter::Antialiasing);
painter.translate((massimo / 2),(massimo / 2));
painter.rotate(r);
painter.translate(-(massimo / 2),-(massimo / 2));
/////painter.drawPixmap(fotox,fotoy,base);
painter.drawImage(fotox,fotoy,base,Qt::MonoOnly);
painter.end();
int newlarge = (massimo/cento)*ratio;
display = nuovo.scaledToWidth(newlarge,Qt::FastTransformation);
original = nuovo;
wrapper->paint(display);
////////SetZoom( ratio );
airotato = true;
}
}