本文整理汇总了C++中QPainterPath::addPath方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::addPath方法的具体用法?C++ QPainterPath::addPath怎么用?C++ QPainterPath::addPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPath
的用法示例。
在下文中一共展示了QPainterPath::addPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: brushOutline
QPainterPath KisLiquifyPaintop::brushOutline(const KisLiquifyProperties &props,
const KisPaintInformation &info)
{
const qreal diameter = props.size();
const qreal reverseCoeff = props.reverseDirection() ? -1.0 : 1.0;
QPainterPath outline;
outline.addEllipse(-0.5 * diameter, -0.5 * diameter,
diameter, diameter);
switch (props.mode()) {
case KisLiquifyProperties::MOVE:
case KisLiquifyProperties::SCALE:
break;
case KisLiquifyProperties::ROTATE: {
QPainterPath p;
p.lineTo(-3.0, 4.0);
p.moveTo(0.0, 0.0);
p.lineTo(-3.0, -4.0);
QTransform S;
if (diameter < 15.0) {
const qreal scale = diameter / 15.0;
S = QTransform::fromScale(scale, scale);
}
QTransform R;
R.rotateRadians(-reverseCoeff * 0.5 * M_PI);
QTransform T = QTransform::fromTranslate(0.5 * diameter, 0.0);
p = (S * R * T).map(p);
outline.addPath(p);
break;
}
case KisLiquifyProperties::OFFSET: {
qreal normalAngle = info.drawingAngle() + reverseCoeff * 0.5 * M_PI;
QPainterPath p = KisAlgebra2D::smallArrow();
const qreal offset = qMax(0.8 * diameter, 15.0);
QTransform R;
R.rotateRadians(normalAngle);
QTransform T = QTransform::fromTranslate(offset, 0.0);
p = (T * R).map(p);
outline.addPath(p);
break;
}
case KisLiquifyProperties::UNDO:
break;
case KisLiquifyProperties::N_MODES:
qFatal("Not supported mode");
}
return outline;
}
示例2: shape
QPainterPath DimRadial::shape() const
{
// Returns the shape of the radial dimension
QPainterPath s;
QPainterPathStroker stroker;
QTransform t;
t.scale(1, -1);
t.translate(0, -2 * arrow->line.p2().y());
s.addPath(arrow->getArrowPath());
s.moveTo(extLine.p1());
s.lineTo(extLine.p2());
s.addPath(t.map(text));
stroker.setWidth(10);
return stroker.createStroke(s);
}
示例3: brushOutline
QPainterPath KisGridPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
{
QPainterPath path;
if (mode == CursorIsOutline || mode == CursorIsCircleOutline || mode == CursorTiltOutline) {
qreal sizex = getInt(GRID_WIDTH) * getDouble(GRID_SCALE);
qreal sizey = getInt(GRID_HEIGHT) * getDouble(GRID_SCALE);
QRectF rc(0, 0, sizex, sizey);
rc.translate(-rc.center());
path.addRect(rc);
QPainterPath tiltLine;
QLineF tiltAngle(QPointF(0.0,0.0), QPointF(0.0,sizex));
tiltAngle.setLength(qMax(sizex*0.5, 50.0) * (1 - info.tiltElevation(info, 60.0, 60.0, true)));
tiltAngle.setAngle((360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0))-3.0);
tiltLine.moveTo(tiltAngle.p1());
tiltLine.lineTo(tiltAngle.p2());
tiltAngle.setAngle((360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0))+3.0);
tiltLine.lineTo(tiltAngle.p2());
tiltLine.lineTo(tiltAngle.p1());
path = outlineFetcher()->fetchOutline(info, this, path);
if (mode == CursorTiltOutline) {
path.addPath(outlineFetcher()->fetchOutline(info, this, tiltLine, 1.0, 0.0, true, 0, 0));
}
}
return path;
}
示例4: marginPath
QPainterPath FrameCd::marginPath( const Distance& size ) const
{
Distance wReal = (mW == 0) ? 2*mR1 : mW;
Distance hReal = (mH == 0) ? 2*mR1 : mH;
Distance r1 = mR1 - size;
Distance r2 = mR2 + size;
QPainterPath path;
/*
* Construct outer subpath (may be clipped if it's a business card CD)
*/
QPainterPath outerPath;
outerPath.addEllipse( (wReal/2 - r1).pt(), (hReal/2 - r1).pt(), 2*r1.pt(), 2*r1.pt() );
QPainterPath clipPath;
clipPath.addRect( size.pt(), size.pt(), (wReal-2*size).pt(), (hReal-2*size).pt() );
path.addPath( outerPath & clipPath );
path.closeSubpath();
/*
* Add inner subpath
*/
path.addEllipse( (wReal/2 - r2).pt(), (hReal/2 - r2).pt(), 2*r2.pt(), 2*r2.pt() );
return path;
}
示例5: brushOutline
QPainterPath KisDuplicateOpSettings::brushOutline(const QPointF& pos, KisPaintOpSettings::OutlineMode mode, qreal scale, qreal rotation) const
{
QPainterPath path;
path = KisBrushBasedPaintOpSettings::brushOutline(QPointF(0.0,0.0),KisPaintOpSettings::CursorIsOutline, scale, rotation);
QPainterPath copy(path);
QRectF rect2 = copy.boundingRect();
if (m_isOffsetNotUptodate) {
copy.translate(m_position - pos);
} else {
copy.translate(-m_offset);
}
path.addPath(copy);
QTransform m;
m.scale(0.5,0.5);
rect2 = m.mapRect(rect2);
path.moveTo(rect2.topLeft());
path.lineTo(rect2.bottomRight());
path.moveTo(rect2.topRight());
path.lineTo(rect2.bottomLeft());
if (mode == CursorIsOutline){
return path.translated(pos);
} else {
// workaround?
//copy.addEllipse(QRectF(0,0,1,1));
return copy.translated(pos);
}
}
示例6: shape
QPainterPath UBGraphicsProtractor::shape() const
{
QPainterPath path = QGraphicsEllipseItem::shape();
QPainterPath buttonPath;
QRectF markerRect = markerButtonRect();
QPointF center = rect().center();
qreal centerX = center.x();
qreal centerY = center.y();
buttonPath.addRect(resizeButtonRect().adjusted(centerX, centerY, centerX, centerY));
if (!resizeButtonRect().contains(markerRect))
{
buttonPath.addRect(markerRect.adjusted(centerX - markerRect.left() * 2 - markerRect.width(), centerY
, centerX - markerRect.left() * 2 - markerRect.width(), centerY));
buttonPath.addRect(markerRect.adjusted(centerX, centerY, centerX, centerY));
}
buttonPath.addRect(closeButtonRect().adjusted(centerX, centerY, centerX, centerY));
buttonPath.addRect(resetButtonRect().adjusted(centerX, centerY, centerX, centerY));
QTransform t;
t.translate(centerX, centerY);
t.rotate(-mStartAngle);
t.translate(-centerX, -centerY);
buttonPath = t.map(buttonPath);
buttonPath = buttonPath.subtracted(path);
path.addPath(buttonPath);
return path;
}
示例7: addPath
int PainterPath::addPath(lua_State * L) // ( const QPainterPath & path )
{
QPainterPath* lhs = ValueInstaller2<QPainterPath>::check( L, 1 );
QPainterPath* path = ValueInstaller2<QPainterPath>::check( L, 2 );
lhs->addPath( *path );
return 0;
}
示例8: shapeFromPath
QPainterPath GraphicsUtils::shapeFromPath(const QPainterPath &path, const QPen &pen, double shapeStrokeWidth, bool includeOriginalPath)
{
// this function mostly copied from QGraphicsItem::qt_graphicsItem_shapeFromPath
// We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
static const double penWidthZero = double(0.00000001);
if (path == QPainterPath())
return path;
QPainterPathStroker ps;
ps.setCapStyle(pen.capStyle());
//ps.setCapStyle(Qt::FlatCap);
if (shapeStrokeWidth <= 0.0)
ps.setWidth(penWidthZero);
else
ps.setWidth(shapeStrokeWidth);
ps.setJoinStyle(pen.joinStyle());
ps.setMiterLimit(pen.miterLimit());
QPainterPath p = ps.createStroke(path);
if (includeOriginalPath) {
p.addPath(path);
}
return p;
}
示例9: painterPath
QPainterPath TextSymbol::painterPath(void)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
QString filename = ctx.loader->absPath("fonts/" + m_font);
FontDataStore* ds = CachedFontParser::parse(filename);
QMatrix mat(m_xsize / ds->xsize(), 0, 0, m_ysize / ds->ysize(), 0, 0);
for (int i = 0; i < m_text.length(); ++i) {
CharRecord* rec = ds->charRecord(m_text[i].toAscii());
if (rec) {
QPainterPath p = mat.map(rec->painterPath(m_width_factor));
path.addPath(p);
}
mat.translate(ds->xsize() + ds->offset(), 0);
}
QRectF b = path.boundingRect();
QMatrix mat2;
mat2.translate(-b.x(), -(b.y() + b.height()));
path = mat2.map(path);
return path;
}
示例10: shape
//!
//! Returns the shape of the item as QPainterPath.
//!
//! \param The shape of the item as QPainterPath.
//!
QPainterPath ConnectionGraphicsItem::shape () const
{
QPainterPath result;
result.addPath(m_mainPath);
result.addPolygon(m_arrowHeadPolygon);
return result;
}
示例11: drawFace
QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx)
{
std::vector<TechDrawGeometry::Wire *> fWires = f->wires;
QPainterPath facePath;
for(std::vector<TechDrawGeometry::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
QPainterPath wirePath;
for(std::vector<TechDrawGeometry::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
//Save the start Position
QPainterPath edgePath = drawPainterPath(*edge);
// If the current end point matches the shape end point the new edge path needs reversing
QPointF shapePos = (wirePath.currentPosition()- edgePath.currentPosition());
if(sqrt(shapePos.x() * shapePos.x() + shapePos.y()*shapePos.y()) < 0.05) { //magic tolerance
edgePath = edgePath.toReversed();
}
wirePath.connectPath(edgePath);
}
//dumpPath("wirePath:",wirePath);
facePath.addPath(wirePath);
}
facePath.setFillRule(Qt::OddEvenFill);
QGIFace* gFace = new QGIFace(idx);
addToGroup(gFace);
gFace->setPos(0.0,0.0);
gFace->setPath(facePath);
//debug a path
//std::stringstream faceId;
//faceId << "facePath " << idx;
//dumpPath(faceId.str().c_str(),facePath);
return gFace;
}
示例12: run
bool SmoothPathPlugin::run(ScribusDoc* doc, QString)
{
ScribusDoc* currDoc = doc;
if (currDoc == 0)
currDoc = ScCore->primaryMainWindow()->doc;
if (currDoc->m_Selection->count() > 0)
{
PageItem *currItem = currDoc->m_Selection->itemAt(0);
QPainterPath pp;
if (currItem->itemType() == PageItem::PolyLine)
pp = currItem->PoLine.toQPainterPath(false);
else
pp = currItem->PoLine.toQPainterPath(true);
QList<QPolygonF> polyList = pp.toSubpathPolygons();
QPainterPath result;
for (int a = 0; a < polyList.count(); a++)
{
result.addPath(bezierFit(polyList[a], 5.0));
}
currItem->PoLine.fromQPainterPath(result);
currItem->ClipEdited = true;
currItem->FrameType = 3;
currDoc->AdjustItemSize(currItem);
currItem->OldB2 = currItem->width();
currItem->OldH2 = currItem->height();
currItem->updateClip();
currDoc->regionsChanged()->update(QRectF());
currDoc->changed();
}
return true;
}
示例13: drawLineTo
void PaintCanvas::drawLineTo(const QPoint &endPoint)
{
// std::cout<<"DRAWLINETO MyPenWidth= "<<myPenWidth<<std::endl;
QPainter painter(&image);
painter.setPen(QPen(myPenColor, myPenWidth, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.drawLine(lastPoint, endPoint);
modified = true;
int rad = (myPenWidth / 2) + 2;
update(QRect(lastPoint, endPoint).normalized()
.adjusted(-rad, -rad, +rad, +rad));
//Path Test
if(clickedToEndPath){
QPainterPath invertPath;
painter.setBrush(myBrushColor);
invertPath.addRect(0,0,image.width(),image.height());
invertPath.addPath(maskpath);
painter.drawPath(invertPath);
}
//
update();
lastPoint = endPoint;
}
示例14: lensDeform
QPainterPath PathDeformRenderer::lensDeform(const QPainterPath &source, const QPointF &offset)
{
QPainterPath path;
path.addPath(source);
qreal flip = m_intensity / qreal(100);
for (int i=0; i<path.elementCount(); ++i) {
const QPainterPath::Element &e = path.elementAt(i);
qreal x = e.x + offset.x();
qreal y = e.y + offset.y();
qreal dx = x - m_pos.x();
qreal dy = y - m_pos.y();
qreal len = m_radius - qSqrt(dx * dx + dy * dy);
if (len > 0) {
path.setElementPositionAt(i,
x + flip * dx * len / m_radius,
y + flip * dy * len / m_radius);
} else {
path.setElementPositionAt(i, x, y);
}
}
return path;
}
示例15: brushOutlineImpl
QPainterPath KisBrushBasedPaintOpSettings::brushOutlineImpl(const KisPaintInformation &info,
OutlineMode mode,
qreal additionalScale,
bool forceOutline)
{
QPainterPath path;
if (forceOutline || mode == CursorIsOutline || mode == CursorIsCircleOutline || mode == CursorTiltOutline) {
KisBrushSP brush = this->brush();
if (!brush) return path;
qreal finalScale = brush->scale() * additionalScale;
QPainterPath realOutline = brush->outline();
if (mode == CursorIsCircleOutline || mode == CursorTiltOutline ||
(forceOutline && mode == CursorNoOutline)) {
QPainterPath ellipse;
ellipse.addEllipse(realOutline.boundingRect());
realOutline = ellipse;
}
path = outlineFetcher()->fetchOutline(info, this, realOutline, finalScale, brush->angle());
if (mode == CursorTiltOutline) {
QPainterPath tiltLine = makeTiltIndicator(info,
realOutline.boundingRect().center(),
realOutline.boundingRect().width() * 0.5,
3.0);
path.addPath(outlineFetcher()->fetchOutline(info, this, tiltLine, finalScale, 0.0, true, realOutline.boundingRect().center().x(), realOutline.boundingRect().center().y()));
}
}
return path;
}