本文整理汇总了C++中QPointF类的典型用法代码示例。如果您正苦于以下问题:C++ QPointF类的具体用法?C++ QPointF怎么用?C++ QPointF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPointF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCurveAttribute
/*!
Draw step function
The direction of the steps depends on Inverted attribute.
\param painter Painter
\param xMap x map
\param yMap y map
\param canvasRect Contents rectangle of the canvas
\param from index of the first point to be painted
\param to index of the last point to be painted
\sa CurveAttribute, setCurveAttribute(),
draw(), drawCurve(), drawDots(), drawLines(), drawSticks()
*/
void QwtPlotCurve::drawSteps( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const
{
const bool doAlign = QwtPainter::roundingAlignment( painter );
QPolygonF polygon( 2 * ( to - from ) + 1 );
QPointF *points = polygon.data();
bool inverted = orientation() == Qt::Vertical;
if ( d_data->attributes & Inverted )
inverted = !inverted;
const QwtSeriesData<QPointF> *series = data();
int i, ip;
for ( i = from, ip = 0; i <= to; i++, ip += 2 )
{
const QPointF sample = series->sample( i );
double xi = xMap.transform( sample.x() );
double yi = yMap.transform( sample.y() );
if ( doAlign )
{
xi = qRound( xi );
yi = qRound( yi );
}
if ( ip > 0 )
{
const QPointF &p0 = points[ip - 2];
QPointF &p = points[ip - 1];
if ( inverted )
{
p.rx() = p0.x();
p.ry() = yi;
}
else
{
p.rx() = xi;
p.ry() = p0.y();
}
}
points[ip].rx() = xi;
points[ip].ry() = yi;
}
if ( d_data->paintAttributes & ClipPolygons )
{
QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
const qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
const QPolygonF clipped = QwtClipper::clipPolygonF(
clipRect, polygon, false );
QwtPainter::drawPolyline( painter, clipped );
}
else
{
QwtPainter::drawPolyline( painter, polygon );
}
if ( d_data->brush.style() != Qt::NoBrush )
fillCurve( painter, xMap, yMap, canvasRect, polygon );
}
示例2: QPointF
void QtGradientWidget::mousePressEvent(QMouseEvent *e)
{
if (e->button() != Qt::LeftButton)
return;
QPoint p = e->pos();
if (d_ptr->m_gradientType == QGradient::LinearGradient) {
QPointF startPoint = d_ptr->toViewport(d_ptr->m_startLinear);
double x = p.x() - startPoint.x();
double y = p.y() - startPoint.y();
if ((d_ptr->m_handleSize * d_ptr->m_handleSize / 4) > (x * x + y * y)) {
d_ptr->m_dragHandle = QtGradientWidgetPrivate::StartLinearHandle;
d_ptr->m_dragOffset = QPointF(x, y);
update();
return;
}
QPointF endPoint = d_ptr->toViewport(d_ptr->m_endLinear);
x = p.x() - endPoint.x();
y = p.y() - endPoint.y();
if ((d_ptr->m_handleSize * d_ptr->m_handleSize / 4) > (x * x + y * y)) {
d_ptr->m_dragHandle = QtGradientWidgetPrivate::EndLinearHandle;
d_ptr->m_dragOffset = QPointF(x, y);
update();
return;
}
} else if (d_ptr->m_gradientType == QGradient::RadialGradient) {
QPointF focalPoint = d_ptr->toViewport(d_ptr->m_focalRadial);
double x = p.x() - focalPoint.x();
double y = p.y() - focalPoint.y();
if ((d_ptr->m_handleSize * d_ptr->m_handleSize / 9) > (x * x + y * y)) {
d_ptr->m_dragHandle = QtGradientWidgetPrivate::FocalRadialHandle;
d_ptr->m_dragOffset = QPointF(x, y);
update();
return;
}
QPointF centralPoint = d_ptr->toViewport(d_ptr->m_centralRadial);
x = p.x() - centralPoint.x();
y = p.y() - centralPoint.y();
if ((d_ptr->m_handleSize * d_ptr->m_handleSize / 4) > (x * x + y * y)) {
d_ptr->m_dragHandle = QtGradientWidgetPrivate::CentralRadialHandle;
d_ptr->m_dragOffset = QPointF(x, y);
update();
return;
}
QPointF central = d_ptr->toViewport(d_ptr->m_centralRadial);
QRectF r = d_ptr->pointRect(central, 2 * d_ptr->m_handleSize / 3);
QRectF r1(0, r.y(), size().width(), r.height());
QRectF r2(r.x(), 0, r.width(), r.y());
QRectF r3(r.x(), r.y() + r.height(), r.width(), size().height() - r.y() - r.height());
QPointF pF(p.x(), p.y());
if (r1.contains(pF) || r2.contains(pF) || r3.contains(pF)) {
x = pF.x() / size().width() - d_ptr->m_centralRadial.x();
y = pF.y() / size().height() - d_ptr->m_centralRadial.y();
double clickRadius = sqrt(x * x + y * y);
//d_ptr->m_radiusOffset = d_ptr->m_radiusRadial - clickRadius;
d_ptr->m_radiusFactor = d_ptr->m_radiusRadial / clickRadius;
if (d_ptr->m_radiusFactor == 0)
d_ptr->m_radiusFactor = 1;
d_ptr->m_dragRadius = d_ptr->m_radiusRadial;
d_ptr->m_dragHandle = QtGradientWidgetPrivate::RadiusRadialHandle;
mouseMoveEvent(e);
update();
return;
}
} else if (d_ptr->m_gradientType == QGradient::ConicalGradient) {
QPointF centralPoint = d_ptr->toViewport(d_ptr->m_centralConical);
double x = p.x() - centralPoint.x();
double y = p.y() - centralPoint.y();
if ((d_ptr->m_handleSize * d_ptr->m_handleSize / 4) > (x * x + y * y)) {
d_ptr->m_dragHandle = QtGradientWidgetPrivate::CentralConicalHandle;
d_ptr->m_dragOffset = QPointF(x, y);
update();
return;
}
double radius = size().width();
if (size().height() < radius)
radius = size().height();
radius /= 2;
double corr = d_ptr->m_handleSize / 3;
radius -= corr;
QPointF vp = d_ptr->toViewport(d_ptr->m_centralConical);
x = p.x() - vp.x();
y = p.y() - vp.y();
if (((radius - corr) * (radius - corr) < (x * x + y * y)) &&
((radius + corr) * (radius + corr) > (x * x + y * y))) {
QPointF central = d_ptr->toViewport(d_ptr->m_centralConical);
QPointF current(e->pos().x(), e->pos().y());
x = current.x() - central.x();
y = current.y() - central.y();
x /= size().width() / 2;
y /= size().height() / 2;
double r = sqrt(x * x + y * y);
//.........这里部分代码省略.........
示例3: Q_UNUSED
void QtGradientWidget::paintEvent(QPaintEvent *e)
{
Q_UNUSED(e)
QPainter p(this);
if (d_ptr->m_backgroundCheckered) {
int pixSize = 40;
QPixmap pm(2 * pixSize, 2 * pixSize);
QPainter pmp(&pm);
pmp.fillRect(0, 0, pixSize, pixSize, Qt::white);
pmp.fillRect(pixSize, pixSize, pixSize, pixSize, Qt::white);
pmp.fillRect(0, pixSize, pixSize, pixSize, Qt::black);
pmp.fillRect(pixSize, 0, pixSize, pixSize, Qt::black);
p.setBrushOrigin((size().width() % pixSize + pixSize) / 2, (size().height() % pixSize + pixSize) / 2);
p.fillRect(rect(), pm);
p.setBrushOrigin(0, 0);
}
QGradient *gradient = 0;
switch (d_ptr->m_gradientType) {
case QGradient::LinearGradient:
gradient = new QLinearGradient(d_ptr->m_startLinear, d_ptr->m_endLinear);
break;
case QGradient::RadialGradient:
gradient = new QRadialGradient(d_ptr->m_centralRadial, d_ptr->m_radiusRadial, d_ptr->m_focalRadial);
break;
case QGradient::ConicalGradient:
gradient = new QConicalGradient(d_ptr->m_centralConical, d_ptr->m_angleConical);
break;
default:
break;
}
if (!gradient)
return;
gradient->setStops(d_ptr->m_gradientStops);
gradient->setSpread(d_ptr->m_gradientSpread);
p.save();
p.scale(size().width(), size().height());
p.fillRect(QRect(0, 0, 1, 1), *gradient);
p.restore();
p.setRenderHint(QPainter::Antialiasing);
QColor c = QColor::fromRgbF(0.5, 0.5, 0.5, 0.5);
QBrush br(c);
p.setBrush(br);
QPen pen(Qt::white);
pen.setWidthF(1);
p.setPen(pen);
QPen dragPen = pen;
dragPen.setWidthF(2);
if (d_ptr->m_gradientType == QGradient::LinearGradient) {
p.save();
if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::StartLinearHandle)
p.setPen(dragPen);
d_ptr->paintPoint(&p, d_ptr->m_startLinear, d_ptr->m_handleSize);
p.restore();
p.save();
if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::EndLinearHandle)
p.setPen(dragPen);
d_ptr->paintPoint(&p, d_ptr->m_endLinear, d_ptr->m_handleSize);
p.restore();
} else if (d_ptr->m_gradientType == QGradient::RadialGradient) {
QPointF central = d_ptr->toViewport(d_ptr->m_centralRadial);
p.save();
QRectF r = d_ptr->pointRect(central, 2 * d_ptr->m_handleSize / 3);
QRectF r1(0, r.y(), size().width(), r.height());
QRectF r2(r.x(), 0, r.width(), r.y());
QRectF r3(r.x(), r.y() + r.height(), r.width(), size().height() - r.y() - r.height());
p.fillRect(r1, c);
p.fillRect(r2, c);
p.fillRect(r3, c);
p.setBrush(Qt::NoBrush);
p.save();
if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::CentralRadialHandle)
p.setPen(dragPen);
d_ptr->paintPoint(&p, d_ptr->m_centralRadial, d_ptr->m_handleSize);
p.restore();
QRectF rect = QRectF(central.x() - d_ptr->m_radiusRadial * size().width(),
central.y() - d_ptr->m_radiusRadial * size().height(),
2 * d_ptr->m_radiusRadial * size().width(),
2 * d_ptr->m_radiusRadial * size().height());
p.setClipRect(r1);
p.setClipRect(r2, Qt::UniteClip);
p.setClipRect(r3, Qt::UniteClip);
p.drawEllipse(rect);
if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::RadiusRadialHandle) {
p.save();
p.setPen(dragPen);
QRectF rect = QRectF(central.x() - d_ptr->m_radiusRadial / d_ptr->m_radiusFactor * size().width(),
central.y() - d_ptr->m_radiusRadial / d_ptr->m_radiusFactor * size().height(),
2 * d_ptr->m_radiusRadial / d_ptr->m_radiusFactor * size().width(),
//.........这里部分代码省略.........
示例4: selectedItem
void QgsMapToolAnnotation::canvasMoveEvent( QMouseEvent * e )
{
QgsAnnotationItem* sItem = selectedItem();
if ( sItem && ( e->buttons() & Qt::LeftButton ) )
{
if ( mCurrentMoveAction == QgsAnnotationItem::MoveMapPosition )
{
sItem->setMapPosition( toMapCoordinates( e->pos() ) );
sItem->update();
}
else if ( mCurrentMoveAction == QgsAnnotationItem::MoveFramePosition )
{
if ( sItem->mapPositionFixed() )
{
sItem->setOffsetFromReferencePoint( sItem->offsetFromReferencePoint() + ( e->posF() - mLastMousePosition ) );
}
else
{
QPointF newCanvasPos = sItem->pos() + ( e->posF() - mLastMousePosition );
sItem->setMapPosition( toMapCoordinates( newCanvasPos.toPoint() ) );
}
sItem->update();
}
else if ( mCurrentMoveAction != QgsAnnotationItem::NoAction )
{
//handle the frame resize actions
QSizeF size = sItem->frameSize();
double xmin = sItem->offsetFromReferencePoint().x();
double ymin = sItem->offsetFromReferencePoint().y();
double xmax = xmin + size.width();
double ymax = ymin + size.height();
if ( mCurrentMoveAction == QgsAnnotationItem::ResizeFrameRight ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameRightDown ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameRightUp )
{
xmax += e->posF().x() - mLastMousePosition.x();
}
if ( mCurrentMoveAction == QgsAnnotationItem::ResizeFrameLeft ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameLeftDown ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameLeftUp )
{
xmin += e->posF().x() - mLastMousePosition.x();
}
if ( mCurrentMoveAction == QgsAnnotationItem::ResizeFrameUp ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameLeftUp ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameRightUp )
{
ymin += e->posF().y() - mLastMousePosition.y();
}
if ( mCurrentMoveAction == QgsAnnotationItem::ResizeFrameDown ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameLeftDown ||
mCurrentMoveAction == QgsAnnotationItem::ResizeFrameRightDown )
{
ymax += e->posF().y() - mLastMousePosition.y();
}
//switch min / max if necessary
double tmp;
if ( xmax < xmin )
{
tmp = xmax; xmax = xmin; xmin = tmp;
}
if ( ymax < ymin )
{
tmp = ymax; ymax = ymin; ymin = tmp;
}
sItem->setOffsetFromReferencePoint( QPointF( xmin, ymin ) );
sItem->setFrameSize( QSizeF( xmax - xmin, ymax - ymin ) );
sItem->update();
}
}
else if ( sItem )
{
QgsAnnotationItem::MouseMoveAction moveAction = sItem->moveActionForPosition( e->posF() );
if ( mCanvas )
{
mCanvas->setCursor( QCursor( sItem->cursorShapeForAction( moveAction ) ) );
}
}
mLastMousePosition = e->posF();
}
示例5: pointRect
QRectF QtGradientWidgetPrivate::pointRect(const QPointF &point, double size) const
{
return QRectF(point.x() - size / 2, point.y() - size / 2, size, size);
}
示例6: qDebug
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
QWidget *)
{
qDebug() << "Arrow: paint";
if (myStartItem->collidesWithItem(myEndItem))
return;
/*
QPen myPen = pen();
myPen.setColor(myColor);
qreal arrowSize = 20;
painter->setPen(myPen);
painter->setBrush(myColor);
QLineF centerLine(myStartItem->pos(), myEndItem->pos());
QPolygonF endPolygon = myEndItem->polygon();
//p1 = coordinates of first pointer of enditem in
//scene coordinates
QPointF p1 = endPolygon.first() + myEndItem->pos();
QPointF p2;
QPointF intersectPoint;
QLineF polyLine;
//.count()=.size()
for (int i = 1; i < endPolygon.count(); ++i) {
p2 = endPolygon.at(i) + myEndItem->pos();
polyLine = QLineF(p1, p2);
QLineF::IntersectType intersectType =
polyLine.intersect(centerLine, &intersectPoint);
if (intersectType == QLineF::BoundedIntersection)
break;
p1 = p2;
}
*/
//qreal comp1=intersectPoint.x();
//qreal comp2;
//TODO:
//This is my patch to define input and output points for lines
//All code above this point is rendered useless and should be removed
QPointF intersectPoint;
QPen myPen = pen();
myPen.setColor(myColor);
qreal arrowSize = 20;
painter->setPen(myPen);
painter->setBrush(myColor);
intersectPoint=myEndItem->pos();
intersectPoint.setX(intersectPoint.x()-myEndItem->boundingRect().width()/2);
QPointF otherPoint;
otherPoint=myStartItem->pos();
otherPoint.setX(otherPoint.x()+myStartItem->boundingRect().width()/2);
//original
setLine(QLineF(otherPoint, intersectPoint));
if(isZone2()){
zone2(otherPoint);
}
else{
zone1(otherPoint);
}
//double angle = ::acos(line().dx() / line().length());
double angle=Pi;
if (line().dy() >= 0)
angle = (Pi * 2) - angle;
QPointF arrowP1 = line().p2() + QPointF(sin(angle + Pi / 3) * arrowSize,
cos(angle + Pi / 3) * arrowSize);
QPointF arrowP2 = line().p2() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
cos(angle + Pi - Pi / 3) * arrowSize);
arrowHead.clear();
arrowHead << line().p2() << arrowP1 << arrowP2;
for(int i=0;i<part.size();++i)
painter->drawLine(*part[i]);
//setLine(*part[0]);
//painter->drawLine(line());
painter->drawPolygon(arrowHead);
if (isSelected()) {
painter->setPen(QPen(myColor, 1, Qt::DashLine));
QLineF myLine = line();
myLine.translate(0, 4.0);
painter->drawLine(myLine);
myLine.translate(0,-8.0);
painter->drawLine(myLine);
}
//qDebug() << "PAINT ORDER FINISH";
}
示例7: QPainterPath
void PlotObject::updatePath()
{
_path = QPainterPath();
if (((SelectProperty*) properties()["mode"])->currentIndex() == 0) {
QList<qreal> xValues;
QList<qreal> yValues;
qreal start = ((RealProperty*) properties()["start"])->value();
qreal end = ((RealProperty*) properties()["end"])->value();
qreal pointCount = ((IntegerProperty*) properties()["points"])->value();
qreal step = (end - start) / pointCount;
if (step > 0) {
for (qreal x = start; x <= end; x += step) {
xValues.append(x);
}
} else if (step < 0) {
for (qreal x = start; x >= end; x += step) {
xValues.append(x);
}
} else {
return;
}
if (xValues.isEmpty()) return;
yValues = MathUtility::parse(((PropertyString*) properties()["formular"])->string(), xValues);
_path = QPainterPath(QPointF(xValues.first(), yValues.first()));
for (int i = 1; i < xValues.size(); i++) {
_path.lineTo(xValues[i], yValues[i]);
}
} else {
QList<qreal> alphas;
QList<qreal> radius;
qreal start = ((RealProperty*) properties()["polar-start"])->value() * M_PI/180.0;
qreal end = ((RealProperty*) properties()["polar-end"])->value() * M_PI/180.0;
qreal pointCount = ((IntegerProperty*) properties()["points"])->value();
qreal step = (end - start) / pointCount;
if (step > 0) {
for (qreal x = start; x <= end; x += step) {
alphas.append(x);
}
} else if (step < 0) {
for (qreal x = start; x >= end; x += step) {
alphas.append(x);
}
} else {
return;
}
radius = MathUtility::parse(((PropertyString*) properties()["formular"])->string(), alphas);
auto polarToCart = [](qreal alpha, qreal radius) {
return QPointF(qCos(alpha) * radius,
qSin(alpha) * radius);
};
_path = QPainterPath(polarToCart(alphas.first(), radius.first()));
for (int i = 1; i < alphas.size(); i++) {
QPointF p = polarToCart(alphas[i], radius[i]);
_path.lineTo(p.x(), p.y());
}
}
}
示例8: KInteractionStrategy
ShapeShearStrategy::ShapeShearStrategy(KToolBase *tool, const QPointF &clicked, KFlake::SelectionHandle direction)
: KInteractionStrategy(tool)
, m_start(clicked)
{
KShapeSelection *sel = tool->canvas()->shapeManager()->selection();
QList<KShape*> selectedShapes = sel->selectedShapes(KFlake::StrippedSelection);
foreach (KShape *shape, selectedShapes) {
if (!shape->isEditable())
continue;
m_selectedShapes << shape;
m_oldTransforms << shape->transformation();
}
m_initialSelectionMatrix = sel->transformation();
// Eventhoug we aren't currently activated by the corner handles we might as well code like it
switch (direction) {
case KFlake::TopMiddleHandle:
m_top = true; m_bottom = false; m_left = false; m_right = false; break;
case KFlake::TopRightHandle:
m_top = true; m_bottom = false; m_left = false; m_right = true; break;
case KFlake::RightMiddleHandle:
m_top = false; m_bottom = false; m_left = false; m_right = true; break;
case KFlake::BottomRightHandle:
m_top = false; m_bottom = true; m_left = false; m_right = true; break;
case KFlake::BottomMiddleHandle:
m_top = false; m_bottom = true; m_left = false; m_right = false; break;
case KFlake::BottomLeftHandle:
m_top = false; m_bottom = true; m_left = true; m_right = false; break;
case KFlake::LeftMiddleHandle:
m_top = false; m_bottom = false; m_left = true; m_right = false; break;
case KFlake::TopLeftHandle:
m_top = true; m_bottom = false; m_left = true; m_right = false; break;
default:
Q_ASSERT(0);
}
m_initialSize = sel->size();
m_solidPoint = QPointF(m_initialSize.width() / 2, m_initialSize.height() / 2);
if (m_top)
m_solidPoint += QPointF(0, m_initialSize.height() / 2);
else if (m_bottom)
m_solidPoint -= QPointF(0, m_initialSize.height() / 2);
if (m_left)
m_solidPoint += QPointF(m_initialSize.width() / 2, 0);
else if (m_right)
m_solidPoint -= QPointF(m_initialSize.width() / 2, 0);
QPointF edge;
qreal angle = 0.0;
if (m_top) {
edge = sel->absolutePosition(KFlake::BottomLeftCorner) - sel->absolutePosition(KFlake::BottomRightCorner);
angle = 180.0;
} else if (m_bottom) {
edge = sel->absolutePosition(KFlake::TopRightCorner) - sel->absolutePosition(KFlake::TopLeftCorner);
angle = 0.0;
} else if (m_left) {
edge = sel->absolutePosition(KFlake::BottomLeftCorner) - sel->absolutePosition(KFlake::TopLeftCorner);
angle = 90.0;
} else if (m_right) {
edge = sel->absolutePosition(KFlake::TopRightCorner) - sel->absolutePosition(KFlake::BottomRightCorner);
angle = 270.0;
}
qreal currentAngle = atan2(edge.y(), edge.x()) / M_PI * 180;
m_initialSelectionAngle = currentAngle - angle;
//kDebug() <<" PREsol.x=" << m_solidPoint.x() <<" sol.y=" << m_solidPoint.y();
m_solidPoint = tool->canvas()->shapeManager()->selection()->absoluteTransformation(0).map(m_solidPoint);
// use crossproduct of top edge and left edge of selection bounding rect
// to determine if the selection is mirrored
QPointF top = sel->absolutePosition(KFlake::TopRightCorner) - sel->absolutePosition(KFlake::TopLeftCorner);
QPointF left = sel->absolutePosition(KFlake::BottomLeftCorner) - sel->absolutePosition(KFlake::TopLeftCorner);
m_isMirrored = (top.x()*left.y() - top.y()*left.x()) < 0.0;
}
示例9: b
QPointF operator+(QPointF &p)
{
QPointF b(p.x()+m_X,p.y()+m_Y);
return b;
}
示例10: evaluateDataDefinedProperty
void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
bool ok;
if ( hasDataDefinedProperty( "outline_width" ) )
{
double width = evaluateDataDefinedProperty( "outline_width", context.feature(), mOutlineWidth ).toDouble();
width *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit, mOutlineWidthMapUnitScale );
mPen.setWidthF( width );
}
if ( hasDataDefinedProperty( "outline_style" ) )
{
QString styleString = evaluateDataDefinedProperty( "outline_style", context.feature(), QVariant(), &ok ).toString();
if ( ok )
{
Qt::PenStyle style = QgsSymbolLayerV2Utils::decodePenStyle( styleString );
mPen.setStyle( style );
}
}
if ( hasDataDefinedProperty( "fill_color" ) )
{
QString colorString = evaluateDataDefinedProperty( "fill_color", context.feature(), QVariant(), &ok ).toString();
if ( ok )
mBrush.setColor( QColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ) );
}
if ( hasDataDefinedProperty( "outline_color" ) )
{
QString colorString = evaluateDataDefinedProperty( "outline_color", context.feature(), QVariant(), &ok ).toString();
if ( ok )
mPen.setColor( QColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ) );
}
double scaledWidth = mSymbolWidth;
double scaledHeight = mSymbolHeight;
if ( hasDataDefinedProperty( "width" ) || hasDataDefinedProperty( "height" ) || hasDataDefinedProperty( "symbol_name" ) )
{
QString symbolName = mSymbolName;
if ( hasDataDefinedProperty( "symbol_name" ) )
{
symbolName = evaluateDataDefinedProperty( "symbol_name", context.feature(), mSymbolName ).toString();
}
preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() );
}
//offset
double offsetX = 0;
double offsetY = 0;
markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale );
QPointF off( offsetX, offsetY );
QPainter* p = context.renderContext().painter();
if ( !p )
{
return;
}
//priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
double rotation = 0.0;
if ( hasDataDefinedProperty( "rotation" ) )
{
rotation = evaluateDataDefinedProperty( "rotation", context.feature(), mAngle ).toDouble();
}
else if ( !qgsDoubleNear( mAngle, 0.0 ) )
{
rotation = mAngle;
}
if ( rotation )
off = _rotatedOffset( off, rotation );
QMatrix transform;
transform.translate( point.x() + off.x(), point.y() + off.y() );
if ( !qgsDoubleNear( rotation, 0.0 ) )
{
transform.rotate( rotation );
}
p->setPen( mPen );
p->setBrush( mBrush );
p->drawPath( transform.map( mPainterPath ) );
}
示例11: subject
QPointF glc::round(const QPointF& point)
{
QPointF subject(glc::round(static_cast<double>(point.x())), glc::round(static_cast<double>(point.y())));
return subject;
}
示例12: compare
bool glc::compare(const QPointF& v1, const QPointF& v2)
{
bool compareResult= (qAbs(v1.x() - v2.x()) <= comparedPrecision);
return compareResult && (qAbs(v1.y() - v2.y()) <= comparedPrecision);
}
示例13: setGrip
void VBox::setGrip(Grip, const QPointF& pt)
{
setBoxHeight(Spatium(pt.y()));
layout();
}
示例14: rotate
void Plugin_Entity::rotate(QPointF center, double angle){
entity->rotate( RS_Vector(center.x(), center.y()) , angle);
}
示例15: FitVector
FitVector(QPointF &p)
{
m_X=p.x();
m_Y=p.y();
}