static inline double qwtDistance( const QwtDoublePoint &p1, const QwtDoublePoint &p2 ) { double dx = p2.x() - p1.x(); double dy = p2.y() - p1.y(); return ::sqrt( dx * dx + dy * dy ); }
QList<QwtDoublePoint> QwtCircleClipper::cuttingPoints( Edge edge, const QwtDoublePoint &pos, double radius) const { QList<QwtDoublePoint> points; if ( edge == Left || edge == Right ) { const double x = (edge == Left) ? left() : right(); if ( qwtAbs(pos.x() - x) < radius ) { const double off = ::sqrt(qwtSqr(radius) - qwtSqr(pos.x() - x)); const double y1 = pos.y() + off; if ( y1 >= top() && y1 <= bottom() ) points += QwtDoublePoint(x, y1); const double y2 = pos.y() - off; if ( y2 >= top() && y2 <= bottom() ) points += QwtDoublePoint(x, y2); } } else { const double y = (edge == Top) ? top() : bottom(); if ( qwtAbs(pos.y() - y) < radius ) { const double off = ::sqrt(qwtSqr(radius) - qwtSqr(pos.y() - y)); const double x1 = pos.x() + off; if ( x1 >= left() && x1 <= right() ) points += QwtDoublePoint(x1, y); const double x2 = pos.x() - off; if ( x2 >= left() && x2 <= right() ) points += QwtDoublePoint(x2, y); } } return points; }
/*! Constructs a rectangle with topLeft as the top-left corner and size as the rectangle size. */ QwtDoubleRect::QwtDoubleRect( const QwtDoublePoint &p, const QwtDoubleSize &size): d_left(p.x()), d_right(p.x() + size.width()), d_top(p.y()), d_bottom(p.y() + size.height()) { }
void LineMarker::setCoordStartPoint(const QwtDoublePoint& p) { if (QwtDoublePoint(d_rect.left(), d_rect.top()) == p) return; d_rect.setLeft(p.x()); d_rect.setTop(p.y()); const QwtScaleMap &xMap = d_plot->canvasMap(xAxis()); const QwtScaleMap &yMap = d_plot->canvasMap(yAxis()); d_start = QPoint(xMap.transform(p.x()), yMap.transform(p.y())); }
void LineMarker::setCoordEndPoint(const QwtDoublePoint& p) { if (QwtDoublePoint(d_rect.right(), d_rect.bottom()) == p) return; d_rect.setRight(p.x()); d_rect.setBottom(p.y()); const QwtScaleMap &xMap = d_plot->canvasMap(xAxis()); const QwtScaleMap &yMap = d_plot->canvasMap(yAxis()); d_end = QPoint(xMap.transform(p.x()), yMap.transform(p.y())); }
/*! \brief Translate a position into a position string In case of HLineRubberBand the label is the value of the y position, in case of VLineRubberBand the value of the x position. Otherwise the label contains x and y position separated by a ´, ´. The format for the double to string conversion is "%.4f". \param pos Position \return Position string */ QString QwtPlotPicker::cursorLabel(const QwtDoublePoint &pos) const { switch(rubberBand()) { case HLineRubberBand: return QString().sprintf("%.4f", pos.y()); case VLineRubberBand: return QString().sprintf("%.4f", pos.x()); default: return QString().sprintf("%.4f, %.4f", pos.x(), pos.y()); } return QString::null; // make some dumb compilers happy }
/*! \brief Translate a position into a position string In case of HLineRubberBand the label is the value of the y position, in case of VLineRubberBand the value of the x position. Otherwise the label contains x and y position separated by a ',' . The format for the double to string conversion is "%.4f". \param pos Position \return Position string */ QwtText QwtPlotPicker::trackerText(const QwtDoublePoint &pos) const { QString text; switch(rubberBand()) { case HLineRubberBand: text.sprintf("%.4f", pos.y()); break; case VLineRubberBand: text.sprintf("%.4f", pos.x()); break; default: text.sprintf("%.4f, %.4f", pos.x(), pos.y()); } return QwtText(text); }
bool QwtPolygonClipperF::insideEdge(const QwtDoublePoint &p, Edge edge) const { switch(edge) { case Left: return p.x() > left(); case Top: return p.y() > top(); case Right: return p.x() < right(); case Bottom: return p.y() < bottom(); default: break; } return false; }
/*! Translate a point from plot into pixel coordinates \return Point in pixel coordinates \sa QwtPlotPicker::invTransform() */ QPoint QwtPlotPicker::transform(const QwtDoublePoint &pos) const { QwtScaleMap xMap = plot()->canvasMap(d_xAxis); QwtScaleMap yMap = plot()->canvasMap(d_yAxis); return QPoint( xMap.transform(pos.x()), yMap.transform(pos.y()) ); }
void LineDialog::displayCoordinates(int unit) { if (unit == ScaleCoordinates){ QwtDoublePoint sp = lm->startPointCoord(); xStartBox->setValue(sp.x()); xStartBox->show(); xStartPixelBox->hide(); yStartBox->setValue(sp.y()); yStartBox->show(); yStartPixelBox->hide(); QwtDoublePoint ep = lm->endPointCoord(); xEndBox->setValue(ep.x()); xEndBox->show(); xEndPixelBox->hide(); yEndBox->setValue(ep.y()); yEndBox->show(); yEndPixelBox->hide(); } else { QPoint startPoint = lm->startPoint(); QPoint endPoint = lm->endPoint(); xStartBox->hide(); xStartPixelBox->setValue(startPoint.x()); xStartPixelBox->show(); yStartBox->hide(); yStartPixelBox->setValue(startPoint.y()); yStartPixelBox->show(); xEndBox->hide(); xEndPixelBox->setValue(endPoint.x()); xEndPixelBox->show(); yEndBox->hide(); yEndPixelBox->setValue(endPoint.y()); yEndPixelBox->show(); } }
void LineDialog::displayCoordinates(int unit) { if (unit == ScaleCoordinates) { QwtDoublePoint sp = lm->startPointCoord(); xStartBox->setText(QString::number(sp.x())); yStartBox->setText(QString::number(sp.y())); QwtDoublePoint ep = lm->endPointCoord(); xEndBox->setText(QString::number(ep.x())); yEndBox->setText(QString::number(ep.y())); } else { QPoint startPoint = lm->startPoint(); QPoint endPoint = lm->endPoint(); xStartBox->setText(QString::number(startPoint.x())); yStartBox->setText(QString::number(startPoint.y())); xEndBox->setText(QString::number(endPoint.x())); yEndBox->setText(QString::number(endPoint.y())); } }
void ProRataPeptideTable::pointMLESelected( const QwtDoublePoint point ) { int iRow = 0; unsigned int iMinIndex = 0; double dMinDistance = 1000; double dCurrentDistance = 0; map< unsigned int, double > mIndexDistance; for( unsigned int i = 0; i < vpepInfo.size(); i++ ) { if( !vpepInfo.at(i)->getValidity() ) continue; // the x and y axes are not in the same range // take a sqrt to compress the difference dCurrentDistance = sqrt( fabs( point.x() - vpepInfo.at(i)->getPCALog2Ratio() ) ) + sqrt( fabs( point.y() - vpepInfo.at(i)->getPCALog2SNR() ) ); if( dCurrentDistance < dMinDistance ) { dMinDistance = dCurrentDistance; iMinIndex = i; } } if( dMinDistance > 1000 ) return; //QMessageBox::information( this, "Row to be selected, before intising", QString::number( iMinIndex ) ); iRow = (int)iMinIndex; //QMessageBox::information( this, "Row to be selected", QString::number( iRow ) ); //qtwTable->selectRow( iRow ) ; //qtwTable->showRow( iRow ); QAbstractItemView::SelectionMode sm = qtwTable->selectionMode(); qtwTable->setSelectionMode(QAbstractItemView::ExtendedSelection); qtwTable->selectRow( iRow ); qtwTable->setSelectionMode(sm); delete ppepRatio; ppepRatio = new PeptideRatio; vpepInfo.at(iRow)->setPeptideRatio( ppepRatio ); emit peptideClicked( ppepRatio ); emit peptideClicked( vpepInfo.at(iRow) ); //qtwTable->selectRow( 0 ) ; }
double QwtCircleClipper::toAngle( const QwtDoublePoint &from, const QwtDoublePoint &to) const { if ( from.x() == to.x() ) return from.y() <= to.y() ? M_PI / 2.0 : 3 * M_PI / 2.0; const double m = qwtAbs((to.y() - from.y()) / (to.x() - from.x()) ); double angle = ::atan(m); if ( to.x() > from.x() ) { if ( to.y() > from.y() ) angle = 2 * M_PI - angle; } else { if ( to.y() > from.y() ) angle = M_PI + angle; else angle = M_PI - angle; } return angle; }
/*! \brief Calculate the bounding rect of the plot area The plot area depends on the zoom parameters. \param canvasRect Rectangle of the canvas \return Rectangle for displaying 100% of the plot */ QwtDoubleRect QwtPolarPlot::plotRect( const QRect &canvasRect ) const { const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius ); const QwtScaleEngine *se = scaleEngine( QwtPolar::Radius ); const int margin = plotMarginHint(); const QRect cr = canvasRect; const int radius = qwtMin( cr.width(), cr.height() ) / 2 - margin; QwtScaleMap map; map.setTransformation( se->transformation() ); map.setPaintXInterval( 0.0, radius / d_data->zoomFactor ); #if QWT_VERSION < 0x050200 map.setScaleInterval( sd->lBound(), sd->hBound() ); #else map.setScaleInterval( sd->lowerBound(), sd->upperBound() ); #endif double v = map.s1(); if ( map.s1() <= map.s2() ) v += d_data->zoomPos.radius(); else v -= d_data->zoomPos.radius(); v = map.xTransform( v ); const QwtDoublePoint off = QwtPolarPoint( d_data->zoomPos.azimuth(), v ).toPoint(); QwtDoublePoint center( cr.center().x(), cr.top() + margin + radius ); center -= QwtDoublePoint( off.x(), -off.y() ); QwtDoubleRect rect( 0, 0, 2 * map.p2(), 2 * map.p2() ); rect.moveCenter( center ); return rect; }
QwtDoublePoint QwtPolygonClipperF::intersectEdge(const QwtDoublePoint &p1, const QwtDoublePoint &p2, Edge edge ) const { double x=0.0, y=0.0; double m = 0; const double dy = p2.y() - p1.y(); const double dx = p2.x() - p1.x(); switch ( edge ) { case Left: x = left(); m = double(qwtAbs(p1.x() - x)) / qwtAbs(dx); y = p1.y() + int(dy * m); break; case Top: y = top(); m = double(qwtAbs(p1.y() - y)) / qwtAbs(dy); x = p1.x() + int(dx * m); break; case Right: x = right(); m = double(qwtAbs(p1.x() - x)) / qwtAbs(dx); y = p1.y() + int(dy * m); break; case Bottom: y = bottom(); m = double(qwtAbs(p1.y() - y)) / qwtAbs(dy); x = p1.x() + int(dx * m); break; default: break; } return QwtDoublePoint(x,y); }
/** Called each time the mouse moves over the canvas */ QwtText CustomPicker::trackerText(const QwtDoublePoint &pos) const { emit mouseMoved(pos.x(), pos.y()); return QwtText(); }
/*! Returns true if the point p is inside or on the edge of the rectangle; otherwise returns false. If proper is true, this function returns true only if p is inside (not on the edge). */ bool QwtDoubleRect::contains(const QwtDoublePoint &p, bool proper) const { return contains(p.x(), p.y(), proper); }
/*! Calculate the bounding interval of the radial scale that is visible on the canvas. */ QwtDoubleInterval QwtPolarPlot::visibleInterval() const { const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius ); const QwtDoubleRect cRect = canvas()->contentsRect(); const QwtDoubleRect pRect = plotRect( cRect.toRect() ); if ( cRect.contains( pRect.toRect() ) || !cRect.intersects( pRect ) ) { #if QWT_VERSION < 0x050200 return QwtDoubleInterval( sd->lBound(), sd->hBound() ); #else return QwtDoubleInterval( sd->lowerBound(), sd->upperBound() ); #endif } const QwtDoublePoint pole = pRect.center(); const QwtDoubleRect scaleRect = pRect & cRect; const QwtScaleMap map = scaleMap( QwtPolar::Radius ); double dmin = 0.0; double dmax = 0.0; if ( scaleRect.contains( pole ) ) { dmin = 0.0; QwtDoublePoint corners[4]; corners[0] = scaleRect.bottomRight(); corners[1] = scaleRect.topRight(); corners[2] = scaleRect.topLeft(); corners[3] = scaleRect.bottomLeft(); dmax = 0.0; for ( int i = 0; i < 4; i++ ) { const double dist = qwtDistance( pole, corners[i] ); if ( dist > dmax ) dmax = dist; } } else { if ( pole.x() < scaleRect.left() ) { if ( pole.y() < scaleRect.top() ) { dmin = qwtDistance( pole, scaleRect.topLeft() ); dmax = qwtDistance( pole, scaleRect.bottomRight() ); } else if ( pole.y() > scaleRect.bottom() ) { dmin = qwtDistance( pole, scaleRect.bottomLeft() ); dmax = qwtDistance( pole, scaleRect.topRight() ); } else { dmin = scaleRect.left() - pole.x(); dmax = qwtMax( qwtDistance( pole, scaleRect.bottomRight() ), qwtDistance( pole, scaleRect.topRight() ) ); } } else if ( pole.x() > scaleRect.right() ) { if ( pole.y() < scaleRect.top() ) { dmin = qwtDistance( pole, scaleRect.topRight() ); dmax = qwtDistance( pole, scaleRect.bottomLeft() ); } else if ( pole.y() > scaleRect.bottom() ) { dmin = qwtDistance( pole, scaleRect.bottomRight() ); dmax = qwtDistance( pole, scaleRect.topLeft() ); } else { dmin = pole.x() - scaleRect.right(); dmax = qwtMax( qwtDistance( pole, scaleRect.bottomLeft() ), qwtDistance( pole, scaleRect.topLeft() ) ); } } else if ( pole.y() < scaleRect.top() ) { dmin = scaleRect.top() - pole.y(); dmax = qwtMax( qwtDistance( pole, scaleRect.bottomLeft() ), qwtDistance( pole, scaleRect.bottomRight() ) ); } else if ( pole.y() > scaleRect.bottom() ) { dmin = pole.y() - scaleRect.bottom(); dmax = qwtMax( qwtDistance( pole, scaleRect.topLeft() ), qwtDistance( pole, scaleRect.topRight() ) ); } } const double radius = pRect.width() / 2.0; if ( dmax > radius ) dmax = radius; QwtDoubleInterval interval; interval.setMinValue( map.invTransform( dmin ) ); interval.setMaxValue( map.invTransform( dmax ) ); return interval; }
//! Set Value void QwtPlotMarker::setValue(const QwtDoublePoint& pos) { setValue(pos.x(), pos.y()); }
//! moves the center to pos, leaving the size unchanged void QwtDoubleRect::moveCenter(const QwtDoublePoint &pos) { moveCenter(pos.x(), pos.y()); }
/** * Zwraca "intensywność" spektrogramu w danym punkcie. * * W przypadku klasycznego spektrogramu jest to wartość danego prążka widma. * * @param pos punkt w którym pobieramy wartość * @return intensywność */ double SpectrogramPlot::getIntensity(const QwtDoublePoint& pos) const { return spectrogram->data().value(pos.x(), pos.y()); }
void SectionWindow::relayMove(QwtDoublePoint p) { emit moved(p.x(), p.y()); }
void UI::FunctionWidget::pickerSelected(const QwtDoublePoint& pos) { double x,y; //x = m_pPlot->invTransform(QwtPlot::xBottom,pos.x()); //y = m_pPlot->invTransform(QwtPlot::yLeft,pos.y()); emit pickerMouseSelected( pos.x(),pos.y() ); }
const QList<double> &levels, int flags) const #else QwtRasterData::ContourLines QwtRasterData::contourLines( const QwtDoubleRect &rect, const QSize &raster, const QValueList<double> &levels, int flags) const #endif { ContourLines contourLines; if ( levels.size() == 0 || !rect.isValid() || !raster.isValid() ) return contourLines; const double dx = rect.width() / raster.width(); const double dy = rect.height() / raster.height(); const bool ignoreOnPlane = flags & QwtRasterData::IgnoreAllVerticesOnLevel; const QwtDoubleInterval range = this->range(); bool ignoreOutOfRange = false; if ( range.isValid() ) ignoreOutOfRange = flags & IgnoreOutOfRange; ((QwtRasterData*)this)->initRaster(rect, raster); for ( int y = 0; y < raster.height() - 1; y++ ) { enum Position { Center, TopLeft, TopRight, BottomRight, BottomLeft, NumPositions }; Contour3DPoint xy[NumPositions]; for ( int x = 0; x < raster.width() - 1; x++ ) { const QwtDoublePoint pos(rect.x() + x * dx, rect.y() + y * dy); if ( x == 0 ) { xy[TopRight].setPos(pos.x(), pos.y()); xy[TopRight].setZ( value( xy[TopRight].x(), xy[TopRight].y()) ); xy[BottomRight].setPos(pos.x(), pos.y() + dy); xy[BottomRight].setZ( value(xy[BottomRight].x(), xy[BottomRight].y()) ); } xy[TopLeft] = xy[TopRight]; xy[BottomLeft] = xy[BottomRight]; xy[TopRight].setPos(pos.x() + dx, pos.y()); xy[BottomRight].setPos(pos.x() + dx, pos.y() + dy); xy[TopRight].setZ( value(xy[TopRight].x(), xy[TopRight].y()) ); xy[BottomRight].setZ( value(xy[BottomRight].x(), xy[BottomRight].y()) ); double zMin = xy[TopLeft].z(); double zMax = zMin; double zSum = zMin; for ( int i = TopRight; i <= BottomLeft; i++ ) { const double z = xy[i].z(); zSum += z; if ( z < zMin ) zMin = z; if ( z > zMax ) zMax = z; } if ( ignoreOutOfRange ) { if ( !range.contains(zMin) || !range.contains(zMax) ) continue; } if ( zMax < levels[0] || zMin > levels[levels.size() - 1] ) { continue; } xy[Center].setPos(pos.x() + 0.5 * dx, pos.y() + 0.5 * dy); xy[Center].setZ(0.25 * zSum); const int numLevels = (int)levels.size(); for (int l = 0; l < numLevels; l++) { const double level = levels[l]; if ( level < zMin || level > zMax ) continue; #if QT_VERSION >= 0x040000 QPolygonF &lines = contourLines[level]; #else QwtArray<QwtDoublePoint> &lines = contourLines[level]; #endif const ContourPlane plane(level); QwtDoublePoint line[2]; Contour3DPoint vertex[3]; for (int m = TopLeft; m < NumPositions; m++) { vertex[0] = xy[m]; vertex[1] = xy[0]; vertex[2] = xy[m != BottomLeft ? m + 1 : TopLeft]; const bool intersects = plane.intersect(vertex, line, ignoreOnPlane); if ( intersects ) { #if QT_VERSION >= 0x040000 lines += line[0]; lines += line[1]; #else const int index = lines.size(); lines.resize(lines.size() + 2, QGArray::SpeedOptim); lines[index] = line[0]; lines[index+1] = line[1]; #endif } } } } } ((QwtRasterData*)this)->discardRaster(); return contourLines; }