本文整理汇总了C++中FPointArray::point方法的典型用法代码示例。如果您正苦于以下问题:C++ FPointArray::point方法的具体用法?C++ FPointArray::point怎么用?C++ FPointArray::point使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPointArray
的用法示例。
在下文中一共展示了FPointArray::point方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToggleAbsMode
void NodePalette::ToggleAbsMode()
{
if (doc==0)
return;
FPoint zp(0.0, 0.0);
disconnect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
disconnect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
FPointArray Clip;
FPoint np(0.0, 0.0);
if (EditCont->isChecked())
Clip = doc->m_Selection->itemAt(0)->ContourLine;
else
Clip = doc->m_Selection->itemAt(0)->PoLine;
if (doc->nodeEdit.SelNode.count() != 0)
np = Clip.point(doc->nodeEdit.SelNode.at(0));
if (AbsMode->isChecked())
{
XSpin->setMinimum(-16777215);
YSpin->setMinimum(-16777215);
if (absToCanvas->isChecked())
zp = FPoint(doc->m_Selection->itemAt(0)->xPos(), doc->m_Selection->itemAt(0)->yPos());
else
zp = FPoint(doc->m_Selection->itemAt(0)->xPos() - doc->currentPage()->xOffset(), doc->m_Selection->itemAt(0)->yPos() - doc->currentPage()->yOffset());
}
else
{
XSpin->setMinimum(0);
YSpin->setMinimum(0);
}
XSpin->setValue((np.x() + zp.x())*doc->unitRatio());
YSpin->setValue((np.y() + zp.y())*doc->unitRatio());
connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(MovePoint()));
}
示例2: doInvert
void CurveWidget::doInvert()
{
FPointArray curve = cDisplay->getCurve();
for (int a = 0; a < curve.size(); a++)
{
FPoint p = curve.point(a);
curve.setPoint(a, p.x(), 1.0 - p.y());
}
cDisplay->setCurve(curve);
}
示例3: DrawObj_Item
void PageItem_PolyLine::DrawObj_Item(ScPainter *p, QRectF /*e*/, double /*sc*/)
{
if (!m_Doc->RePos && PoLine.size()>=4)
{
if (!m_Doc->layerOutline(LayerNr))
{
if ((fillColor() != CommonStrings::None) || (GrType != 0))
{
FPointArray cli;
FPoint Start;
bool firstp = true;
for (uint n = 0; n < PoLine.size()-3; n += 4)
{
if (firstp)
{
Start = PoLine.point(n);
firstp = false;
}
if (PoLine.point(n).x() > 900000)
{
cli.addPoint(PoLine.point(n-2));
cli.addPoint(PoLine.point(n-2));
cli.addPoint(Start);
cli.addPoint(Start);
cli.setMarker();
firstp = true;
continue;
}
cli.addPoint(PoLine.point(n));
cli.addPoint(PoLine.point(n+1));
cli.addPoint(PoLine.point(n+2));
cli.addPoint(PoLine.point(n+3));
}
if (cli.size() > 2)
{
FPoint l1 = cli.point(cli.size()-2);
cli.addPoint(l1);
cli.addPoint(l1);
cli.addPoint(Start);
cli.addPoint(Start);
}
p->setupPolygon(&cli);
p->fillPath();
}
p->setupPolygon(&PoLine, false);
if (NamedLStyle.isEmpty())
{
if (lineColor() != CommonStrings::None)
p->strokePath();
}
else
{
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
QColor tmp;
for (int it = ml.size()-1; it > -1; it--)
{
if (ml[it].Color != CommonStrings::None) // && (ml[it].Width != 0))
{
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
p->setPen(tmp, ml[it].Width, static_cast<Qt::PenStyle>(ml[it].Dash), static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
p->strokePath();
}
}
}
}
if (m_startArrowIndex != 0)
{
FPoint Start = PoLine.point(0);
for (uint xx = 1; xx < PoLine.size(); xx += 2)
{
FPoint Vector = 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;
arrowTrans.translate(Start.x(), Start.y());
arrowTrans.rotate(r);
drawArrow(p, arrowTrans, m_startArrowIndex);
break;
}
}
}
if (m_endArrowIndex != 0)
{
FPoint End = PoLine.point(PoLine.size()-2);
for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
{
FPoint Vector = 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;
arrowTrans.translate(End.x(), End.y());
arrowTrans.rotate(r);
drawArrow(p, arrowTrans, m_endArrowIndex);
break;
}
}
}
}
//.........这里部分代码省略.........
示例4: getCurveYValue
double getCurveYValue(FPointArray &curve, double x, bool linear)
{
double t;
FPoint p;
FPoint p0,p1,p2,p3;
double c0,c1,c2,c3;
double val = 0.5;
if(curve.size() == 0)
return 0.5;
// First find curve segment
p = curve.point(0);
if(x < p.x())
return p.y();
p = curve.point(curve.size()-1);
if(x >= p.x())
return p.y();
uint cc = 0;
// Find the four control points (two on each side of x)
p = curve.point(0);
while(x >= p.x())
{
cc++;
p = curve.point(cc);
}
if (cc > 1)
{
p0 = curve.point(cc-2);
p1 = curve.point(cc-1);
}
else
p1 = p0 = curve.point(0);
p2 = p;
if (cc < curve.size()-1)
p3 = curve.point(cc+1);
else
p3 = p;
// Calculate the value
if (linear)
{
double mc;
if (p1.x() - p2.x() != 0.0)
mc = (p1.y() - p2.y()) / (p1.x() - p2.x());
else
mc = p2.y() / p2.x();
val = (x - p1.x()) * mc + p1.y();
}
else
{
t = (x - p1.x()) / (p2.x() - p1.x());
c2 = (p2.y() - p0.y()) * (p2.x()-p1.x()) / (p2.x()-p0.x());
c3 = p1.y();
c0 = -2*p2.y() + 2*c3 + c2 + (p3.y() - p1.y()) * (p2.x() - p1.x()) / (p3.x() - p1.x());
c1 = p2.y() - c3 - c2 - c0;
val = ((c0*t + c1)*t + c2)*t + c3;
}
if(val < 0.0)
val = 0.0;
if(val > 1.0)
val = 1.0;
return val;
}
示例5: DrawObj_Item
void PageItem_PolyLine::DrawObj_Item(ScPainter *p, QRectF /*e*/)
{
if (!m_Doc->RePos && PoLine.size()>=4)
{
if (!m_Doc->layerOutline(LayerID))
{
if ((fillColor() != CommonStrings::None) || (GrType != 0))
{
FPointArray cli;
FPoint Start;
bool firstp = true;
for (uint n = 0; n < PoLine.size()-3; n += 4)
{
if (firstp)
{
Start = PoLine.point(n);
firstp = false;
}
if (PoLine.point(n).x() > 900000)
{
cli.addPoint(PoLine.point(n-2));
cli.addPoint(PoLine.point(n-2));
cli.addPoint(Start);
cli.addPoint(Start);
cli.setMarker();
firstp = true;
continue;
}
cli.addPoint(PoLine.point(n));
cli.addPoint(PoLine.point(n+1));
cli.addPoint(PoLine.point(n+2));
cli.addPoint(PoLine.point(n+3));
}
if (cli.size() > 2)
{
FPoint l1 = cli.point(cli.size()-2);
cli.addPoint(l1);
cli.addPoint(l1);
cli.addPoint(Start);
cli.addPoint(Start);
}
p->setupPolygon(&cli);
p->fillPath();
}
p->setupPolygon(&PoLine, false);
if (NamedLStyle.isEmpty())
{
if ((!patternStrokeVal.isEmpty()) && (m_Doc->docPatterns.contains(patternStrokeVal)))
{
if (patternStrokePath)
{
QPainterPath guidePath = PoLine.toQPainterPath(false);
DrawStrokePattern(p, guidePath);
}
else
{
p->setPattern(&m_Doc->docPatterns[patternStrokeVal], patternStrokeScaleX, patternStrokeScaleY, patternStrokeOffsetX, patternStrokeOffsetY, patternStrokeRotation, patternStrokeSkewX, patternStrokeSkewY, patternStrokeMirrorX, patternStrokeMirrorY);
p->setStrokeMode(ScPainter::Pattern);
p->strokePath();
}
}
else if (GrTypeStroke > 0)
{
if ((!gradientStrokeVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientStrokeVal)))
gradientStrokeVal = "";
if (!(gradientStrokeVal.isEmpty()) && (m_Doc->docGradients.contains(gradientStrokeVal)))
stroke_gradient = m_Doc->docGradients[gradientStrokeVal];
if (stroke_gradient.Stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient.
{
if (lineColor() != CommonStrings::None)
{
p->setBrush(strokeQColor);
p->setStrokeMode(ScPainter::Solid);
}
else
p->setStrokeMode(ScPainter::None);
}
else
{
p->setStrokeMode(ScPainter::Gradient);
p->stroke_gradient = stroke_gradient;
if (GrTypeStroke == 6)
p->setGradient(VGradient::linear, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeStartX, GrStrokeStartY), GrStrokeScale, GrStrokeSkew);
else
p->setGradient(VGradient::radial, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeFocalX, GrStrokeFocalY), GrStrokeScale, GrStrokeSkew);
}
p->strokePath();
}
else if (lineColor() != CommonStrings::None)
{
p->setStrokeMode(ScPainter::Solid);
p->strokePath();
}
}
else
{
p->setStrokeMode(ScPainter::Solid);
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
QColor tmp;
for (int it = ml.size()-1; it > -1; it--)
//.........这里部分代码省略.........
示例6: getVisualBoundingRect
void PageItem_Line::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
{
double minx = std::numeric_limits<double>::max();
double miny = std::numeric_limits<double>::max();
double maxx = -std::numeric_limits<double>::max();
double maxy = -std::numeric_limits<double>::max();
double extraSpace = 0.0;
if (NamedLStyle.isEmpty())
{
if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0))
{
extraSpace = m_lineWidth / 2.0;
if ((extraSpace == 0) && m_Doc->view()) // Hairline case
extraSpace = 0.5 / m_Doc->view()->scale();
}
if ((!patternStrokeVal.isEmpty()) && (m_Doc->docPatterns.contains(patternStrokeVal)) && (patternStrokePath))
{
ScPattern *pat = &m_Doc->docPatterns[patternStrokeVal];
QTransform mat;
mat.rotate(patternStrokeRotation);
mat.scale(patternStrokeScaleX / 100.0, patternStrokeScaleY / 100.0);
QRectF p1R = QRectF(0, 0, pat->width / 2.0, pat->height / 2.0);
QRectF p2R = mat.map(p1R).boundingRect();
extraSpace = p2R.height();
}
}
else
{
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
const SingleLine& sl = ml.last();
if (sl.Color != CommonStrings::None)
{
extraSpace = sl.Width / 2.0;
if ((extraSpace == 0) && m_Doc->view()) // Hairline case
extraSpace = 0.5 / m_Doc->view()->scale();
}
}
if (m_rotation != 0)
{
FPointArray pb;
pb.resize(0);
pb.addPoint(FPoint(0.0, -extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
pb.addPoint(FPoint(visualWidth(), -extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
pb.addPoint(FPoint(visualWidth(), +extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
pb.addPoint(FPoint(0.0, +extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
for (uint pc = 0; pc < 4; ++pc)
{
minx = qMin(minx, pb.point(pc).x());
miny = qMin(miny, pb.point(pc).y());
maxx = qMax(maxx, pb.point(pc).x());
maxy = qMax(maxy, pb.point(pc).y());
}
*x1 = minx;
*y1 = miny;
*x2 = maxx;
*y2 = maxy;
}
else
{
*x1 = m_xPos;
*y1 = m_yPos - extraSpace;
*x2 = m_xPos + visualWidth();
*y2 = m_yPos + extraSpace;
}
QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
if (m_startArrowIndex != 0)
{
QTransform arrowTrans;
FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
arrowTrans.translate(m_xPos, m_yPos);
arrowTrans.rotate(m_rotation);
arrowTrans.translate(0, 0);
arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
if (NamedLStyle.isEmpty())
{
if (m_lineWidth != 0.0)
arrowTrans.scale(m_lineWidth, m_lineWidth);
}
else
{
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
if (ml[ml.size()-1].Width != 0.0)
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
}
arrowTrans.scale(-1,1);
arrow.map(arrowTrans);
FPoint minAr = getMinClipF(&arrow);
FPoint maxAr = getMaxClipF(&arrow);
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
}
if (m_endArrowIndex != 0)
{
QTransform arrowTrans;
FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
arrowTrans.translate(m_xPos, m_yPos);
arrowTrans.rotate(m_rotation);
arrowTrans.translate(m_width, 0);
arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
if (NamedLStyle.isEmpty())
//.........这里部分代码省略.........
示例7: getBoundingRect
void PageItem_Line::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
{
double minx = std::numeric_limits<double>::max();
double miny = std::numeric_limits<double>::max();
double maxx = -std::numeric_limits<double>::max();
double maxy = -std::numeric_limits<double>::max();
if (m_rotation != 0)
{
FPointArray pb;
pb.resize(0);
pb.addPoint(FPoint(0, -m_lineWidth / 2.0, m_xPos, m_yPos, m_rotation, 1.0, 1.0));
pb.addPoint(FPoint(m_width, -m_lineWidth / 2.0, m_xPos, m_yPos, m_rotation, 1.0, 1.0));
pb.addPoint(FPoint(m_width, +m_lineWidth / 2.0, m_xPos, m_yPos, m_rotation, 1.0, 1.0));
pb.addPoint(FPoint(0, +m_lineWidth / 2.0, m_xPos, m_yPos, m_rotation, 1.0, 1.0));
for (uint pc = 0; pc < 4; ++pc)
{
minx = qMin(minx, pb.point(pc).x());
miny = qMin(miny, pb.point(pc).y());
maxx = qMax(maxx, pb.point(pc).x());
maxy = qMax(maxy, pb.point(pc).y());
}
*x1 = minx;
*y1 = miny;
*x2 = maxx;
*y2 = maxy;
}
else
{
*x1 = m_xPos;
*y1 = m_yPos - qMax(1.0, m_lineWidth) / 2.0;
*x2 = m_xPos + m_width;
*y2 = m_yPos + qMax(1.0, m_lineWidth) / 2.0;
}
QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
if (m_startArrowIndex != 0)
{
QTransform arrowTrans;
FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
arrowTrans.translate(m_xPos, m_yPos);
arrowTrans.rotate(m_rotation);
arrowTrans.translate(0, 0);
arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
if (NamedLStyle.isEmpty())
{
if (m_lineWidth != 0.0)
arrowTrans.scale(m_lineWidth, m_lineWidth);
}
else
{
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
if (ml[ml.size()-1].Width != 0.0)
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
}
arrowTrans.scale(-1,1);
arrow.map(arrowTrans);
FPoint minAr = getMinClipF(&arrow);
FPoint maxAr = getMaxClipF(&arrow);
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
}
if (m_endArrowIndex != 0)
{
QTransform arrowTrans;
FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
arrowTrans.translate(m_xPos, m_yPos);
arrowTrans.rotate(m_rotation);
arrowTrans.translate(m_width, 0);
arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
if (NamedLStyle.isEmpty())
{
if (m_lineWidth != 0.0)
arrowTrans.scale(m_lineWidth, m_lineWidth);
}
else
{
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
if (ml[ml.size()-1].Width != 0.0)
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
}
arrow.map(arrowTrans);
FPoint minAr = getMinClipF(&arrow);
FPoint maxAr = getMaxClipF(&arrow);
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
}
totalRect.getCoords(x1, y1, x2, y2);
}
示例8: 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;
}