本文整理汇总了C++中FPointArray::putPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ FPointArray::putPoints方法的具体用法?C++ FPointArray::putPoints怎么用?C++ FPointArray::putPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPointArray
的用法示例。
在下文中一共展示了FPointArray::putPoints方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}