Exemple #1
0
void SaxsviewImage::setAxisTitleFont(const QFont& font) {
  for (int i = QwtPlot::yLeft; i < QwtPlot::axisCnt; ++i) {
    QwtText t = axisTitle(i);
    t.setFont(font);
    setAxisTitle(i, t);
  }
}
Exemple #2
0
QwtText CurveTracker::trackerTextF( const QPointF &pos ) const
{
    QwtText trackerText;

    trackerText.setColor( Qt::black );

    QColor c( "#333333" );
    trackerText.setBorderPen( QPen( c, 2 ) );
    c.setAlpha( 200 );
    trackerText.setBackgroundBrush( c );

    QString info;

    const QwtPlotItemList curves = 
        plot()->itemList( QwtPlotItem::Rtti_PlotCurve );

    for ( int i = 0; i < curves.size(); i++ )
    {
        const QString curveInfo = curveInfoAt( 
            static_cast<const QwtPlotCurve *>( curves[i] ), pos );

        if ( !curveInfo.isEmpty() )
        {
            if ( !info.isEmpty() )
                info += "<br>";

            info += curveInfo;
        }
    }

    trackerText.setText( info );
    return trackerText;
}
Exemple #3
0
void Legend::toggleHide(bool hide)
{
    QList<PlotCurve*> list = mpPlot->getPlotCurvesList();

    for(int i = 0; i < list.length(); i++)
    {
        if(list[i]->title().text() == mLegendItemStr)
        {
            if (hide)
            {
                QwtText text = list[i]->title();
                text.setColor(QColor(Qt::gray));
                list[i]->setTitle(text);
                list[i]->setVisible(false);
            }
            else
            {
                QwtText text = list[i]->title();
                text.setColor(QColor(Qt::black));
                list[i]->setTitle(text.text());
                list[i]->setVisible(true);
            }
        }
    }
    mpPlot->replot();
}
Exemple #4
0
void QwtPicker::drawTracker(QPainter *painter) const
{
    const QRect textRect = trackerRect(painter->font());
    if ( !textRect.isEmpty() )
    {
        QwtText label = trackerText(d_data->trackerPosition);
        if ( !label.isEmpty() )
        {
            painter->save();

#if defined(Q_WS_MAC)
            // Antialiased fonts are broken on the Mac.
#if QT_VERSION >= 0x040000 
            painter->setRenderHint(QPainter::TextAntialiasing, false);
#else
            QFont fnt = label.usedFont(painter->font());
            fnt.setStyleStrategy(QFont::NoAntialias);
            label.setFont(fnt);
#endif
#endif
            label.draw(painter, textRect);

            painter->restore();
        }
    }
}
void MultiLayer::setFonts(const QFont &titleFnt, const QFont &scaleFnt,
                          const QFont &numbersFnt, const QFont &legendFnt) {
  for (int i = 0; i < (int)graphsList.count(); i++) {
    Graph *gr = (Graph *)graphsList.at(i);
    QwtPlot *plot = gr->plotWidget();

    QwtText text = plot->title();
    text.setFont(titleFnt);
    plot->setTitle(text);
    for (int j = 0; j < QwtPlot::axisCnt; j++) {
      plot->setAxisFont(j, numbersFnt);

      text = plot->axisTitle(j);
      text.setFont(scaleFnt);
      plot->setAxisTitle(j, text);
    }

    QVector<int> keys = gr->textMarkerKeys();
    for (int k = 0; k < (int)keys.size(); k++) {
      Legend *mrk = (Legend *)gr->textMarker(keys[k]);
      if (mrk) mrk->setFont(legendFnt);
    }
    plot->replot();
  }
  emit modifiedPlot();
}
/*!
   Draws the label for a major scale tick

   \param painter Painter
   \param value Value

   \sa drawTick(), drawBackbone()
*/
void QwtRoundScaleDraw::drawLabel( QPainter *painter, double value ) const
{
    const QwtText label = tickLabel( painter->font(), value );
    if ( label.isEmpty() )
        return;

    const double tval = scaleMap().transform( value );
    if ( ( tval > d_data->startAngle + 359 * 16 )
        || ( tval < d_data->startAngle - 359 * 16 ) )
    {
        return;
    }

    double radius = d_data->radius;
    if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ||
        hasComponent( QwtAbstractScaleDraw::Backbone ) )
    {
        radius += spacing();
    }

    if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
        radius += tickLength( QwtScaleDiv::MajorTick );

    const QSizeF sz = label.textSize( painter->font() );
    const double arc = tval / 16.0 / 360.0 * 2 * M_PI;

    const double x = d_data->center.x() +
        ( radius + sz.width() / 2.0 ) * qSin( arc );
    const double y = d_data->center.y() -
        ( radius + sz.height() / 2.0 ) * cos( arc );

    const QRectF r( x - sz.width() / 2, y - sz.height() / 2,
        sz.width(), sz.height() );
    label.draw( painter, r );
}
    PfPvPlotZoneLabel(PfPvPlot *_parent, int _zone_number)
    {
        parent = _parent;
        zone_number = _zone_number;

        RideItem *rideItem = parent->rideItem;
        const Zones *zones = rideItem->zones;
        int zone_range = rideItem->zoneRange();

        setZ(1.0 + zone_number / 100.0);

        // create new zone labels if we're shading
        if (zone_range >= 0) {

            // retrieve zone setup
            QList <int> zone_lows = zones->getZoneLows(zone_range);
            QList <QString> zone_names = zones->getZoneNames(zone_range);
            int num_zones = zone_lows.size();
            assert(zone_names.size() == num_zones);

            if (zone_number < num_zones) {

                watts = ((zone_number + 1 < num_zones) ?  0.5 * (zone_lows[zone_number] + zone_lows[zone_number + 1]) : ( (zone_number > 0) ?  (1.5 * zone_lows[zone_number] - 0.5 * zone_lows[zone_number - 1]) : 2.0 * zone_lows[zone_number]));

                text = QwtText(zone_names[zone_number]);
                text.setFont(QFont("Helvetica",24, QFont::Bold));
                QColor text_color = zoneColor(zone_number, num_zones);
                text_color.setAlpha(64);
                text.setColor(text_color);
            }
        }
    }
/*!
  Minimum size hint needed to display an entry

  \param data Attributes of the legend entry
  \return Minimum size
 */
QSize QwtPlotLegendItem::minimumSize( const QwtLegendData &data ) const
{
    QSize size( 2 * d_data->itemMargin, 2 * d_data->itemMargin );

    if ( !data.isValid() )
        return size;

    const QwtGraphic graphic = data.icon();
    const QwtText text = data.title();

    int w = 0;
    int h = 0;

    if ( !graphic.isNull() )
    {
        w = graphic.width();
        h = graphic.height();
    }

    if ( !text.isEmpty() )
    {
        const QSizeF sz = text.textSize( font() );

        w += qCeil( sz.width() );
        h = qMax( h, qCeil( sz.height() ) );
    }

    if ( graphic.width() > 0 && !text.isEmpty() )
        w += d_data->itemSpacing;

    size += QSize( w, h );
    return size;
}
Exemple #9
0
/* ------- Шрифт ------- */
void ViewPlot::settingFont()
{
    bool bOk;
    QFont fnt = QFontDialog::getFont( &bOk, stngViewPlot->value("ViewPlot/GridFont", QFont("Arial")).value<QFont>() );

    if(bOk) {
        stngViewPlot->setValue( "ViewPlot/GridFont", fnt );
        // Оси
        ui->qwtPlot_spectrogram->setAxisFontForAll(fnt);
        // Легенда
        QwtText crvTitle (curve->title());
        crvTitle.setFont(fnt);
        curve->setTitle(crvTitle);
        // Координаты
        ui->label->setFont(fnt);
        // Маркеры
        markerH->setFont(fnt);
        markerV->setFont(fnt);
    }
    ui->qwtPlot_spectrogram->replot();
    plotSquare();
    QRect rectFrame ( ui->frame->geometry() );
    rectFrame.setX(rectFrame.x() + 1);
    ui->frame->setGeometry(rectFrame);
}
    //--------------------------------------------------------------------------------------------------
    /// 
    //--------------------------------------------------------------------------------------------------
    virtual QwtText trackerText(const QPoint& pos) const override
    {
        QwtText txt;

        const RiuSummaryQwtPlot* sumPlot = dynamic_cast<const RiuSummaryQwtPlot*>(this->plot());
        if (sumPlot)
        {
            int closestYAxis = QwtPlot::yLeft;
            QString timeString;
            QString valueString;
            QPointF closestPoint = sumPlot->closestCurvePoint(pos, &valueString, &timeString, &closestYAxis);
            if (!closestPoint.isNull())
            {
                QString str = valueString;

                if (!timeString.isEmpty())
                {
                    str += QString(" (%1)").arg(timeString);
                }

                txt.setText(str);
            }

            RiuSummaryQwtPlot* nonConstPlot = const_cast<RiuSummaryQwtPlot*>(sumPlot);
            nonConstPlot->updateClosestCurvePointMarker(closestPoint, closestYAxis);
        }

        return txt;
    }
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;
	}
}
Exemple #12
0
        void draw(QPainter *painter,
	           const QwtScaleMap &xMap, const QwtScaleMap &yMap,
	           const QRect &rect) const
        {
	    if (parent->shadeZones() &&
		(rect.width() > 0) &&
		(rect.height() > 0)
		) {
		// draw the label along a plot diagonal:
		// 1. x*y = watts * dx/dv * dy/df
		// 2. x/width = y/height
		// =>
		// 1. x^2 = width/height * watts
		// 2. y^2 = height/width * watts

		double xscale = fabs(xMap.transform(3) - xMap.transform(0)) / 3;
		double yscale = fabs(yMap.transform(600) - yMap.transform(0)) / 600;
		if ((xscale > 0) && (yscale > 0)) {
		    double w = watts * xscale * yscale;
		    int x = xMap.transform(sqrt(w * rect.width() / rect.height()) / xscale);
		    int y = yMap.transform(sqrt(w * rect.height() / rect.width()) / yscale);

		    // the following code based on source for QwtPlotMarker::draw()
		    QRect tr(QPoint(0, 0), text.textSize(painter->font()));
		    tr.moveCenter(QPoint(x, y));
		    text.draw(painter, tr);
		}
	    }
	}
void ScalePicker::selectTitle(QwtScaleWidget *scale, bool select)
{
    if (!scale)
        return;

    if (d_title_selected == select && d_selected_axis == scale)
        return;

    Graph *g = plot();
    g->deselect();

    d_title_selected = select;
    d_selected_axis = scale;
	d_labels_selected = false;

    QwtText title = scale->title();
    if (select){
        title.setBackgroundPen(QPen(Qt::blue));
		g->notifyFontChange(title.font());
		g->notifyColorChange(title.color());
    } else
        title.setBackgroundPen(QPen(Qt::NoPen));

    scale->setTitle(title);
}
Exemple #14
0
//将位置转换成字符串
QwtText RectPicker::trackerTextF(const QPointF &pos) const
{
	QwtText text;

	const QPolygon points = selection();//选择的点
	if (!points.isEmpty())
	{
		QString num;
		QPoint point = points[0];
		QPointF point2 = invTransform(point);
		num = QString("(%1,%2),(,)").arg(point2.x()).arg(point2.y());
		QColor bg(Qt::white);
		bg.setAlpha(200);
		if (points.size() == 2)
		{

			QPointF point0 = invTransform(points[0]);
			QPointF point1 = invTransform(points[1]);
			num = QString("(%1,%2),(%3,%4)").arg(point0.x()).arg(point0.y()).arg(point1.x()).arg(point1.y());
		}
		text.setBackgroundBrush(QBrush(bg));
		text.setText(num);
	}
	return text;
}
Exemple #15
0
/*!
   Calculate the bounding rectangle for the tracker text
   from the current position of the tracker

   \param font Font of the tracker text
   \return Bounding rectangle of the tracker text

   \sa trackerPosition()
*/
QRect QwtPicker::trackerRect( const QFont &font ) const
{
    if ( trackerMode() == AlwaysOff ||
        ( trackerMode() == ActiveOnly && !isActive() ) )
    {
        return QRect();
    }

    if ( d_data->trackerPosition.x() < 0 || d_data->trackerPosition.y() < 0 )
        return QRect();

    QwtText text = trackerText( d_data->trackerPosition );
    if ( text.isEmpty() )
        return QRect();

    const QSizeF textSize = text.textSize( font );
    QRect textRect( 0, 0, qCeil( textSize.width() ), qCeil( textSize.height() ) );

    const QPoint &pos = d_data->trackerPosition;

    int alignment = 0;
    if ( isActive() && d_data->pickedPoints.count() > 1
        && rubberBand() != NoRubberBand )
    {
        const QPoint last =
            d_data->pickedPoints[int( d_data->pickedPoints.count() ) - 2];

        alignment |= ( pos.x() >= last.x() ) ? Qt::AlignRight : Qt::AlignLeft;
        alignment |= ( pos.y() > last.y() ) ? Qt::AlignBottom : Qt::AlignTop;
    }
    else
        alignment = Qt::AlignTop | Qt::AlignRight;

    const int margin = 5;

    int x = pos.x();
    if ( alignment & Qt::AlignLeft )
        x -= textRect.width() + margin;
    else if ( alignment & Qt::AlignRight )
        x += margin;

    int y = pos.y();
    if ( alignment & Qt::AlignBottom )
        y += margin;
    else if ( alignment & Qt::AlignTop )
        y -= textRect.height() + margin;

    textRect.moveTopLeft( QPoint( x, y ) );

    int right = qMin( textRect.right(), pickRect().right() - margin );
    int bottom = qMin( textRect.bottom(), pickRect().bottom() - margin );
    textRect.moveBottomRight( QPoint( right, bottom ) );

    int left = qMax( textRect.left(), pickRect().left() + margin );
    int top = qMax( textRect.top(), pickRect().top() + margin );
    textRect.moveTopLeft( QPoint( left, top ) );

    return textRect;
}
/*!
   Calculate the extent of the scale

   The extent is the distance between the baseline to the outermost
   pixel of the scale draw. radius() + extent() is an upper limit
   for the radius of the bounding circle.

   \param font Font used for painting the labels

   \sa setMinimumExtent(), minimumExtent()
   \warning The implemented algo is not too smart and
            calculates only an upper limit, that might be a
            few pixels too large
*/
double QwtRoundScaleDraw::extent( const QFont &font ) const
{
    double d = 0.0;

    if ( hasComponent( QwtAbstractScaleDraw::Labels ) )
    {
        const QwtScaleDiv &sd = scaleDiv();
        const QList<double> &ticks = sd.ticks( QwtScaleDiv::MajorTick );
        for ( int i = 0; i < ticks.count(); i++ )
        {
            const double value = ticks[i];
            if ( !sd.contains( value ) )
                continue;

            const QwtText label = tickLabel( font, value );
            if ( label.isEmpty() )
                continue;

            const double tval = scaleMap().transform( value );
            if ( ( tval < d_data->startAngle + 360 * 16 )
                && ( tval > d_data->startAngle - 360 * 16 ) )
            {
                const double arc = tval / 16.0 / 360.0 * 2 * M_PI;

                const QSizeF sz = label.textSize( font );
                const double off = qMax( sz.width(), sz.height() );

                double x = off * qSin( arc );
                double y = off * qCos( arc );

                const double dist = qSqrt( x * x + y * y );
                if ( dist > d )
                    d = dist;
            }
        }
    }

    if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
    {
        d += maxTickLength();
    }

    if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
    {
        const double pw = qMax( 1, penWidth() );  // penwidth can be zero
        d += pw;
    }

    if ( hasComponent( QwtAbstractScaleDraw::Labels ) &&
        ( hasComponent( QwtAbstractScaleDraw::Ticks ) ||
            hasComponent( QwtAbstractScaleDraw::Backbone ) ) )
    {
        d += spacing();
    }

    d = qMax( d, minimumExtent() );

    return d;
}
void SweepInspector::loadSweep(int index) {
  //load in new sweep values from data
  if (data == NULL) return;
  if ( (index < 0)  || (index >= data->getNumSweeps())) return;

  //remove old data and get new
  if (d_curve) d_curve->attach(NULL);
  detachItems();
  fsweep sweep = data->getSweep(index);

  d_curve = new QwtPlotCurve( data->timestampFromIndex(index) ); //Qwt will delete() this when its done with it
  d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
  d_curve->setStyle( QwtPlotCurve::Lines );
  d_curve->setPen( QColor( Qt::yellow ), 2, Qt::SolidLine );
  d_curve->setSamples( sweep );
  d_curve->attach(this);

  QwtInterval frange = data->limits(FREQ);
  //setAxisScale(QwtPlot::xBottom, frange.minValue(), frange.maxValue(), (frange.maxValue() - frange.minValue())/ 5.0);
  //setAxisScale(QwtPlot::yLeft, -135, 20, 10.0);
  setTitle( QString("RF Sweep @ %1").arg(data->timestampFromIndex(index)) );
  //set maximum zoom out
  zoomer->setZoomBase(QRectF(QPointF(frange.minValue(), 40), QPointF(frange.maxValue(), -135)));
  zoomer->zoomBase();

  //find max, min, and average values and drop it on plot as well
  double max = sweep.first().y(), min = sweep.first().y(), avg=0;
  for(int i=0; i < sweep.size(); i++) {
    max = std::max(max, sweep.at(i).y());
    min = std::min(min, sweep.at(i).y());
    avg += sweep.at(i).y();
  } avg /= sweep.size();

  //add markers onto the plot
  QwtPlotMarker *one = new QwtPlotMarker(), *two = new QwtPlotMarker();
  one->attach(this); one->setAxes(QwtPlot::xTop, QwtPlot::yRight);
  two->attach(this); two->setAxes(QwtPlot::xTop, QwtPlot::yRight);

  QwtText tone = QwtText(QString("Max: %1 dBm\nMin: %2 dBm\nAvg: %3 dBm").arg(max).arg(min).arg(avg));
  tone.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
  tone.setColor( Qt::green );
  tone.setRenderFlags(Qt::AlignTop | Qt::AlignLeft);

  one->setLabel(tone);
  one->setValue(0, 10);
  one->setLabelAlignment(Qt::AlignBottom | Qt::AlignRight);

  QwtText ttwo(data->plotText());
  ttwo.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
  ttwo.setColor( Qt::white );
  ttwo.setRenderFlags(Qt::AlignBottom | Qt::AlignRight);

  two->setLabel(ttwo);
  two->setValue(10, 10);
  two->setLabelAlignment(Qt::AlignBottom | Qt::AlignLeft);

  replot();
  repaint();
}
 virtual QwtText trackerText(const QwtDoublePoint &pos) const
 {
     QColor bg(Qt::white);
     bg.setAlpha(200);
     QwtText text = QwtPlotZoomer::trackerText(pos);
     text.setBackgroundBrush( QBrush( bg ));
     return text;
 }
Exemple #19
0
void Plot2D::topAxisFontSize(const unsigned axisFontSize)
{
  QwtText title = m_qwtPlot->axisTitle(QwtPlot::xTop);
  QFont font = title.font();
  font.setPointSize(axisFontSize);
  title.setFont(font);
  m_qwtPlot->setAxisTitle(QwtPlot::xTop, title);
}
Exemple #20
0
void Plot2D::titleFontSize(const unsigned titleFontSize)
{
  QwtText title = m_qwtPlot->title();
  QFont font = title.font();
  font.setPointSize(titleFontSize);
  title.setFont(font);
  m_qwtPlot->setTitle(title);
}
Exemple #21
0
    virtual QwtText trackerTextF(const QPointF &pos) const
    {
        QColor bg(Qt::white);

        QwtText text = QwtPlotZoomer::trackerTextF(pos);
        text.setBackgroundBrush( QBrush( bg ));
        return text;
    }
void QwtScaleWidget::drawTitle(QPainter *painter,
    QwtScaleDraw::Alignment align, const QRect &rect) const
{
    QRect r;
    double angle;
    int flags = d_data->title.renderFlags() & 
        ~(Qt::AlignTop | Qt::AlignBottom | Qt::AlignVCenter);

    switch(align)
    {
        case QwtScaleDraw::LeftScale:
            flags |= Qt::AlignTop;
            angle = -90.0;
            r.setRect(rect.left(), rect.bottom(), rect.height(), rect.width());
            break;
        case QwtScaleDraw::RightScale:
            flags |= Qt::AlignTop;
            angle = 90.0;
            r.setRect(rect.right(), rect.top(), rect.height(), rect.width());
            break;
        case QwtScaleDraw::TopScale:
            flags |= Qt::AlignTop;
            angle = 0.0;
            r = rect;
            break;
        case QwtScaleDraw::BottomScale:
        default:
            flags |= Qt::AlignBottom;
            angle = 0.0;
            r = rect;
            break;
    }

    painter->save();
    painter->setFont(font());
#if QT_VERSION < 0x040000
    painter->setPen(colorGroup().color(QColorGroup::Text));
#else
    painter->setPen(palette().color(QPalette::Text));
#endif

    const QwtMetricsMap metricsMap = QwtPainter::metricsMap();
    QwtPainter::resetMetricsMap();

    r = metricsMap.layoutToDevice(r);

    painter->translate(r.x(), r.y());
    if (angle != 0.0)
        painter->rotate(angle);

    QwtText title = d_data->title;
    title.setRenderFlags(flags);
    title.draw(painter, QRect(0, 0, r.width(), r.height()));

    QwtPainter::setMetricsMap(metricsMap); // restore metrics map

    painter->restore();
}
Exemple #23
0
    PfPvPlotZoneLabel(PfPvPlot *_parent, int _zone_number)
    {
        parent = _parent;
        RideItem *rideItem = parent->rideItem;
        zone_number = _zone_number;

        // get zone data from ride or athlete ...
        const Zones *zones;
        int zone_range = -1;

        if (parent->context->isCompareIntervals) {

            zones = parent->context->athlete->zones();
            if (!zones) return;

            // use first compare interval date
            if (parent->context->compareIntervals.count())
                zone_range = zones->whichRange(parent->context->compareIntervals[0].data->startTime().date());

            // still not set 
            if (zone_range == -1)
                zone_range = zones->whichRange(QDate::currentDate());

        } else if (rideItem) {

            zones = rideItem->zones;
            zone_range = rideItem->zoneRange();

        } else {

            return; // nulls

        }

        setZ(1.0 + zone_number / 100.0);

        // create new zone labels if we're shading
        if (zone_range >= 0) {

            // retrieve zone setup
            QList <int> zone_lows = zones->getZoneLows(zone_range);
            QList <QString> zone_names = zones->getZoneNames(zone_range);
            int num_zones = zone_lows.size();
            if(zone_names.size() != num_zones) return;

            if (zone_number < num_zones) {

                watts = ((zone_number + 1 < num_zones) ?  0.5 * (zone_lows[zone_number] + zone_lows[zone_number + 1]) : ( (zone_number > 0) ?  (1.5 * zone_lows[zone_number] - 0.5 * zone_lows[zone_number - 1]) : 2.0 * zone_lows[zone_number]));

                text = QwtText(zone_names[zone_number]);
                text.setFont(QFont("Helvetica",24, QFont::Bold));
                QColor text_color = zoneColor(zone_number, num_zones);
                text_color.setAlpha(64);
                text.setColor(text_color);
            }
        }
    }
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::setDefaults()
{
    QPalette newPalette(palette());
    newPalette.setColor(QPalette::Background, Qt::white);
    setPalette(newPalette);

    setAutoFillBackground(true);
    setCanvasBackground(Qt::white);

    QFrame* canvasFrame = dynamic_cast<QFrame*>(canvas());
    if (canvasFrame)
    {
        canvasFrame->setFrameShape(QFrame::NoFrame);
    }

    canvas()->setMouseTracking(true);
    canvas()->installEventFilter(this);

    QPen gridPen(Qt::SolidLine);
    gridPen.setColor(Qt::lightGray);
    m_grid->setPen(gridPen);

    enableAxis(QwtPlot::xBottom, true);
    enableAxis(QwtPlot::yLeft, true);
    enableAxis(QwtPlot::xTop, false);
    enableAxis(QwtPlot::yRight, false);

    plotLayout()->setAlignCanvasToScales(true);

    useDateBasedTimeAxis();

    QFont xAxisFont = axisFont(QwtPlot::xBottom);
    xAxisFont.setPixelSize(11);
    setAxisFont(QwtPlot::xBottom, xAxisFont);
    setAxisMaxMinor(QwtPlot::xBottom, 2);

    QFont yAxisFont = axisFont(QwtPlot::yLeft);
    yAxisFont.setPixelSize(11);
    setAxisFont(QwtPlot::yLeft, yAxisFont);

    setAxisMaxMinor(QwtPlot::yLeft, 3);

    QwtText axisTitleY = axisTitle(QwtPlot::yLeft);
    QFont yAxisTitleFont = axisTitleY.font();
    yAxisTitleFont.setPixelSize(11);
    yAxisTitleFont.setBold(false);
    axisTitleY.setFont(yAxisTitleFont);
    axisTitleY.setRenderFlags(Qt::AlignRight);
    setAxisTitle(QwtPlot::yLeft, axisTitleY);


    QwtLegend* legend = new QwtLegend(this);
    // The legend will be deleted in the destructor of the plot or when 
    // another legend is inserted.
    this->insertLegend(legend, BottomLegend);
}
/*!
   Set the text to the legend item

   \param text Text label
    \sa QwtTextLabel::text()
*/
void QwtLegendLabel::setText( const QwtText &text )
{
    const int flags = Qt::AlignLeft | Qt::AlignVCenter
        | Qt::TextExpandTabs | Qt::TextWordWrap;

    QwtText txt = text;
    txt.setRenderFlags( flags );

    QwtTextLabel::setText( txt );
}
Exemple #26
0
 bool ticTracker( const QPointF& pos, QwtText& text ) {
     size_t npos;
     int fcn, rep, index;
     double minutes;
     if ( ticFinder( pos.x(), npos, index, rep, fcn, minutes ) ) {
         QString ammend = QString::fromStdString( ( boost::format("[data#%d idx:%d [rep:%d] fcn:%d]") % npos % index % rep % fcn ).str() );
         text.setText( QString( "%1 %2" ).arg( text.text() ).arg( ammend ), QwtText::RichText );
     }
     return true;
 }
Exemple #27
0
void QwtPicker::drawTracker(QPainter *painter) const
{
    const QRect textRect = trackerRect(painter);
    if ( !textRect.isEmpty() )
    {
        QwtText label = trackerText(d_data->labelPosition);
        if ( !label.isEmpty() )
            label.draw(painter, textRect);
    }
}
Exemple #28
0
void CBioPlot::SetupPlot(const char * title)
{
	QwtText label;

	// start with a clean plot
	if (thePlot == NULL) delete thePlot;

	// create a new plot
	thePlot = new QwtPlot();

	// we do our own painting
	thePlot->setAutoReplot( false );

	// for faster painting, apparently
	thePlot->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);

	// plot can be rescaled
	thePlot->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

	// plot background
	thePlot->setCanvasBackground(QColor(Qt::white));

	// font to use for axes etc
	thePlot->setAxisFont(  QwtPlot::yLeft,   axis_font );
	thePlot->setAxisFont(  QwtPlot::yRight,  axis_font );
	thePlot->setAxisFont(  QwtPlot::xBottom, axis_font );
	thePlot->setAxisFont(  QwtPlot::xTop,    axis_font );

	// x-axis label
	label = QString("t (s)");
	label.setFont( axis_font );
	thePlot->setAxisTitle( QwtPlot::xBottom, label );

	// y-axis label
	label = QString(title);
	label.setFont( axis_font );
	thePlot->setAxisTitle( QwtPlot::yLeft, label );

	// set the left margin
	thePlot->axisScaleDraw( QwtPlot::yLeft )->setMinimumExtent( MARGIN );

	// max 5 ticks on the vertical axis
	thePlot->setAxisMaxMajor( QwtPlot::yLeft,  5);
	thePlot->setAxisMaxMajor( QwtPlot::yRight, 5);

	// setup the scale of the time axis
	SetAxisScale();

	//// set autoscaling for the y-axis, but start at [-1,1]
	thePlot->setAxisScale    ( QwtPlot::yLeft, -1, 1 );
	thePlot->setAxisAutoScale( QwtPlot::yLeft );

	// plot everything we made so far
	thePlot->replot();
}
QmitkHistogramWidget::QmitkHistogramWidget(QWidget * parent, bool showreport)
  : QDialog(parent)
{
  QBoxLayout *layout = new QVBoxLayout(this);

  //***histogram***

  QGroupBox *hgroupbox = new QGroupBox("", this);

  hgroupbox->setMinimumSize(900, 400);

  m_Plot = new QwtPlot(hgroupbox);
  m_Plot->setCanvasBackground(QColor(Qt::white));
  m_Plot->setTitle("Histogram");
  QwtText text = m_Plot->titleLabel()->text();
  text.setFont(QFont("Helvetica", 12, QFont::Normal));

  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->enableYMin(true);
  grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(m_Plot);

  layout->addWidget(hgroupbox);

  layout->setSpacing(20);

  if (showreport == true)
  {
    //***report***
    QGroupBox *rgroupbox = new QGroupBox("", this);

    rgroupbox->setMinimumSize(900, 400);

    QLabel *label = new QLabel("Gray  Value  Analysis", rgroupbox);
    label->setAlignment(Qt::AlignHCenter);
    label->setFont(QFont("Helvetica", 14, QFont::Bold));

    m_Textedit = new QTextEdit(rgroupbox);
    m_Textedit->setFont(QFont("Helvetica", 12, QFont::Normal));
    m_Textedit->setReadOnly(true);

    layout->addWidget(rgroupbox);
  }

  m_Picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
    QwtPicker::PointSelection, 
    QwtPlotPicker::NoRubberBand, QwtPicker::AlwaysOn, 
    m_Plot->canvas());

  connect(m_Picker, SIGNAL(selected(const QwtDoublePoint &)),
    SLOT(OnSelect(const QwtDoublePoint &)));
}
 virtual QwtText label(double value) const
 {
     QwtText lbl;
     const int index = qRound(value);
     if ((value == (double)index) && index >= 0 && index < m_labels.size())
     {
         lbl = QwtText(m_labels[index], QwtText::TeXText);
         lbl.setLayoutAttribute(QwtText::MinimumLayout);
     }
     return lbl;
 }