double Graph::getAxisPosPct(int axis, const QPoint &pos) { QwtScaleWidget *w = axisWidget(axis); switch(axis) { case QwtPlot::yLeft: case QwtPlot::yRight: return 1.0 - (double(pos.y() - w->pos().y()) / w->height()); case QwtPlot::xTop: case QwtPlot::xBottom: return (double(pos.x() - w->pos().x()) / w->width()); } return 0.5; }
void QwtPlotWidget::slotMouseReleased( const QMouseEvent &e) { double x,y; char buf[100]; int dx = 0; int dy = 0; QwtScaleWidget *awx = axisWidget(QwtPlot::yLeft); if(awx != NULL) dx = awx->width(); QwtScaleWidget *awy = axisWidget(QwtPlot::xTop); if(awy != NULL) dy = awy->height(); x = this->invTransform(QwtPlot::xBottom, e.pos().x() - dx); y = this->invTransform(QwtPlot::yLeft, e.pos().y() - dy); sprintf( buf, "QPlotMouseReleased(%d,%f,%f)\n",id, x, y ); tcp_send(s,buf,strlen(buf)); }