Esempio n. 1
0
void
PfPvPlot::configChanged()
{
    setCanvasBackground(GColor(CPLOTBACKGROUND));

    // frame with inverse of background
    QwtSymbol *sym = new QwtSymbol;
    sym->setStyle(QwtSymbol::Ellipse);
    sym->setSize(4);
    sym->setPen(QPen(Qt::red));
    sym->setBrush(QBrush(Qt::red));
    curve->setSymbol(sym);
    curve->setStyle(QwtPlotCurve::Dots);
    curve->setRenderHint(QwtPlotItem::RenderAntialiased);

    QPalette palette;
    palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND)));
    palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER));
    palette.setColor(QPalette::Text, GColor(CPLOTMARKER));
    setPalette(palette);

    axisWidget(QwtPlot::xBottom)->setPalette(palette);
    axisWidget(QwtPlot::yLeft)->setPalette(palette);

    // use grid line color for mX, mY and CPcurve
    QPen marker = GColor(CPLOTMARKER);
    QPen cp = GColor(CCP);
    mX->setLinePen(marker);
    mY->setLinePen(marker);
    cpCurve->setPen(cp);

    setCL(appsettings->value(this, GC_CRANKLENGTH).toDouble() / 1000.0);

    replot();
}
Esempio n. 2
0
void
Aerolab::configChanged(qint32)
{

  // set colors
  setCanvasBackground(GColor(CPLOTBACKGROUND));
  QPen vePen = QPen(GColor(CAEROVE));
  vePen.setWidth(appsettings->value(this, GC_LINEWIDTH, 0.5).toDouble());
  veCurve->setPen(vePen);
  QPen altPen = QPen(GColor(CAEROEL));
  altPen.setWidth(appsettings->value(this, GC_LINEWIDTH, 0.5).toDouble());
  altCurve->setPen(altPen);
  QPen gridPen(GColor(CPLOTGRID));
  gridPen.setStyle(Qt::DotLine);
  grid->setPen(gridPen);

  QPen ihlPen = QPen( GColor( CINTERVALHIGHLIGHTER ) );
  ihlPen.setWidth(1);
  intervalHighlighterCurve->setPen( ihlPen );

  QColor ihlbrush = QColor(GColor(CINTERVALHIGHLIGHTER));
  ihlbrush.setAlpha(40);
  intervalHighlighterCurve->setBrush(ihlbrush);   // fill below the line

  //XXX broken this->legend()->remove( intervalHighlighterCurve ); // don't show in legend
  QPalette palette;
  palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER));
  palette.setColor(QPalette::Text, GColor(CPLOTMARKER));
  axisWidget(QwtPlot::xBottom)->setPalette(palette);
  axisWidget(QwtPlot::yLeft)->setPalette(palette);
}
Esempio n. 3
0
void
HrPwPlot::configChanged(qint32)
{
    // setColors bg
    setCanvasBackground(GColor(CPLOTBACKGROUND));

    QPalette palette;
    palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND)));
    palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND)));
    palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER));
    palette.setColor(QPalette::Text, GColor(CPLOTMARKER));
    setPalette(palette);

    // tick draw
    QwtScaleDraw *sd = new QwtScaleDraw;
    sd->setTickLength(QwtScaleDiv::MajorTick, 3);
    sd->setTickLength(QwtScaleDiv::MinorTick, 0);
    setAxisScaleDraw(QwtPlot::xBottom, sd);
    axisWidget(QwtPlot::xBottom)->setPalette(palette);

    sd = new QwtScaleDraw;
    sd->setTickLength(QwtScaleDiv::MajorTick, 3);
    sd->enableComponent(QwtScaleDraw::Ticks, false);
    sd->enableComponent(QwtScaleDraw::Backbone, false);
    setAxisScaleDraw(QwtPlot::yLeft, sd);
    axisWidget(QwtPlot::yLeft)->setPalette(palette);

    QPen gridPen;
    gridPen.setColor(GColor(CPLOTGRID));
    grid->setPen(gridPen);
}
Esempio n. 4
0
bool Plot::eventFilter(QObject *object, QEvent *e)
{
    if ( e->type() == QEvent::Resize )
    {
        const QSize &size = ((QResizeEvent *)e)->size();
        if ( object == (QObject *)axisWidget(yLeft) )
        {
            const QwtScaleWidget *scaleWidget = axisWidget(yLeft);

            const int margin = 2;

            // adjust the color bar to the scale backbone
            const int x = size.width() - scaleWidget->margin() + margin;
            const int w = scaleWidget->margin() - 2 * margin;
            const int y = scaleWidget->startBorderDist();
            const int h = size.height() -
                scaleWidget->startBorderDist() - scaleWidget->endBorderDist();

            d_colorBar->setGeometry(x, y, w, h);
        }
        if ( object == canvas() )
        {
            const int w = 16;
            const int h = 50;
            const int margin = 2;

            const QRect cr = canvas()->contentsRect();
            d_wheel->setGeometry(
                cr.right() - margin - w, cr.center().y() - h / 2, w, h);
        }
    }

    return QwtPlot::eventFilter(object, e);
}
SpinScanPolarPlot::SpinScanPolarPlot(QWidget *parent, uint8_t *spinData) : QwtPlot(parent), leftCurve(NULL), rightCurve(NULL), spinData(spinData)
{
    // Setup the axis
    setAxisTitle(yLeft, "SpinScan");
    setAxisMaxMinor(xBottom, 0);
    setAxisMaxMinor(yLeft, 0);

    QPalette pal;
    setAxisScale(yLeft, -90, 90); // max 8 bit plus a little
    setAxisScale(xBottom, -90, 90); // max 8 bit plus a little
    pal.setColor(QPalette::WindowText, GColor(CSPINSCANLEFT));
    pal.setColor(QPalette::Text, GColor(CSPINSCANLEFT));
    axisWidget(QwtPlot::yLeft)->setPalette(pal);
    axisWidget(QwtPlot::yLeft)->scaleDraw()->setTickLength(QwtScaleDiv::MajorTick, 3);

    enableAxis(xBottom, false); // very little value and some cpu overhead
    enableAxis(yLeft, false);

    rightCurve = new QwtPlotCurve("SpinScan Right");
    rightCurve->setRenderHint(QwtPlotItem::RenderAntialiased); // too cpu intensive
    rightCurve->attach(this);
    rightCurve->setYAxis(QwtPlot::yLeft);
    rightSpinScanPolarData = new SpinScanPolarData(spinData, false);

    leftCurve = new QwtPlotCurve("SpinScan Left");
    leftCurve->setRenderHint(QwtPlotItem::RenderAntialiased); // too cpu intensive
    leftCurve->attach(this);
    leftCurve->setYAxis(QwtPlot::yLeft);
    leftSpinScanPolarData = new SpinScanPolarData(spinData, true);

    static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame);
    configChanged(CONFIG_APPEARANCE); // set colors
}
Esempio n. 6
0
void SaxsviewImage::setAxisTitleFontColor(const QColor& c) {
  QPalette pal = axisWidget(QwtPlot::xBottom)->palette();
  pal.setColor(QPalette::Text, c);

  for (int i = QwtPlot::yLeft; i < QwtPlot::axisCnt; ++i)
    axisWidget(i)->setPalette(pal);

  replot();
}
Esempio n. 7
0
int Graph::getAxisOnPos(const QPoint &pos)
{
    int yLeftPos = axisWidget(QwtPlot::yLeft)->pos().x() + axisWidget(QwtPlot::yLeft)->width();
    int yRightPos = axisWidget(QwtPlot::yRight)->pos().x();
    int xPos = axisWidget(QwtPlot::xBottom)->pos().y();

    if(pos.x() < yLeftPos)      return QwtPlot::yLeft;
    else if(yRightPos && pos.x() > yRightPos) return QwtPlot::yRight;
    else if(xPos && pos.y() > xPos) return QwtPlot::xBottom;
    else                    return -1;
}
Esempio n. 8
0
void caStripPlot::setScaleColor(QColor c)
{
    QwtScaleWidget *scaleX =axisWidget(QwtPlot::xBottom);
    QwtScaleWidget *scaleY =axisWidget(QwtPlot::yLeft);
    thisScaleColor = c;
    QPalette palette = scaleX->palette();
    palette.setColor( QPalette::WindowText, c); // for ticks
    palette.setColor( QPalette::Text, c);       // for ticks' labels
    scaleX->setPalette( palette);
    scaleY->setPalette (palette);
    titleLabel()->setPalette(palette);
}
Esempio n. 9
0
/*!
  \brief Initializes a QwtPlot instance
  \param title Title text
 */
void QwtPlot::initPlot( const QwtText &title )
{
    d_data = new PrivateData;

    d_data->layout = new QwtPlotLayout;
    d_data->autoReplot = false;

    // title
    d_data->titleLabel = new QwtTextLabel( this );
    d_data->titleLabel->setObjectName( "QwtPlotTitle" );
    d_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );

    QwtText text( title );
    text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
    d_data->titleLabel->setText( text );

    // footer
    d_data->footerLabel = new QwtTextLabel( this );
    d_data->footerLabel->setObjectName( "QwtPlotFooter" );

    QwtText footer;
    footer.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
    d_data->footerLabel->setText( footer );

    // legend
    d_data->legend = NULL;

    // axis
    initAxesData();

    // canvas
    d_data->canvas = new QwtPlotCanvas( this );
    d_data->canvas->setObjectName( "QwtPlotCanvas" );
    d_data->canvas->installEventFilter( this );

    setSizePolicy( QSizePolicy::MinimumExpanding,
        QSizePolicy::MinimumExpanding );

    resize( 200, 200 );

    QList<QWidget *> focusChain;
    focusChain << this << d_data->titleLabel << axisWidget( xTop )
        << axisWidget( yLeft ) << d_data->canvas << axisWidget( yRight )
        << axisWidget( xBottom ) << d_data->footerLabel;

    for ( int i = 0; i < focusChain.size() - 1; i++ )
        qwtSetTabOrder( focusChain[i], focusChain[i+1], false );

    qwtEnableLegendItems( this, true );
}
Esempio n. 10
0
// set colours mostly
void
MUPlot::configChanged(qint32)
{
    QPalette palette;
    palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND)));
    palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER));
    palette.setColor(QPalette::Text, GColor(CPLOTMARKER));
    setPalette(palette);

    axisWidget(QwtPlot::xBottom)->setPalette(palette);
    axisWidget(QwtPlot::yLeft)->setPalette(palette);

    setCanvasBackground(GColor(CPLOTBACKGROUND));
}
Esempio n. 11
0
/**
 * Tworzy wykres spektrogramu.
 *
 * Przygotowuje mapowanie kolorów, skale osi we właściwych jednostkach itp.
 *
 * @param parent obiekt rodzica
 */
SpectrogramPlot::SpectrogramPlot(QWidget* parent):
    QwtPlot(tr("Wave file not loaded"), parent)
{
    spectrogram = new QwtPlotSpectrogram();
    QwtLinearColorMap colorMap(Qt::black, Qt::red);
    colorMap.addColorStop(0.3, Qt::darkBlue);
    colorMap.addColorStop(0.4, Qt::blue);
    colorMap.addColorStop(0.65, Qt::green);
    colorMap.addColorStop(0.85, Qt::yellow);
    spectrogram->setColorMap(colorMap);

    // kolorowa prawa oœś
    QwtScaleWidget *rightAxis = axisWidget(yRight);
    rightAxis->setTitle(tr("Intensity [dB]"));
    rightAxis->setColorBarEnabled(true);
    enableAxis(yRight);
    spectrogram->attach(this);
    const QFontMetrics fmRight(rightAxis->font());
    int intensityWidth = rightAxis->colorBarWidth() + fmRight.width("888 888");
    axisScaleDraw(yRight)->setMinimumExtent(intensityWidth);

    QwtPlotPanner *panner = new QwtPlotPanner(canvas());
    panner->setAxisEnabled(QwtPlot::yRight, false);
    panner->setMouseButton(Qt::MidButton);

    // dolna oś
    setAxisScaleDraw(xBottom, new DurationScaleDraw());
}
Esempio n. 12
0
void Plot::removeCurve(int index)
{
	QwtPlotItem *c = d_curves[index];
  	if (!c)
  		return;

  	if (c->rtti() == QwtPlotItem::Rtti_PlotSpectrogram)
  	{
  		Spectrogram *sp = (Spectrogram *)c;
  	    QwtScaleWidget *colorAxis = axisWidget(sp->colorScaleAxis());
  	    if (colorAxis)
  	    	colorAxis->setColorBarEnabled(false);
  	}

	c->detach();
	QwtPlotItem* p = d_curves.take (index);
  // RNT: Making curve_key unique prevents clashes elsewhere
	//--curve_key;
	// MG: This is a rather crude but effective way of delaying the
	// deletion of the curve objects. This is necessary because in
	// a tight loop a curve may not have been completely removed 
	// but the object has been deleted.
	Detacher *detacher = new Detacher(p);
	detacher->deleteLater();
}
/*!
  \return the title of a specified axis
  \param axisId axis index
*/
QwtText QwtPlot::axisTitle(int axisId) const
{
    if (axisValid(axisId))
        return axisWidget(axisId)->title();
    else
        return QwtText();
}
Esempio n. 14
0
/*!
  \param axisId Axis
  \return Map for the axis on the canvas. With this map pixel coordinates can
          translated to plot coordinates and vice versa.
  \sa QwtScaleMap, transform(), invTransform()

*/
QwtScaleMap QwtPlot::canvasMap( int axisId ) const
{
    QwtScaleMap map;
    if ( !d_data->canvas )
        return map;

    map.setTransformation( axisScaleEngine( axisId )->transformation() );

    const QwtScaleDiv &sd = axisScaleDiv( axisId );
    map.setScaleInterval( sd.lowerBound(), sd.upperBound() );

    if ( axisEnabled( axisId ) )
    {
        const QwtScaleWidget *s = axisWidget( axisId );
        if ( axisId == yLeft || axisId == yRight )
        {
            double y = s->y() + s->startBorderDist() - d_data->canvas->y();
            double h = s->height() - s->startBorderDist() - s->endBorderDist();
            map.setPaintInterval( y + h, y );
        }
        else
        {
            double x = s->x() + s->startBorderDist() - d_data->canvas->x();
            double w = s->width() - s->startBorderDist() - s->endBorderDist();
            map.setPaintInterval( x, x + w );
        }
    }
    else
    {
        const QRect &canvasRect = d_data->canvas->contentsRect();
        if ( axisId == yLeft || axisId == yRight )
        {
            int top = 0;
            if ( !plotLayout()->alignCanvasToScale( xTop ) )
                top = plotLayout()->canvasMargin( xTop );

            int bottom = 0;
            if ( !plotLayout()->alignCanvasToScale( xBottom ) )
                bottom = plotLayout()->canvasMargin( xBottom );

            map.setPaintInterval( canvasRect.bottom() - bottom,
                                  canvasRect.top() + top );
        }
        else
        {
            int left = 0;
            if ( !plotLayout()->alignCanvasToScale( yLeft ) )
                left = plotLayout()->canvasMargin( yLeft );

            int right = 0;
            if ( !plotLayout()->alignCanvasToScale( yRight ) )
                right = plotLayout()->canvasMargin( yRight );

            map.setPaintInterval( canvasRect.left() + left,
                                  canvasRect.right() - right );
        }
    }

    return map;
}
/*!
  \returns the scale draw of a specified axis
  \param axisId axis index
  \return specified scaleDraw for axis, or NULL if axis is invalid.
  \sa QwtScaleDraw
*/
QwtScaleDraw *QwtPlot::axisScaleDraw(int axisId) 
{
    if (!axisValid(axisId))
        return NULL;

    return axisWidget(axisId)->scaleDraw();
}
Esempio n. 16
0
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));
}
Esempio n. 17
0
/*!
  \return Size hint for the plot widget
  \sa minimumSizeHint()
*/
QSize QwtPlot::sizeHint() const
{
    int dw = 0;
    int dh = 0;
    for ( int axisId = 0; axisId < axisCnt; axisId++ )
    {
        if ( axisEnabled( axisId ) )
        {
            const int niceDist = 40;
            const QwtScaleWidget *scaleWidget = axisWidget( axisId );
            const QwtScaleDiv &scaleDiv = scaleWidget->scaleDraw()->scaleDiv();
            const int majCnt = scaleDiv.ticks( QwtScaleDiv::MajorTick ).count();

            if ( axisId == yLeft || axisId == yRight )
            {
                int hDiff = ( majCnt - 1 ) * niceDist
                    - scaleWidget->minimumSizeHint().height();
                if ( hDiff > dh )
                    dh = hDiff;
            }
            else
            {
                int wDiff = ( majCnt - 1 ) * niceDist
                    - scaleWidget->minimumSizeHint().width();
                if ( wDiff > dw )
                    dw = wDiff;
            }
        }
    }
    return minimumSizeHint() + QSize( dw, dh );
}
Esempio n. 18
0
void
CpintPlot::configChanged()
{
    QPalette palette;
    palette.setBrush(QPalette::Window, QBrush(GColor(CPLOTBACKGROUND)));
    palette.setColor(QPalette::WindowText, GColor(CPLOTMARKER));
    palette.setColor(QPalette::Text, GColor(CPLOTMARKER));
    setPalette(palette);

    axisWidget(QwtPlot::xBottom)->setPalette(palette);
    axisWidget(QwtPlot::yLeft)->setPalette(palette);

    setCanvasBackground(GColor(CPLOTBACKGROUND));
    //QPen gridPen(GColor(CPLOTGRID));
    //gridPen.setStyle(Qt::DotLine);
    //grid->setPen(gridPen);
}
void QwtPlot::setAxisScaleDraw(int axisId, QwtScaleDraw *scaleDraw)
{
    if (axisValid(axisId))
    {
        axisWidget(axisId)->setScaleDraw(scaleDraw);
        autoRefresh();
    }
}
/*!
  \return the font of the scale labels for a specified axis
  \param axisId axis index
*/
QFont QwtPlot::axisFont(int axisId) const
{
    if (axisValid(axisId))
        return axisWidget(axisId)->font();
    else
        return QFont();
    
}
Esempio n. 21
0
Plot::Plot( QWidget *parent ):
    QwtPlot( parent ),
    d_formatType( 0 ),
    d_alpha(255)
{
    d_spectrogram = new QwtPlotSpectrogram();
    d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count
    d_spectrogram->setCachePolicy( QwtPlotRasterItem::PaintCache );

    QList<double> contourLevels;
    for ( double level = 0.5; level < 10.0; level += 1.0 )
        contourLevels += level;
    d_spectrogram->setContourLevels( contourLevels );

    d_spectrogram->setData( new SpectrogramData() );
    d_spectrogram->attach( this );

    const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );

    // A color bar on the right axis
    QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight );
    rightAxis->setTitle( "Intensity" );
    rightAxis->setColorBarEnabled( true );

    setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
    enableAxis( QwtPlot::yRight );

    plotLayout()->setAlignCanvasToScales( true );

    setColorMap( Plot::RGBMap );

    // LeftButton for the zooming
    // MidButton for the panning
    // RightButton: zoom out by 1
    // Ctrl+RighButton: zoom out to full size

    QwtPlotZoomer* zoomer = new MyZoomer( canvas() );
    zoomer->setMousePattern( QwtEventPattern::MouseSelect2,
        Qt::RightButton, Qt::ControlModifier );
    zoomer->setMousePattern( QwtEventPattern::MouseSelect3,
        Qt::RightButton );

    QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
    panner->setAxisEnabled( QwtPlot::yRight, false );
    panner->setMouseButton( Qt::MidButton );

    // Avoid jumping when labels with more/less digits
    // appear/disappear when scrolling vertically

    const QFontMetrics fm( axisWidget( QwtPlot::yLeft )->font() );
    QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft );
    sd->setMinimumExtent( fm.width( "100.00" ) );

    const QColor c( Qt::darkBlue );
    zoomer->setRubberBandPen( c );
    zoomer->setTrackerPen( c );
}
Esempio n. 22
0
void ZoomPlot :: mouseReleaseEvent ( QMouseEvent * event ) {
  int mx = event->x() - axisWidget(yLeft)->sizeHint().width();	//current mouse coordinates
  int my = event->y();						//in reference to plot origin (w/o scale)

  if (event->button() == Qt::LeftButton) { //LMB - zooming
     drawing = false;
     delete kwadrat;

     zoom_start_x -= axisWidget(yLeft)->sizeHint().width();

     if (mx == zoom_start_x || my == zoom_start_y) {std::cout << "Cannot zoom!\n"; return;}

     double to_x = invTransform (xBottom, mx), to_y = invTransform (yLeft, my);
     double from_x = invTransform (xBottom, zoom_start_x), from_y = invTransform (yLeft, zoom_start_y);

     ZoomIn (from_x,from_y,to_x,to_y);
  }
  else if (event->button() == Qt::MidButton) { emit clicked(Qt::MidButton, invTransform (xBottom, event->x()-axisWidget(yLeft)->sizeHint().width()), invTransform (yLeft, event->y()));} //ustaw lewy kraniec?
  else if (event->button() == Qt::RightButton) { emit clicked(Qt::RightButton, invTransform (xBottom, event->x()-axisWidget(yLeft)->sizeHint().width()), invTransform (yLeft, event->y()));} //ustaw prawy kraniec?
}
Esempio n. 23
0
QSize Plot::sizeHint() const
{
    const QSize hint = QwtPlot::minimumSizeHint();

    const int fh = axisWidget( QwtPlot::yLeft )->fontMetrics().height();
    const int spacing = 0;
    const int fw = dynamic_cast<const QwtPlotCanvas*>( canvas() )->frameWidth();

    // 4 tick labels 
    return QSize( hint.width(), 4 * fh + 3 * spacing + 2 * fw );
}
Esempio n. 24
0
Graph::Graph(QWidget *parent) : QwtPlot(parent)
{
    // zoom in/out with the wheel
    Magnifier *magnifier = new Magnifier( canvas() );
    magnifier->setMouseButton(Qt::NoButton);

    // panning with the left mouse button
    Panner *panner =  new Panner( canvas() );
    panner->setMouseButton(Qt::LeftButton);

    // zooming with middle button
    QwtPlotZoomer *zoomer = new QwtPlotZoomer(canvas());
    {
        QVector<QwtEventPattern::MousePattern> pattern(6);
        pattern[0].button = Qt::MiddleButton;
        zoomer->setMousePattern(pattern);
    }

    m_grid = new QwtPlotGrid();
    m_grid->setMinorPen(QPen(Qt::gray, 0.0, Qt::DotLine));
    m_grid->setMajorPen(QPen(Qt::black, 0.0, Qt::DotLine));
    m_grid->enableX(true);
    m_grid->enableXMin(true);
    m_grid->enableY(true);
    m_grid->enableYMin(true);
    m_grid->attach(this);

    initLegend();

    connect(axisWidget(QwtPlot::xBottom), SIGNAL(scaleDivChanged()), SIGNAL(updateSampleSize()));

    setAxisScale(QwtPlot::xBottom, -20, 20);
    setAxisScale(QwtPlot::yRight, -20, 20);
    setAxisScale(QwtPlot::yLeft, -20, 20);
    axisWidget(QwtPlot::xBottom)->setToolTip(tr("Double-click to add marker"));
    axisWidget(QwtPlot::yLeft)->setToolTip(tr("Double-click to add marker"));
    axisWidget(QwtPlot::yRight)->setToolTip(tr("Double-click to add marker"));

    // to show graph appearance while dragging from add button to widget area
    replot();
}
Esempio n. 25
0
void matrixofpixels::PixPlotSpect(int TypeOfSpec,QwtMatrixRasterData *rasterpixdata)
{
    changeitems();
    MapPlot->setData(rasterpixdata);
    MapPlot->setRenderThreadCount(0);
    setAxisAutoScale(this->xTop);
    setAxisAutoScale(this->xBottom);



    switch (TypeOfSpec)
    {
    case 1:
        MapPlot->setColorMap(new ColorMap(BLUERED));
        break;
    case 2:
        MapPlot->setColorMap(new ColorMap(BLACKWHITE));
        break;
    default:
        MapPlot->setColorMap(new ColorMap(BLUERED));
    }

    MapPlot->attach(/*MainPlot*/this);

    const QwtInterval zInterval = MapPlot->data()->interval(Qt::ZAxis);

    setAxisScale(QwtPlot::xBottom, 0, Npix);
    setAxisMaxMinor(QwtPlot::xBottom, 0);
    setAxisScale(QwtPlot::yLeft, 0, Npix);
    setAxisMaxMinor(QwtPlot::yLeft, 0);

    //rightAxis = new QwtScaleWidget();
    QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);

    //rightAxis = axisWidget(QwtPlot::yRight);
    rightAxis->setColorBarEnabled(true);
    rightAxis->setColorBarWidth(20);
    rightAxis->setColorMap(zInterval, new ColorMap(TypeOfSpec) );
    //ColorMap(TypeOfSpec);

    plotLayout()->setAlignCanvasToScales(true);

    setAxisScale(QwtPlot::yRight,zInterval.minValue(),zInterval.maxValue());
    enableAxis(QwtPlot::yRight);
    replot();
    setAutoFillBackground(true);

    /**
      setAutoFillBackground(true); - autozapolnenie, ctobi isklyuchit'
    nalozjeniya graphikov
    */

}
Esempio n. 26
0
void Plot::setColorMap( int type )
{
    QwtScaleWidget *axis = axisWidget( QwtPlot::yRight );
    const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );

    d_mapType = type;

    int alpha = d_alpha;
    switch( type )
    {
        case Plot::HueMap:
        {
            d_spectrogram->setColorMap( new HueColorMap( d_formatType ) );
            axis->setColorMap( zInterval, new HueColorMap( d_formatType ) );
            break;
        }
        case Plot::SaturationMap:
        {
            d_spectrogram->setColorMap( new SaturationColorMap( d_formatType ) );
            axis->setColorMap( zInterval, new SaturationColorMap( d_formatType ) );
            break;
        }
        case Plot::ValueMap:
        {
            d_spectrogram->setColorMap( new ValueColorMap( d_formatType ) );
            axis->setColorMap( zInterval, new ValueColorMap( d_formatType ) );
            break;
        }
        case Plot::SVMap:
        {
            d_spectrogram->setColorMap( new SVColorMap( d_formatType ) );
            axis->setColorMap( zInterval, new SVColorMap( d_formatType ) );
            break;
        }
        case Plot::AlphaMap:
        {
            alpha = 255;
            d_spectrogram->setColorMap( new AlphaColorMap( d_formatType ) );
            axis->setColorMap( zInterval, new AlphaColorMap( d_formatType ) );
            break;
        }
        case Plot::RGBMap:
        default:
        {
            d_spectrogram->setColorMap( new LinearColorMap( d_formatType ) );
            axis->setColorMap( zInterval, new LinearColorMap( d_formatType ) );
        }
    }
    d_spectrogram->setAlpha( alpha );

    replot();
}
// Init X axis.
void DataPlot::initAxisX()
{
    //QwtText xTitle("System Uptime [h:m:s]");
    //xTitle.setFont(QFont("Ubuntu", 10));
    //setAxisTitle(QwtPlot::xBottom, xTitle);
    setAxisScaleDraw(QwtPlot::xBottom,new TimeScaleDraw(upTime()));
    setAxisScale(QwtPlot::xBottom, 0, PLOT_SIZE );
    setAxisLabelRotation(QwtPlot::xBottom, -50.0);
    setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
    QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
    const int fmh = QFontMetrics(scaleWidget->font()).height();
    scaleWidget->setMinBorderDist(0, fmh / 2);
}
Esempio n. 28
0
Lineplot::Lineplot(QWidget *parent)
  :QwtPlot(parent)
  ,xMin_(0)
  ,xMax_(0)
{
  counter_ = 0;
  numPoints_ = 1;
  indexPoints_ = new double[numPoints_];
  dataPoints_ = new double[numPoints_];

  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

  QPalette palette;
  palette.setColor(canvas()->backgroundRole(), QColor("white"));
  canvas()->setPalette(palette);

  curve_ = new QwtPlotCurve("Curve");
  curve_->setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
  curve_->setStyle(QwtPlotCurve::Lines);
  curve_->setRawSamples(indexPoints_, dataPoints_, numPoints_);
  curve_->setYAxis(QwtPlot::yLeft);
  curve_->attach(this);

  memset(dataPoints_, 0x0, numPoints_*sizeof(double));
  for(int i=0;i<numPoints_;i++)
    indexPoints_[i] = i;

  enableAxis(QwtPlot::yRight);
  QwtScaleWidget *leftAxis = axisWidget(QwtPlot::yLeft);
  connect(leftAxis, SIGNAL(scaleDivChanged()), this, SLOT(linkScales()));

  setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
  setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
  setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);

  axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true);
  axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true);
  axisScaleEngine(QwtPlot::yRight)->setAttribute(QwtScaleEngine::Floating,true);

  zoomer_ = new MyZoomer(canvas());
  zoomer_->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
  zoomer_->setMousePattern(QwtEventPattern::MouseSelect2, Qt::LeftButton,
                           Qt::ControlModifier);

  panner_ = new QwtPlotPanner(canvas());
  panner_->setMouseButton(Qt::RightButton);

  magnifier_ = new QwtPlotMagnifier(canvas());
  magnifier_->setMouseButton(Qt::NoButton);

}
Esempio n. 29
0
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;
}
Esempio n. 30
0
void
PerfPlot::setAxisTitle(int axis, QString label)
{
    // setup the default fonts
    QFont stGiles; // hoho - Chart Font St. Giles ... ok you have to be British to get this joke
    stGiles.fromString(appsettings->value(this, GC_FONT_CHARTLABELS, QFont().toString()).toString());
    stGiles.setPointSize(appsettings->value(NULL, GC_FONT_CHARTLABELS_SIZE, 8).toInt());

    QwtText title(label);
    title.setFont(stGiles);
    QwtPlot::setAxisFont(axis, stGiles);
    QwtPlot::setAxisTitle(axis, title);
    axisWidget(axis)->update();
}