示例#1
0
void ImageMarker::updateBoundingRect() {
  if (!plot()) return;

  setXValue(plot()->invTransform(xAxis(), d_pos.x()));
  d_x_right = plot()->invTransform(xAxis(), d_pos.x() + d_size.width());

  setYValue(plot()->invTransform(yAxis(), d_pos.y()));
  d_y_bottom = plot()->invTransform(yAxis(), d_pos.y() + d_size.height());
}
void LegendMarker::setOrigin( const QPoint & p )
{
	d_pos = p;

	const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
	const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

	setXValue (xMap.invTransform(p.x()));
	setYValue (yMap.invTransform(p.y()));
}
示例#3
0
void ImageMarker::setOrigin(const QPoint &p) {
  d_pos = p;

  if (!plot()) return;

  setXValue(plot()->invTransform(xAxis(), p.x()));
  setYValue(plot()->invTransform(yAxis(), p.y()));

  d_size = size();
  updateBoundingRect();
}
void LegendMarker::updateOrigin()
{
if (!d_plot)
	return;

const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

setXValue (xMap.invTransform(d_pos.x()));
setYValue (yMap.invTransform(d_pos.y()));
}
void LegendMarker::setOriginCoord(double x, double y)
{
	if (xValue() == x && yValue() == y)
		return;

	setXValue(x);
	setYValue(y);

	const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
	const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

	d_pos = QPoint(xMap.transform(x), yMap.transform(y));
}
示例#6
0
void ImageMarker::setBoundingRect(double left, double top, double right, double bottom)
{
    if (xValue() == left && yValue() == top && d_x_right == right && d_y_bottom == bottom)
        return;

    setXValue(left);
    setYValue(top);
    d_x_right = right;
    d_y_bottom = bottom;

    if (!plot())
        return;

    plot()->updateLayout();

    QRect r = this->rect();
    d_pos = r.topLeft();
    d_size = r.size();
}
void LegendMarker::updateOrigin()
{
	if (!d_plot)
		return;

	const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
	const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

	const QwtScaleDiv *xScDiv = d_plot->axisScaleDiv (xAxis());
	double xVal = xMap.invTransform(d_pos.x());
  	if (!xScDiv->contains(xVal))
  	        return;

  	const QwtScaleDiv *yScDiv = d_plot->axisScaleDiv (yAxis());
  	double yVal = yMap.invTransform(d_pos.y());
  	if (!yScDiv->contains(yVal))
  	        return;

  	setXValue (xVal);
  	setYValue (yVal);
}
bool ArrowMarker::eventFilter(QObject *, QEvent *e)
{
	switch(e->type()) {
		case QEvent::MouseButtonPress:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				if (me->button() != Qt::LeftButton)
					return false;
				QRect handler = QRect (QPoint(0,0), QSize(10, 10));
				handler.moveCenter (startPoint());
				if (handler.contains(me->pos()))
				{
					QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor), true);
					d_op = MoveStart;
					return true;
				}
				handler.moveCenter (endPoint());
				if (handler.contains(me->pos()))
				{
					QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor), true);
					d_op = MoveEnd;
					return true;
				}
				int d = qRound(width() + (int)floor(headLength()*tan(M_PI*headAngle()/180.0) + 0.5));
				if (dist(me->pos().x(),me->pos().y()) <= d)
				{
					QApplication::setOverrideCursor(QCursor(Qt::SizeAllCursor), true);
					d_op = MoveBoth;
					d_op_startat = me->pos()-startPoint();
					return true;
				}
				return false;
			}
		case QEvent::MouseMove:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				switch(d_op) {
					case MoveStart:
						setStartPoint(me->pos());
						plot()->replot();
						return true;
					case MoveEnd:
						setEndPoint(me->pos());
						plot()->replot();
						return true;
					case MoveBoth:
						setEndPoint(endPoint()+me->pos()-d_op_startat-startPoint());
						setStartPoint(me->pos()-d_op_startat);
						plot()->replot();
						return true;
					default:
						return false;
				}
			}
		case QEvent::MouseButtonRelease:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				switch(d_op) {
					case MoveStart:
						setStartPoint(me->pos());
						plot()->replot();
						d_op = None;
						QApplication::restoreOverrideCursor();
						return true;
					case MoveEnd:
						setEndPoint(me->pos());
						plot()->replot();
						d_op = None;
						QApplication::restoreOverrideCursor();
						return true;
					case MoveBoth:
						setXValue(plot()->invTransform(xAxis(), me->pos().x()-d_op_startat.x()));
						setYValue(plot()->invTransform(yAxis(), me->pos().y()-d_op_startat.y()));
						plot()->replot();
						d_op = None;
						QApplication::restoreOverrideCursor();
						return true;
					default:
						d_op = None;
						QApplication::restoreOverrideCursor();
						return false;
				}
			}
		case QEvent::MouseButtonDblClick:
			{
				const QMouseEvent *me = (const QMouseEvent *)e;
				if (me->button() != Qt::LeftButton)
					return false;
				LineDialog *ld = new LineDialog(this, plot()->window());
				ld->exec();
				return true;
			}
		default:
			return false;
	}
}