本文整理汇总了C++中FPointArray::toQPainterPath方法的典型用法代码示例。如果您正苦于以下问题:C++ FPointArray::toQPainterPath方法的具体用法?C++ FPointArray::toQPainterPath怎么用?C++ FPointArray::toQPainterPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPointArray
的用法示例。
在下文中一共展示了FPointArray::toQPainterPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
bool PathStrokerPlugin::run(ScribusDoc* doc, QString)
{
ScribusDoc* currDoc = doc;
if (currDoc == 0)
currDoc = ScCore->primaryMainWindow()->doc;
if (currDoc->m_Selection->count() > 0)
{
QVector<double> m_array;
PageItem *currItem = currDoc->m_Selection->itemAt(0);
FPointArray path = currItem->PoLine;
QPainterPath pp;
if (currItem->itemType() == PageItem::PolyLine)
pp = path.toQPainterPath(false);
else
pp = path.toQPainterPath(true);
if (currItem->NamedLStyle.isEmpty())
{
QPainterPathStroker stroke;
stroke.setCapStyle(currItem->lineEnd());
stroke.setJoinStyle(currItem->lineJoin());
if (currItem->lineStyle() == Qt::SolidLine)
stroke.setDashPattern(currItem->lineStyle());
else
{
getDashArray(currItem->lineStyle(), 1, m_array);
stroke.setDashPattern(m_array);
}
stroke.setWidth(currItem->lineWidth());
QPainterPath result = stroke.createStroke(pp).simplified();
if (currItem->startArrowIndex() != 0)
{
FPoint Start = currItem->PoLine.point(0);
for (uint xx = 1; xx < currItem->PoLine.size(); xx += 2)
{
FPoint Vector = currItem->PoLine.point(xx);
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
{
double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
QMatrix arrowTrans;
FPointArray arrow = currDoc->arrowStyles.at(currItem->startArrowIndex()-1).points.copy();
arrowTrans.translate(Start.x(), Start.y());
arrowTrans.rotate(r);
arrowTrans.scale(currItem->lineWidth(), currItem->lineWidth());
arrow.map(arrowTrans);
result.addPath(arrow.toQPainterPath(true));
break;
}
}
}
if (currItem->endArrowIndex() != 0)
{
FPoint End = currItem->PoLine.point(currItem->PoLine.size()-2);
for (uint xx = currItem->PoLine.size()-1; xx > 0; xx -= 2)
{
FPoint Vector = currItem->PoLine.point(xx);
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
{
double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
QMatrix arrowTrans;
FPointArray arrow = currDoc->arrowStyles.at(currItem->endArrowIndex()-1).points.copy();
arrowTrans.translate(End.x(), End.y());
arrowTrans.rotate(r);
arrowTrans.scale(currItem->lineWidth(), currItem->lineWidth());
arrow.map(arrowTrans);
result.addPath(arrow.toQPainterPath(true));
break;
}
}
}
currDoc->m_Selection->clear();
PageItem* newItem = currDoc->convertItemTo(currItem, PageItem::Polygon);
newItem->setLineWidth(0);
newItem->setLineStyle(Qt::SolidLine);
newItem->setFillColor(newItem->lineColor());
newItem->setFillShade(newItem->lineShade());
newItem->setFillTransparency(newItem->lineTransparency());
newItem->setFillBlendmode(newItem->lineBlendmode());
FPointArray points;
points.fromQPainterPath(result);
newItem->PoLine = points;
newItem->Frame = false;
newItem->ClipEdited = true;
newItem->FrameType = 3;
currDoc->AdjustItemSize(newItem);
newItem->OldB2 = newItem->width();
newItem->OldH2 = newItem->height();
newItem->updateClip();
newItem->ContourLine = newItem->PoLine.copy();
newItem->setFillEvenOdd(true);
currDoc->m_Selection->addItem(newItem);
}
else
{
currDoc->m_Selection->clear();
multiLine ml = currDoc->MLineStyles[currItem->NamedLStyle];
bool first = true;
for (int it = ml.size()-1; it > -1; it--)
{
if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
{
//.........这里部分代码省略.........
示例2: drawControls
void CreateMode::drawControls(QPainter* p)
{
if (!inItemCreation) return;
QPointF topLeft(createObjectPos.x(), createObjectPos.y());
QPointF btRight(canvasCurrCoord.x(), canvasCurrCoord.y());
QColor drawColor = qApp->palette().color(QPalette::Active, QPalette::Highlight);
if (createObjectMode != modeDrawLine)
{
QRectF bounds = QRectF(topLeft, btRight).normalized();
//Lock Height to Width for Control Modifier for region drawing
if (modifiers==Qt::ControlModifier)
{
bounds.setHeight(bounds.width());
if (btRight.y()<topLeft.y())
bounds.moveBottom(topLeft.y());
if (btRight.x()<topLeft.x() && btRight.y()>topLeft.y())
bounds.moveTop(topLeft.y());
}
QRect localRect = m_canvas->canvasToLocal(bounds);
if (localRect.width() <= 0 || localRect.height() <= 0)
return;
p->setRenderHint(QPainter::Antialiasing);
p->save();
p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
drawColor.setAlpha(64);
p->setBrush(drawColor);
p->drawRect(localRect);
drawColor.setAlpha(255);
p->setBrush(Qt::NoBrush);
p->setPen(QPen(drawColor, 1, Qt::DashLine, Qt::FlatCap, Qt::MiterJoin));
int frameType = 0, itemType = 0;
getFrameItemTypes(itemType, frameType);
if (frameType == PageItem::Ellipse)
{
p->drawEllipse(localRect);
}
else if (createObjectMode == modeDrawArc)
{
QPainterPath path;
path.moveTo(localRect.width() / 2.0, localRect.height() / 2.0);
path.arcTo(0.0, 0.0, localRect.width(), localRect.height(), m_doc->itemToolPrefs().arcStartAngle, m_doc->itemToolPrefs().arcSweepAngle);
path.closeSubpath();
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
else if (createObjectMode == modeDrawRegularPolygon)
{
QPainterPath path = RegularPolygonPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().polyCorners, m_doc->itemToolPrefs().polyUseFactor, m_doc->itemToolPrefs().polyFactor, m_doc->itemToolPrefs().polyRotation, m_doc->itemToolPrefs().polyCurvature, m_doc->itemToolPrefs().polyInnerRot, m_doc->itemToolPrefs().polyOuterCurvature);
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
else if (createObjectMode == modeDrawSpiral)
{
QPainterPath path = SpiralPath(localRect.width(), localRect.height(), m_doc->itemToolPrefs().spiralStartAngle, m_doc->itemToolPrefs().spiralEndAngle, m_doc->itemToolPrefs().spiralFactor);
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
else if ((createObjectMode == modeDrawShapes) && (createObjectSubMode > 1))
{
FPointArray poly;
int valCount = m_doc->ValCount;
double *vals = m_doc->ShapeValues;
for (int a = 0; a < valCount-3; a += 4)
{
if (vals[a] < 0)
{
poly.setMarker();
continue;
}
double x1 = localRect.width() * vals[a] / 100.0;
double y1 = localRect.height() * vals[a+1] / 100.0;
double x2 = localRect.width() * vals[a+2] / 100.0;
double y2 = localRect.height() * vals[a+3] / 100.0;
poly.addPoint(x1, y1);
poly.addPoint(x2, y2);
}
QPainterPath path = poly.toQPainterPath(false);
p->translate(localRect.left(), localRect.top());
p->drawPath(path);
}
p->restore();
}
else
{
QPoint p1 = m_canvas->canvasToLocal(topLeft);
QPoint p2 = m_canvas->canvasToLocal(btRight);
p->save();
p->setPen(QPen(drawColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
p->setBrush(drawColor);
p->drawLine(p1, p2);
p->restore();
}
}
示例3: run
bool PathCutPlugin::run(ScribusDoc* doc, QString)
{
QString vers = QString(qVersion()).left(5);
if (vers < "4.3.3")
{
QMessageBox::information(doc->scMW(), tr("Qt Version too old"), tr("This plugin requires at least version 4.3.3 of the Qt library"));
return true;
}
ScribusDoc* currDoc = doc;
if (currDoc == 0)
currDoc = ScCore->primaryMainWindow()->doc;
if (currDoc->m_Selection->count() > 1)
{
PageItem *Item1 = currDoc->m_Selection->itemAt(0);
PageItem *Item2 = currDoc->m_Selection->itemAt(1);
if (Item1->itemType() != PageItem::PolyLine)
{
Item1 = currDoc->m_Selection->itemAt(1);
Item2 = currDoc->m_Selection->itemAt(0);
}
FPointArray path = Item1->PoLine;
QPainterPathStroker stroke;
stroke.setWidth(Item1->lineWidth());
QPainterPath cutter = stroke.createStroke(path.toQPainterPath(false));
QMatrix ms;
ms.translate(Item1->xPos() - Item2->xPos(), Item1->yPos() - Item2->yPos());
ms.rotate(Item1->rotation());
cutter = ms.map(cutter);
path.map(ms);
FPoint start = path.point(0);
FPoint end = path.point(path.size()-2);
QMatrix mm;
mm.rotate(Item2->rotation());
QPainterPath objekt = mm.map(Item2->PoLine.toQPainterPath(true));
if ((objekt.contains(QPointF(start.x(), start.y()))) || (objekt.contains(QPointF(end.x(), end.y()))))
{
QMessageBox::information(doc->scMW(), tr("Error"), tr("The cutting line must cross the polygon and\nboth end points must lie outside of the polygon"));
return true;
}
QPainterPath result = objekt.subtracted(cutter);
FPointArray points;
points.fromQPainterPath(result);
Item2->PoLine = points;
Item2->Frame = false;
Item2->ClipEdited = true;
Item2->FrameType = 3;
currDoc->AdjustItemSize(Item2);
Item2->OldB2 = Item2->width();
Item2->OldH2 = Item2->height();
Item2->updateClip();
Item2->ContourLine = Item2->PoLine.copy();
currDoc->m_Selection->clear();
currDoc->m_Selection->addItem(Item1);
currDoc->itemSelection_DeleteItem();
currDoc->m_Selection->clear();
currDoc->m_Selection->addItem(Item2);
currDoc->itemSelection_SplitItems();
currDoc->changed();
}
return true;
}