本文整理汇总了C++中FPointArray::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ FPointArray::copy方法的具体用法?C++ FPointArray::copy怎么用?C++ FPointArray::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPointArray
的用法示例。
在下文中一共展示了FPointArray::copy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressEvent
void KCurve::keyPressEvent(QKeyEvent *e)
{
if(e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace)
{
if (m_points.size() > 2)
{
FPoint closest_point = m_points.point(0);
FPoint p = m_points.point(0);
int pos = 0;
int cc = 0;
double distance = 1000; // just a big number
while(cc < m_points.size())
{
p = m_points.point(cc);
if (fabs (m_grab_point.x() - p.x()) < distance)
{
distance = fabs(m_grab_point.x() - p.x());
closest_point = p;
m_pos = pos;
}
cc++;
pos++;
}
FPointArray cli;
cli.putPoints(0, m_pos, m_points);
cli.putPoints(cli.size(), m_points.size()-m_pos-1, m_points, m_pos+1);
m_points.resize(0);
m_points = cli.copy();
m_grab_point = closest_point;
repaint();
emit modified();
QWidget::keyPressEvent(e);
}
}
}
示例2: setCurve
void KCurve::setCurve(FPointArray inlist)
{
m_points_back = m_points.copy();
m_points.resize(0);
m_points = inlist.copy();
repaint();
emit modified();
}
示例3: mousePressEvent
void KCurve::mousePressEvent ( QMouseEvent * e )
{
FPoint closest_point = FPoint();
double distance;
if (e->button() != Qt::LeftButton)
return;
double x = e->pos().x() / (float)width();
double y = 1.0 - e->pos().y() / (float)height();
distance = 1000; // just a big number
FPoint p = m_points.point(0);
int insert_pos =0;
int pos = 0;
int cc = 0;
while(cc < m_points.size())
{
p = m_points.point(cc);
if (fabs (x - p.x()) < distance)
{
distance = fabs(x - p.x());
closest_point = p;
insert_pos = pos;
}
cc++;
pos++;
}
m_pos = insert_pos;
m_grab_point = closest_point;
m_grabOffsetX = m_grab_point.x() - x;
m_grabOffsetY = m_grab_point.y() - y;
m_grab_point = FPoint(x + m_grabOffsetX, y + m_grabOffsetY);
double curveVal = getCurveValue(x);
if(distance * width() > 5)
{
m_dragging = false;
if(fabs(y - curveVal) * width() > 5)
return;
if (m_points.size() < 14)
{
if (x > closest_point.x())
m_pos++;
FPointArray cli;
cli.putPoints(0, m_pos, m_points);
cli.resize(cli.size()+1);
cli.putPoints(cli.size()-1, 1, x, curveVal);
cli.putPoints(cli.size(), m_points.size()-m_pos, m_points, m_pos);
m_points.resize(0);
m_points = cli.copy();
m_dragging = true;
m_grab_point = m_points.point(m_pos);
m_grabOffsetX = m_grab_point.x() - x;
m_grabOffsetY = m_grab_point.y() - curveVal;
m_grab_point = FPoint(x + m_grabOffsetX, curveVal + m_grabOffsetY);
setCursor(QCursor(Qt::CrossCursor));
}
}
else
{
if(fabs(y - closest_point.y()) * width() > 5)
return;
m_dragging = true;
setCursor(QCursor(Qt::CrossCursor));
}
// Determine the leftmost and rightmost points.
m_leftmost = 0;
m_rightmost = 1;
cc = 0;
while(cc < m_points.size())
{
p = m_points.point(cc);
if (p != m_grab_point)
{
if(p.x() > m_leftmost && p.x() < x)
m_leftmost = p.x();
if(p.x() < m_rightmost && p.x() > x)
m_rightmost = p.x();
}
cc++;
}
repaint();
emit modified();
}
示例4: processArrows
void XfigPlug::processArrows(int forward_arrow, QString fArrowData, int backward_arrow, QString bArrowData, int depth, PageItem *ite)
{
int arrow_typeAF; // (enumeration type)
int arrow_styleAF; // (enumeration type)
float arrow_thicknessAF; // (1/80 inch)
float arrow_widthAF; // (Fig units)
float arrow_heightAF; // (Fig units)
int arrow_typeAB; // (enumeration type)
int arrow_styleAB; // (enumeration type)
float arrow_thicknessAB; // (1/80 inch)
float arrow_widthAB; // (Fig units)
float arrow_heightAB; // (Fig units)
FPointArray arrow;
int z = -1;
PageItem::ItemType iteType;
if (forward_arrow == 1)
{
arrow.resize(0);
ScTextStream CodeAF(&fArrowData, QIODevice::ReadOnly);
CodeAF >> arrow_typeAF >> arrow_styleAF >> arrow_thicknessAF >> arrow_widthAF >> arrow_heightAF;
arrow_widthAF = fig2Pts(arrow_widthAF);
arrow_heightAF = fig2Pts(arrow_heightAF);
arrow_thicknessAF = arrow_thicknessAF / 80.0 * 72.0;
FPoint End = ite->PoLine.point(ite->PoLine.size()-2);
for (uint xx = ite->PoLine.size()-1; xx > 0; xx -= 2)
{
FPoint Vector = ite->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);
QTransform arrowTrans;
if (arrow_typeAF == 0)
arrow.parseSVG("M -1, -0.5 L 0, 0 L -1, 0.5");
else if (arrow_typeAF == 1)
arrow.parseSVG("M -1, -0.5 L 0, 0 L -1, 0.5 z");
else if (arrow_typeAF == 2)
arrow.parseSVG("M -1, -0.5 L 0, 0 L -1, 0.5 L -0.7 0 z");
else if (arrow_typeAF == 3)
arrow.parseSVG("M -0.7, -0.5 L 0, 0 L -0.7, 0.5 L -1 0 z");
arrowTrans.translate(End.x(), End.y());
arrowTrans.rotate(r);
arrowTrans.scale(arrow_heightAF, arrow_widthAF);
arrow.map(arrowTrans);
break;
}
}
QString fillC = "White";
if (arrow_styleAF == 1)
fillC = CurrColorStroke;
if (arrow_typeAF == 0)
{
fillC = CommonStrings::None;
iteType = PageItem::PolyLine;
}
else
iteType = PageItem::Polygon;
z = m_Doc->itemAdd(iteType, PageItem::Unspecified, ite->xPos(), ite->yPos(), 10, 10, arrow_thicknessAF, fillC, CurrColorStroke);
if (z >= 0)
{
PageItem *item = m_Doc->Items->at(z);
item->PoLine = arrow.copy();
item->ClipEdited = true;
item->FrameType = 3;
item->setFillShade(CurrFillShade);
item->setLineShade(CurrStrokeShade);
FPoint wh = getMaxClipF(&item->PoLine);
item->setWidthHeight(wh.x(),wh.y());
item->setTextFlowMode(PageItem::TextFlowDisabled);
m_Doc->adjustItemSize(item);
item->setWidthHeight(qMax(item->width(), 1.0), qMax(item->height(), 1.0));
depthMap.insert(999 - depth, currentItemNr);
currentItemNr++;
}
}
示例5: parseGroup
//.........这里部分代码省略.........
}
else if (command == "stroke-width")
strokewidth = ScCLocale::toDoubleC(params);
else if( command == "stroke-linejoin" )
{
if( params == "miter" )
LineJoin = Qt::MiterJoin;
else if( params == "round" )
LineJoin = Qt::RoundJoin;
else if( params == "bevel" )
LineJoin = Qt::BevelJoin;
}
else if( command == "stroke-linecap" )
{
if( params == "butt" )
LineEnd = Qt::FlatCap;
else if( params == "round" )
LineEnd = Qt::RoundCap;
else if( params == "square" )
LineEnd = Qt::SquareCap;
}
}
if (STag == "svg:line")
{
x1 = ScCLocale::toDoubleC(pg.attribute("x1")) * Conversion;
y1 = ScCLocale::toDoubleC(pg.attribute("y1")) * Conversion;
x2 = ScCLocale::toDoubleC(pg.attribute("x2")) * Conversion;
y2 = ScCLocale::toDoubleC(pg.attribute("y2")) * Conversion;
PoLine.addPoint(x1, y1);
PoLine.addPoint(x1, y1);
PoLine.addPoint(x2, y2);
PoLine.addPoint(x2, y2);
int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, CommonStrings::None, StrokeCol);
m_Doc->Items->at(z)->PoLine = PoLine.copy();
finishItem(m_Doc->Items->at(z));
}
else if (STag == "svg:rect")
{
x1 = ScCLocale::toDoubleC(pg.attribute("x")) * Conversion;
y1 = ScCLocale::toDoubleC(pg.attribute("y")) * Conversion;
x2 = ScCLocale::toDoubleC(pg.attribute("width")) * Conversion;
y2 = ScCLocale::toDoubleC(pg.attribute("height")) * Conversion;
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, baseX + x1, baseY + y1, x2, y2, strokewidth, FillCol, StrokeCol);
m_Doc->Items->at(z)->setLineJoin(LineJoin);
m_Doc->Items->at(z)->setLineEnd(LineEnd);
finishItem(m_Doc->Items->at(z));
}
else if ((STag == "svg:polygon") || (STag == "svg:polyline"))
{
bool bFirst = true;
double x = 0.0;
double y = 0.0;
QString points = pg.attribute( "points" ).simplified().replace(',', " ");
QStringList pointList = points.split(' ', QString::SkipEmptyParts);
FirstM = true;
for( QStringList::Iterator it = pointList.begin(); it != pointList.end(); it++ )
{
x = ScCLocale::toDoubleC(*(it++));
y = ScCLocale::toDoubleC(*it);
if( bFirst )
{
svgMoveTo(x * Conversion, y * Conversion);
bFirst = false;
WasM = true;
}
else