Exemple #1
0
void XYChartCore::paintAxis(QPainter* painter)
{
    const qreal minKey = xAxis()->minimumValue();
    const qreal maxKey = xAxis()->maximumValue();
    const qreal minValue = yAxis()->minimumValue();
    const qreal maxValue = yAxis()->maximumValue();

    const QPointF origo = translatePoint(QPointF(0.0, 0.0));
    const QPointF p1 = translatePoint(QPointF(minKey, 0.0));
    const QPointF p2 = translatePoint(QPointF(maxKey, 0.0));
    const QPointF p3 = translatePoint(QPointF(0.0, minValue));
    const QPointF p4 = translatePoint(QPointF(0.0, maxValue));

    if (origo != p1)
        painter->drawLine(origo, p1);

    if (origo != p2)
        painter->drawLine(origo, p2);

    if (origo != p3)
        painter->drawLine(origo, p3);

    if (origo != p4)
        painter->drawLine(origo, p4);
}
void QwtPlotZoomer::rescale()
{
    QwtPlot *plt = plot();
    if ( !plt )
        return;

    const QRectF &rect = d_data->zoomStack[d_data->zoomRectIndex];
    if ( rect != scaleRect() )
    {
        const bool doReplot = plt->autoReplot();
        plt->setAutoReplot( false );

        double x1 = rect.left();
        double x2 = rect.right();
        if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() )
            qSwap( x1, x2 );

        plt->setAxisScale( xAxis(), x1, x2 );

        double y1 = rect.top();
        double y2 = rect.bottom();
        if ( !plt->axisScaleDiv( yAxis() ).isIncreasing() )
            qSwap( y1, y2 );

        plt->setAxisScale( yAxis(), y1, y2 );

        plt->setAutoReplot( doReplot );

        plt->replot();
    }
}
Exemple #3
0
cv::Point3f getYPR(const cv::Point3f forward, const cv::Point3f up)
{
  cv::Point3f ypr;
  // Yaw, rotation about the y-axis
  ypr.x = angle2f(forward.x, forward.z);
  // Pitch, rotation about the x-axis
  ypr.y = angle2f(forward.z, forward.y);
  // Create reference up-vector (y-axis)
  cv::Matx31f yAxis = cv::Matx31f(0.0f, 1.0f, 0.0f);
  // Rotate reference up-vector about x-axis (pitch)
  cv::Matx33f rotX = cv::Matx33f(1.0f,       0.0f,        0.0f,
                                 0.0f, cos(ypr.y), -sin(ypr.y),
                                 0.0f, sin(ypr.y),  cos(ypr.y));
  yAxis = rotX * yAxis;
  // Rotate reference up-vector about y-axis (yaw)
  cv::Matx33f rotY = cv::Matx33f( cos(ypr.x), 0.0f,  sin(ypr.x),
                                        0.0f, 1.0f,        0.0f,
                                 -sin(ypr.x), 0.0f,  cos(ypr.x));
  yAxis = rotY * yAxis;
  // Get rotated reference up-vector as cv::Point3f
  cv::Point3f upReference;
  upReference.x = yAxis(1);
  upReference.y = yAxis(2);
  upReference.z = yAxis(3);
  // Roll, rotation about the z-axis
  ypr.z = angle3f(upReference, up);
  // Done
  return ypr;
}
Exemple #4
0
void ScrollZoomer::layoutScrollBars(const QRect &rect) {
  int hPos = xAxis();
  if (hScrollBarPosition() == OppositeToScale) hPos = oppositeAxis(hPos);

  int vPos = yAxis();
  if (vScrollBarPosition() == OppositeToScale) vPos = oppositeAxis(vPos);

  ScrollBar *hScrollBar = horizontalScrollBar();
  ScrollBar *vScrollBar = verticalScrollBar();

  const int hdim = hScrollBar ? hScrollBar->extent() : 0;
  const int vdim = vScrollBar ? vScrollBar->extent() : 0;

  if (hScrollBar && hScrollBar->isVisible())
    {
      int x = rect.x();
      int y = (hPos == QwtPlot::xTop) ? rect.top() : rect.bottom() - hdim + 1;
      int w = rect.width();

      if (vScrollBar && vScrollBar->isVisible())
        {
          if (vPos == QwtPlot::yLeft)
            x += vdim;
          w -= vdim;
        }

      hScrollBar->setGeometry(x, y, w, hdim);
    }
  if (vScrollBar && vScrollBar->isVisible())
    {
      int pos = yAxis();
      if (vScrollBarPosition() == OppositeToScale)
        pos = oppositeAxis(pos);

      int x = (vPos == QwtPlot::yLeft) ? rect.left() : rect.right() - vdim + 1;
      int y = rect.y();

      int h = rect.height();

      if (hScrollBar && hScrollBar->isVisible())
        {
          if (hPos == QwtPlot::xTop)
            y += hdim;

          h -= hdim;
        }

      vScrollBar->setGeometry(x, y, vdim, h);
    }
  if (hScrollBar && hScrollBar->isVisible() && vScrollBar
      && vScrollBar->isVisible())
    {
      if (d_cornerWidget)
        {
          QRect cornerRect(vScrollBar->pos().x(), hScrollBar->pos().y(), vdim,
              hdim);
          d_cornerWidget->setGeometry(cornerRect);
        }
    }
}
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());
}
/*!
  Return normalized bounding rect of the axes

  \warning Calling QwtPlot::setAxisScale() while QwtPlot::autoReplot() is FALSE
           leaves the axis in an 'intermediate' state.
           In this case, to prevent buggy behaviour, you must call
           QwtPlot::replot() before calling QwtPlotPicker::scaleRect().
           This quirk will be removed in a future release.

  \sa QwtPlot::autoReplot(), QwtPlot::replot().
*/
QwtDoubleRect QwtPlotPicker::scaleRect() const
{
    const QwtPlot *plt = plot();

    const QwtDoubleRect rect(
        plt->axisScale(xAxis())->lBound(),
        plt->axisScale(xAxis())->hBound(),
        plt->axisScale(yAxis())->lBound(),
        plt->axisScale(yAxis())->hBound()
    );

    return rect.normalize();
}
QPoint LineMarker::endPoint()
{
const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

return QPoint(xMap.transform(d_rect.right()), yMap.transform(d_rect.bottom()));
}
QPoint LineMarker::startPoint()
{
const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

return QPoint(xMap.transform(d_rect.left()), yMap.transform(d_rect.top()));
}
Exemple #9
0
  bool GlareSensor_Impl::aimAt(const Point3d& target)
  {
    Point3d position = this->position();
    Vector3d vector = target - position;

    if (!vector.normalize()){
      return false;
    }

    Vector3d yAxis(0,1,0);
    Vector3d rotationAxis = yAxis.cross(vector);

    if (!rotationAxis.normalize()){
      return false;
    }

    double angle = getAngle(yAxis, vector);
    Transformation transformation = Transformation::rotation(rotationAxis, angle);
    EulerAngles eulerAngles = transformation.eulerAngles();

    this->setPsiRotationAroundXAxis(eulerAngles.psi());
    this->setThetaRotationAroundYAxis(eulerAngles.theta());
    this->setPhiRotationAroundZAxis(eulerAngles.phi());

    return true;
  }
Exemple #10
0
Matrix RendererD3D::GetBillboardMatrix(Vector cameraPos, Vector upVector)
{
	Vector xAxis(0.0f,0.0f,0.0f);
	Vector yAxis(0.0f,0.0f,0.0f);
	Vector zAxis(0.0f,0.0f,0.0f);
	Vector upVect(0.0f,1.0f,0.0f);

	Vector cameraVector = cameraPos;

	zAxis = cameraVector;
	zAxis.normalize();

	xAxis = zAxis.Cross(upVect);
	xAxis.normalize();

	yAxis = xAxis.Cross(zAxis);
	yAxis.normalize();

	Matrix transform = { xAxis.x, xAxis.y, xAxis.z, 0.0f,
					yAxis.x, yAxis.y, yAxis.z, 0.0f,
					zAxis.x, zAxis.y, zAxis.z, 0.0f,
					0.0f, 0.0f, 0.0f, 1.0f };

	return transform;
}
Exemple #11
0
void Grid::enableZeroLineY(bool enable) {
  Plot *d_plot = dynamic_cast<Plot *>(plot());
  if (!d_plot)
    return;

  if (mrkY < 0 && enable) {
    QwtPlotMarker *m = new QwtPlotMarker();
    mrkY = d_plot->insertMarker(m);
    m->setRenderHint(QwtPlotItem::RenderAntialiased, false);
    m->setAxis(xAxis(), yAxis());
    m->setLineStyle(QwtPlotMarker::HLine);
    m->setValue(0.0, 0.0);

    double width = 1;
    if (d_plot->canvas()->lineWidth())
      width = d_plot->canvas()->lineWidth();
    else if (d_plot->axisEnabled(QwtPlot::xBottom) ||
             d_plot->axisEnabled(QwtPlot::xTop))
      width = d_plot->axesLinewidth();

    m->setLinePen(QPen(Qt::black, width, Qt::SolidLine));
  } else if (mrkY >= 0 && !enable) {
    d_plot->removeMarker(mrkY);
    mrkY = -1;
  }
}
void Spectrogram::updateLabels(QPainter *p, const QwtScaleMap &, const QwtScaleMap &,
		const QwtRasterData::ContourLines &contourLines) const
{
	QwtValueList levels = contourLevels();
	const int numLevels = levels.size();
	int x_axis = xAxis();
	int y_axis = yAxis();
	for (int l = 0; l < numLevels; l++){
		const double level = levels[l];
		const QPolygonF &lines = contourLines[level];
		if (lines.isEmpty())
			continue;

		PlotMarker *mrk = d_labels_list[l];
		if (!mrk)
			return;

		QSize size = mrk->label().textSize();
		int dx = int((d_labels_x_offset + mrk->xLabelOffset())*0.01*size.height());
		int dy = -int(((d_labels_y_offset + mrk->yLabelOffset())*0.01 + 0.5)*size.height());

		int i = (int)lines.size()/2;
		double x = lines[i].x();
		double y = lines[i].y();

		int x2 = d_graph->transform(x_axis, x) + dx;
		int y2 = d_graph->transform(y_axis, y) + dy;

		if (p->device()->logicalDpiX() == plot()->logicalDpiX() ||
			p->device()->logicalDpiY() == plot()->logicalDpiY())
			mrk->setValue(d_graph->invTransform(x_axis, x2),
							d_graph->invTransform(y_axis, y2));
	}
}
Spectrogram* Spectrogram::copy(Graph *g)
{
	Spectrogram *new_s = new Spectrogram(g, matrix());
	new_s->setDisplayMode(QwtPlotSpectrogram::ImageMode, testDisplayMode(QwtPlotSpectrogram::ImageMode));
	new_s->setDisplayMode(QwtPlotSpectrogram::ContourMode, testDisplayMode(QwtPlotSpectrogram::ContourMode));
	new_s->setCustomColorMap(color_map);
	new_s->setAxis(xAxis(), yAxis());
	new_s->setDefaultContourPen(defaultContourPen());
	new_s->color_map_policy = color_map_policy;
	new_s->d_show_labels = d_show_labels;
	new_s->d_labels_angle = d_labels_angle;
	new_s->d_labels_color = d_labels_color;
	new_s->d_white_out_labels = d_white_out_labels;
	new_s->d_labels_font = d_labels_font;
	new_s->d_labels_x_offset = d_labels_x_offset;
	new_s->d_labels_y_offset = d_labels_y_offset;

	new_s->setContourLevels(contourLevels());

	if (defaultContourPen().style() == Qt::NoPen && !d_color_map_pen)
		new_s->setContourPenList(d_pen_list);
	else
		new_s->d_color_map_pen = d_color_map_pen;

	QList <PlotMarker *> lst = new_s->labelsList();
	int count = lst.size();
	for(int i = 0; i < count; i++){
		PlotMarker *m = lst[i];
		PlotMarker *mrk = d_labels_list[i];
		if (m && mrk)
			m->setLabelOffset(mrk->xLabelOffset(), mrk->yLabelOffset());
	}
	return new_s;
}
Exemple #14
0
QPoint ArrowMarker::endPoint() const {
  if (!plot())
    return QPoint();

  return QPoint(plot()->transform(xAxis(), d_rect.right()),
                plot()->transform(yAxis(), d_rect.bottom()));
}
Exemple #15
0
QPoint ArrowMarker::startPoint() const {
  if (!plot())
    return QPoint();

  return QPoint(plot()->transform(xAxis(), d_rect.left()),
                plot()->transform(yAxis(), d_rect.top()));
}
Exemple #16
0
QwtDoubleRect PlotCurve::boundingRect() const
{
    QwtDoubleRect r = QwtPlotCurve::boundingRect();

    double percent = 0.01;

    double dw = percent*fabs(r.right() - r.left());
    double left = r.left() - dw;
    if (left <= 0.0) {
        ScaleEngine *sc_engine = (ScaleEngine *)this->plot()->axisScaleEngine(xAxis());
        if (sc_engine && (sc_engine->type() == ScaleTransformation::Log10 ||
                          sc_engine->type() == ScaleTransformation::Log2 ||
                          sc_engine->type() == ScaleTransformation::Ln))
            left = r.left();
    }

    r.setLeft(left);
    r.setRight(r.right() + dw);

    double dh = percent*fabs(r.top() - r.bottom());
    r.setBottom(r.bottom() + dh);

    double top = r.top() - dh;
    if (top <= 0.0) {
        ScaleEngine *sc_engine = (ScaleEngine *)this->plot()->axisScaleEngine(yAxis());
        if (sc_engine && (sc_engine->type() == ScaleTransformation::Log10 ||
                          sc_engine->type() == ScaleTransformation::Log2 ||
                          sc_engine->type() == ScaleTransformation::Ln))
            top = r.top();
    }
    r.setTop(top);

    return r;
}
double QwtBarCurve::dataOffset() {
  if (bar_style == Vertical) {
    const QwtScaleMap &xMap = plot()->canvasMap(xAxis());
    int dx = abs(xMap.transform(x(1)) - xMap.transform(x(0)));
    double bar_width = dx * (1 - bar_gap * 0.01);
    if (plot()->isVisible()) {
      for (int i = 2; i < dataSize(); i++) {
        int min = abs(xMap.transform(x(i)) - xMap.transform(x(i - 1)));
        if (min <= dx) dx = min;
      }
      int x1 = xMap.transform(minXValue()) + int(bar_offset * 0.01 * bar_width);
      return xMap.invTransform(x1) - minXValue();
    } else
      return 0.5 * bar_offset * 0.01 * bar_width;
  } else {
    const QwtScaleMap &yMap = plot()->canvasMap(yAxis());
    int dy = abs(yMap.transform(y(1)) - yMap.transform(y(0)));
    double bar_width = dy * (1 - bar_gap * 0.01);
    if (plot()->isVisible()) {
      for (int i = 2; i < dataSize(); i++) {
        int min = abs(yMap.transform(y(i)) - yMap.transform(y(i - 1)));
        if (min <= dy) dy = min;
      }
      int y1 = yMap.transform(minYValue()) + int(bar_offset * 0.01 * bar_width);
      return yMap.invTransform(y1) - minYValue();
    } else
      return 0.5 * bar_offset * 0.01 * bar_width;
  }
  return 0;
}
Exemple #18
0
void Grid::enableZeroLineX(bool enable)
{
    Plot *d_plot = (Plot *)plot();
    if (!d_plot)
        return;

    if (mrkX<0 && enable) {
        QwtPlotMarker *m = new QwtPlotMarker();
        mrkX = d_plot->insertMarker(m);
        m->setRenderHint(QwtPlotItem::RenderAntialiased, false);
        m->setAxis(xAxis(), yAxis());
        m->setLineStyle(QwtPlotMarker::VLine);
        m->setValue(0.0, 0.0);

        double width = 1;
        if (d_plot->canvas()->lineWidth())
            width = d_plot->canvas()->lineWidth();
        else if (d_plot->axisEnabled (QwtPlot::yLeft) || d_plot->axisEnabled (QwtPlot::yRight))
            width =  d_plot->axesLinewidth();

        m->setLinePen(QPen(Qt::black, width, Qt::SolidLine));
    } else if (mrkX >= 0 && !enable) {
        d_plot->removeMarker(mrkX);
        mrkX=-1;
    }
}
Exemple #19
0
QString Grid::saveToString()
{
    QString s = "grid\t";
    s += QString::number(xEnabled())+"\t";
    s += QString::number(xMinEnabled())+"\t";
    s += QString::number(yEnabled())+"\t";
    s += QString::number(yMinEnabled())+"\t";

    s += majPenX().color().name()+"\t";
    s += QString::number(majPenX().style() - 1)+"\t";
    s += QString::number(majPenX().widthF())+"\t";

    s += minPenX().color().name()+"\t";
    s += QString::number(minPenX().style() - 1)+"\t";
    s += QString::number(minPenX().widthF())+"\t";

    s += majPenY().color().name()+"\t";
    s += QString::number(majPenY().style() - 1)+"\t";
    s += QString::number(majPenY().widthF())+"\t";

    s += minPenY().color().name()+"\t";
    s += QString::number(minPenY().style() - 1)+"\t";
    s += QString::number(minPenY().widthF())+"\t";

    s += QString::number(xZeroLineEnabled())+"\t";
    s += QString::number(yZeroLineEnabled())+"\t";
    s += QString::number(xAxis())+"\t";
    s += QString::number(yAxis())+"\t";
    s += QString::number(testRenderHint(QwtPlotItem::RenderAntialiased))+"\n";
    return s;
}
Exemple #20
0
void Grid::enableZeroLineY(bool enable)
{
	Graph *d_plot = (Graph *)plot();
	if (!d_plot)
		return;

	if (!mrkY && enable) {
		mrkY = new QwtPlotMarker();
		d_plot->insertMarker(mrkY);
		mrkY->setRenderHint(QwtPlotItem::RenderAntialiased, false);
		mrkY->setAxis(xAxis(), yAxis());
		mrkY->setLineStyle(QwtPlotMarker::HLine);
		mrkY->setValue(0.0, 0.0);

		QColor c = Qt::black;
		if (d_plot->axisEnabled (QwtPlot::xBottom))
			c = d_plot->axisWidget(QwtPlot::xBottom)->palette().color(QPalette::Foreground);
		else if (d_plot->axisEnabled (QwtPlot::xTop))
			c = d_plot->axisWidget(QwtPlot::xTop)->palette().color(QPalette::Foreground);

		mrkY->setLinePen(QPen(c, d_plot->axesLinewidth(), Qt::SolidLine));
	} else if (mrkY && !enable){
		mrkY->detach();
		d_plot->replot();
		mrkY = NULL;
	}
}
void Spectrogram::createLabels()
{
	clearLabels();

	QwtValueList levels = contourLevels();
	const int numLevels = levels.size();
    for (int l = 0; l < numLevels; l++){
		PlotMarker *m = new PlotMarker(l, d_labels_angle);

		QwtText t = QwtText(QString::number(levels[l]));
		t.setColor(d_labels_color);
		t.setFont(d_labels_font);

		if (d_white_out_labels)
			t.setBackgroundBrush(QBrush(Qt::white));
        else
            t.setBackgroundBrush(QBrush(Qt::transparent));
		m->setLabel(t);

        int x_axis = xAxis();
        int y_axis = yAxis();
		m->setAxis(x_axis, y_axis);

        if (d_graph && d_show_labels)
			m->attach(d_graph);
		d_labels_list << m;
	}
}
void QwtPlotScaleItem::updateBorders()
{
    const QwtPlot *plt = plot();
    if ( plt == NULL || !d_data->scaleDivFromAxis )
        return;
    
    const QRect r = plt->canvas()->contentsRect();
    d_data->canvasRectCache = r;

    QwtDoubleInterval interval;
    if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
    {
        const QwtScaleMap map = plt->canvasMap(xAxis());
        interval.setMinValue(map.invTransform(r.left()));
        interval.setMaxValue(map.invTransform(r.right()));
    }
    else
    {
        const QwtScaleMap map = plt->canvasMap(yAxis());
        interval.setMinValue(map.invTransform(r.bottom()));
        interval.setMaxValue(map.invTransform(r.top()));
    }

    QwtScaleDiv scaleDiv = d_data->scaleDraw->scaleDiv();
    scaleDiv.setInterval(interval);
    d_data->scaleDraw->setScaleDiv(scaleDiv);
}
/*!
  Find the closest curve point for a specific position

  \param pos Position, where to look for the closest curve point
  \param dist If dist != NULL, closestPoint() returns the distance between
              the position and the clostest curve point
  \return Index of the closest curve point, or -1 if none can be found 
          ( f.e when the curve has no points )
  \note closestPoint() implements a dumb algorithm, that iterates 
        over all points
*/
int QwtPlotCurve::closestPoint(const QPoint &pos, double *dist) const
{
    if ( plot() == NULL || dataSize() <= 0 )
        return -1;

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

    int index = -1;
    double dmin = 1.0e10;

    for (int i=0; i < dataSize(); i++)
    {
        const double cx = xMap.xTransform(x(i)) - pos.x();
        const double cy = yMap.xTransform(y(i)) - pos.y();

        const double f = qwtSqr(cx) + qwtSqr(cy);
        if (f < dmin)
        {
            index = i;
            dmin = f;
        }
    }
    if ( dist )
        *dist = sqrt(dmin);

    return index;
}
/*!
  Expand the selected rectangle to minZoomSize() and zoom in
  if accepted.

  \param ok If true, complete the selection and emit selected signals
            otherwise discard the selection.

  \sa accept(), minZoomSize()
  \return True if the selection has been accepted, false otherwise
*/
bool QwtPlotZoomer::end( bool ok )
{
    ok = QwtPlotPicker::end( ok );
    if ( !ok )
        return false;

    QwtPlot *plot = QwtPlotZoomer::plot();
    if ( !plot )
        return false;

    const QPolygon &pa = selection();
    if ( pa.count() < 2 )
        return false;

    QRect rect = QRect( pa.first(), pa.last() );
    rect = rect.normalized();

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

    QRectF zoomRect = QwtScaleMap::invTransform( xMap, yMap, rect ).normalized();

    zoomRect = qwtExpandedZoomRect( zoomRect, minZoomSize(),
        xMap.transformation(), yMap.transformation() );

    zoom( zoomRect );

    return true;
}
Exemple #25
0
std::string Grid::saveToString() {
  TSVSerialiser tsv;
  tsv.writeLine("grid");

  tsv << xEnabled() << xMinEnabled();
  tsv << yEnabled() << yMinEnabled();

  tsv << majPenX().color().name();
  tsv << majPenX().style() - 1;
  tsv << majPenX().widthF();

  tsv << minPenX().color().name();
  tsv << minPenX().style() - 1;
  tsv << minPenX().widthF();

  tsv << majPenY().color().name();
  tsv << majPenY().style() - 1;
  tsv << majPenY().widthF();

  tsv << minPenY().color().name();
  tsv << minPenY().style() - 1;
  tsv << minPenY().widthF();

  tsv << xZeroLineEnabled() << yZeroLineEnabled();
  tsv << xAxis() << yAxis();
  tsv << testRenderHint(QwtPlotItem::RenderAntialiased);
  return tsv.outputLines();
}
Exemple #26
0
void Grid::enableZeroLineY(bool enable)
{
	Graph *d_plot = (Graph *)plot();
	if (!d_plot)
		return;

	if (!mrkY && enable) {
		mrkY = new QwtPlotMarker();
		d_plot->insertMarker(mrkY);
		mrkY->setRenderHint(QwtPlotItem::RenderAntialiased, false);
		mrkY->setAxis(xAxis(), yAxis());
		mrkY->setLineStyle(QwtPlotMarker::HLine);
		mrkY->setValue(0.0, 0.0);

		double width = 1;
		if (d_plot->canvas()->lineWidth())
			width = d_plot->canvas()->lineWidth();
		else if (d_plot->axisEnabled (QwtPlot::xBottom) || d_plot->axisEnabled (QwtPlot::xTop))
			width =  d_plot->axesLinewidth();

		mrkY->setLinePen(QPen(Qt::black, width, Qt::SolidLine));
	} else if (mrkY && !enable){
		mrkY->detach();
		d_plot->replot();
		mrkY = NULL;
	}
}
double LineMarker::dist(int x, int y)
{
const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

const int x0 = xMap.transform(d_rect.left());
const int y0 = yMap.transform(d_rect.top());
const int x1 = xMap.transform(d_rect.right());
const int y1 = yMap.transform(d_rect.bottom());

int xmin=QMIN(x0,x1);
int xmax=QMAX(x0,x1);
int ymin=QMIN(y0,y1);
int ymax=QMAX(y0,y1);
	
if ( (x>xmax || x<xmin || xmin==xmax) && (ymax<y || ymin>y || ymin==ymax))
	//return the shortest distance to one of the ends
	return QMIN(sqrt(double((x-x0)*(x-x0)+(y-y0)*(y-y0))),
				sqrt(double((x-x1)*(x-x1)+(y-y1)*(y-y1))));
	
double d;
if (x0==x1)
	d=abs(x-x0);
else
	{
	double a=(double)(y1-y0)/(double)(x1-x0);
	double b=y0-a*x0;
	d=(a*x-y+b)/sqrt(a*a+1);
	}	
return fabs(d);
}
QPoint ImageMarker::getOrigin()
{
const QwtScaleMap &xMap = plot()->canvasMap(xAxis());
const QwtScaleMap &yMap = plot()->canvasMap(yAxis());

return QPoint(xMap.transform(d_rect.left()), yMap.transform(d_rect.top()));
};
/*!
  Find the closest curve point for a specific position

  \param pos Position, where to look for the closest curve point
  \param dist If dist != NULL, closestPoint() returns the distance between
              the position and the closest curve point
  \return Index of the closest curve point, or -1 if none can be found
          ( f.e when the curve has no points )
  \note closestPoint() implements a dumb algorithm, that iterates
        over all points
*/
int QwtPlotCurve::closestPoint( const QPoint &pos, double *dist ) const
{
    const size_t numSamples = dataSize();

    if ( plot() == NULL || numSamples <= 0 )
        return -1;

    const QwtSeriesData<QPointF> *series = data();

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

    int index = -1;
    double dmin = 1.0e10;

    for ( uint i = 0; i < numSamples; i++ )
    {
        const QPointF sample = series->sample( i );

        const double cx = xMap.transform( sample.x() ) - pos.x();
        const double cy = yMap.transform( sample.y() ) - pos.y();

        const double f = qwtSqr( cx ) + qwtSqr( cy );
        if ( f < dmin )
        {
            index = i;
            dmin = f;
        }
    }
    if ( dist )
        *dist = qSqrt( dmin );

    return index;
}
void ImageMarker::updateBoundingRect()
{
if (!plot())
	return;

d_rect = invTransform(plot()->canvasMap(xAxis()), plot()->canvasMap(yAxis()), QRect(d_pos, d_size));
}