当前位置: 首页>>代码示例>>C++>>正文


C++ FPointArray::putPoints方法代码示例

本文整理汇总了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);
		}
	}
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:35,代码来源:curvewidget.cpp

示例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();
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:81,代码来源:curvewidget.cpp


注:本文中的FPointArray::putPoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。