コード例 #1
0
ファイル: plotsdialog.cpp プロジェクト: oabdelaziz/SorpSim
void plotsDialog::resetZoomer(int i)
{

    Plot* currentPlot = dynamic_cast<Plot*>(tabs->currentWidget());

    d_zoomer[0] = new Zoomer( QwtPlot::xBottom, QwtPlot::yLeft,
                              currentPlot->canvas() );
    d_zoomer[0]->setRubberBand( QwtPicker::RectRubberBand );
    d_zoomer[0]->setRubberBandPen( QColor( Qt::green ) );
    d_zoomer[0]->setTrackerMode( QwtPicker::ActiveOnly );
    d_zoomer[0]->setTrackerPen( QColor( Qt::white ) );

    d_zoomer[1] = new Zoomer( QwtPlot::xTop, QwtPlot::yRight,
                              currentPlot->canvas() );

    d_panner = new QwtPlotPanner( currentPlot->canvas() );
    d_panner->setMouseButton( Qt::MidButton );

    d_picker = new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft,
                                  QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
                                  currentPlot->canvas() );
    d_picker->setStateMachine( new QwtPickerDragPointMachine() );
    d_picker->setRubberBandPen( QColor( Qt::green ) );
    d_picker->setRubberBand( QwtPicker::CrossRubberBand );
    d_picker->setTrackerPen( QColor( Qt::white ) );

    connect(d_picker,SIGNAL(moved(QPoint)),SLOT(moved(QPoint)));

    ui->overlayButton->setHidden(currentPlot->isParametric);
    ui->dataSelectButton->setHidden(!currentPlot->isParametric);

    enableZoomMode(false);
}
コード例 #2
0
ファイル: PlotCurve.cpp プロジェクト: jkrueger1/mantid
void PlotCurve::computeWaterfallOffsets()
{
  Plot *plot = static_cast<Plot *>(this->plot());
  Graph *g = static_cast<Graph *>(plot->parent());

  // reset the offsets
  d_x_offset = 0.0;
  d_y_offset = 0.0;

  if (g->isWaterfallPlot()){
    int index = g->curveIndex(this);
    int curves = g->curves();//Count();
    PlotCurve *c = dynamic_cast<PlotCurve*>(g->curve(0));
    // Get the minimum value of the first curve in this plot
    double ymin = c->minYValue();
    if (index > 0 && c){
      d_x_offset = index*g->waterfallXOffset()*0.01*plot->canvas()->width()/(double)(curves - 1);
      d_y_offset = index*g->waterfallYOffset()*0.01*plot->canvas()->height()/(double)(curves - 1);

      setZ(-index);
      setBaseline(ymin-d_y_offset); // Fill down to minimum value of first curve

    } else {
      setZ(0);
      setBaseline(ymin); // This is for when 'fill under curve' is turn on
    }
    if (g->grid())
      g->grid()->setZ(-g->curves()/*Count()*/ - 1);
  }
}
コード例 #3
0
ファイル: plot.cpp プロジェクト: edowson/signal-scope
 MyPanner(Plot* plot) : QObject(plot)
 {
   mEnabled = false;
   mMouseButton = Qt::LeftButton;
   mKeyboardButton = Qt::NoButton;
   mPlot = plot;
   mPlot->canvas()->installEventFilter(this);
 }
コード例 #4
0
void MultiLayer::makeTransparentLayer(Graph *g)
{
Plot *plot = g->plotWidget();
int lw = plot->lineWidth();
int x = g->x();
int y = g->y();

QRect rect = QRect (plot->x() + lw, plot->y() + lw, plot->width() - 2* lw, plot->height() - 2*lw);
QwtPlotLayout *plotLayout=plot->plotLayout();
plotLayout->activate(plot, rect, 0);

QPixmap pix = QPixmap::grabWidget (canvas, x, y, g->width(), g->height());
plot->setPaletteBackgroundPixmap(pix);
	
QLabel *title=plot->titleLabel ();
QRect tRect=plotLayout->titleRect ();
if (!tRect.isNull())
	{
	pix = QPixmap::grabWidget (canvas, x + tRect.x(), y + tRect.y(), tRect.width(), tRect.height());		
	title->setPaletteBackgroundPixmap(pix);
	}

for (int i=0;i<QwtPlot::axisCnt;i++)
	{
	QwtScale *scale=(QwtScale *) plot->axis (i);
	if (scale)
		{
		QRect sRect=plotLayout->scaleRect (i);
		pix = QPixmap::grabWidget (canvas,x+sRect.x(),y+sRect.y(),sRect.width(), sRect.height());		
		scale->setPaletteBackgroundPixmap(pix);
		}
	}
		
QwtPlotCanvas *plotCanvas = plot->canvas();
QRect cRect=plotLayout->canvasRect ();
pix = QPixmap::grabWidget (canvas,x+cRect.x(),y+cRect.y(),cRect.width(), cRect.height());	
plotCanvas->setPaletteBackgroundPixmap(pix);

plot->replot();
}	
コード例 #5
0
ファイル: PlotCurve.cpp プロジェクト: mantidproject/mantid
/// Compute curve offsets for a curve in a waterfall plot.
/// @param xDataOffset :: Output value of an x-offset that should be applied to
///   the data's bounding rect to fit to a waterfall plot.
/// @param yDataOffset :: Output value of an y-offset that should be applied to
///   the data's bounding rect to fit to a waterfall plot.
void PlotCurve::computeWaterfallOffsets(double &xDataOffset,
                                        double &yDataOffset) {
  Plot *plot = static_cast<Plot *>(this->plot());
  Graph *g = static_cast<Graph *>(plot->parent());

  // Reset the offsets
  // These are offsets of the curve in pixels on the screen.
  d_x_offset = 0.0;
  d_y_offset = 0.0;

  if (g->isWaterfallPlot()) {
    int index = g->curveIndex(this);
    int curves = g->curves();
    auto firstCurve = g->curve(0);
    // Get the minimum value of the first curve in this plot
    double ymin = firstCurve ? firstCurve->minYValue() : 0.0;
    PlotCurve *c = dynamic_cast<PlotCurve *>(g->curve(0));
    if (index > 0 && c) {
      // Compute offsets based on the maximum value for the curve
      double xRange = plot->axisScaleDiv(Plot::xBottom)->range();
      double yRange = plot->axisScaleDiv(Plot::yLeft)->range();

      // First compute offsets in a linear scale
      xDataOffset =
          index * g->waterfallXOffset() * 0.01 * xRange / (double)(curves - 1);
      yDataOffset =
          index * g->waterfallYOffset() * 0.01 * yRange / (double)(curves - 1);

      // Corresponding offset on the screen in pixels
      d_x_offset = plot->canvas()->width() * xDataOffset / xRange;
      d_y_offset = plot->canvas()->height() * yDataOffset / yRange;

      // Correct the data offsets using actual axis scales. If the scales are
      // non-linear the offsets will change.
      { // x-offset
        auto trans = plot->axisScaleEngine(Plot::xBottom)->transformation();
        auto a =
            trans->xForm(g->curve(0)->maxXValue(),
                         plot->axisScaleDiv(Plot::xBottom)->lowerBound(),
                         g->curve(0)->maxXValue(), 0, plot->canvas()->width());
        auto b = trans->invXForm(a + d_x_offset, 0, plot->canvas()->width(), 1,
                                 g->curve(0)->maxXValue());
        xDataOffset = b - g->curve(0)->maxXValue();
      }

      { // y-offset
        auto trans = plot->axisScaleEngine(Plot::yLeft)->transformation();
        auto a =
            trans->xForm(g->curve(0)->maxYValue(),
                         plot->axisScaleDiv(Plot::yLeft)->lowerBound(),
                         g->curve(0)->maxYValue(), 0, plot->canvas()->height());
        auto b = trans->invXForm(a + d_y_offset, 0, plot->canvas()->height(), 1,
                                 g->curve(0)->maxYValue());
        yDataOffset = b - g->curve(0)->maxYValue();
      }
      // Set the z-order of the curves such that the first curve is on top.
      setZ(-index);
      // Fill down to minimum value of first curve
      setBaseline(ymin - yDataOffset);

    } else {
      // First curve - no offset.
      setZ(0);
      setBaseline(ymin); // This is for when 'fill under curve' is turn on
      xDataOffset = 0.0;
      yDataOffset = 0.0;
    }
    if (g->grid())
      g->grid()->setZ(-g->curves() /*Count()*/ - 1);
  }
}
コード例 #6
0
ファイル: Plots.cpp プロジェクト: ablwr/qctools
//---------------------------------------------------------------------------
Plots::Plots( QWidget *parent, FileInformation* fileInformation ) :
    QWidget( parent ),
    m_zoomFactor ( 0 ),
    m_fileInfoData( fileInformation ),
    m_dataTypeIndex( Plots::AxisSeconds )
{
    setlocale(LC_NUMERIC, "C");
    QGridLayout* layout = new QGridLayout( this );
    layout->setSpacing( 1 );
    layout->setContentsMargins( 0, 0, 0, 0 );

    // bottom scale
    m_scaleWidget = new PlotScaleWidget();
    m_scaleWidget->setFormat( Plots::AxisTime );
    setVisibleFrames( 0, numFrames() - 1 );

    // plots and legends
    m_plots = new Plot**[m_fileInfoData->Stats.size()];
    m_plotsCount = 0;
    
    for ( size_t streamPos = 0; streamPos < m_fileInfoData->Stats.size(); streamPos++ )
    {
        if (m_fileInfoData->Stats[streamPos])
        {
            size_t type = m_fileInfoData->Stats[streamPos]->Type_Get();
            size_t countOfGroups = PerStreamType[type].CountOfGroups;
        
            m_plots[streamPos] = new Plot*[countOfGroups + 1]; //+1 for axix
    
            for ( size_t group = 0; group < countOfGroups; group++ )
            {
                if (m_fileInfoData->ActiveFilters[PerStreamType[type].PerGroup[group].ActiveFilterGroup])
                {
                    Plot* plot = new Plot( streamPos, type, group, fileInformation, this );
                    plot->addGuidelines(m_fileInfoData->BitsPerRawSample());

                    if(type == Type_Video)
                        adjustGroupMax(group, m_fileInfoData->BitsPerRawSample());

                    // we allow to shrink the plot below height of the size hint
                    plot->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Expanding );
                    plot->setAxisScaleDiv( QwtPlot::xBottom, m_scaleWidget->scaleDiv() );
                    initYAxis( plot );
                    updateSamples( plot );

                    connect( plot, SIGNAL( cursorMoved( int ) ), SLOT( onCursorMoved( int ) ) );

                    plot->canvas()->installEventFilter( this );

                    layout->addWidget( plot, m_plotsCount, 0 );
                    layout->addWidget( plot->legend(), m_plotsCount, 1 );

                    m_plots[streamPos][group] = plot;

                    m_plotsCount++;

                    qDebug() << "g: " << plot->group() << ", t: " << plot->type() << ", m_plotsCount: " << m_plotsCount;
                }
                else
                {
                    m_plots[streamPos][group] = NULL;
                }
            }
        }
        else
        {
            m_plots[streamPos]=NULL;
        }
    }

    layout->addWidget( m_scaleWidget, m_plotsCount, 0, 1, 2 );

    // combo box for the axis format
    XAxisFormatBox* xAxisBox = new XAxisFormatBox();
    xAxisBox->setCurrentIndex( Plots::AxisTime );
    connect( xAxisBox, SIGNAL( currentIndexChanged( int ) ),
        this, SLOT( onXAxisFormatChanged( int ) ) );

    int axisBoxRow = layout->rowCount() - 1;
#if 1
    // one row below to have space enough for bottom scale tick labels
    layout->addWidget( xAxisBox, m_plotsCount + 1, 1 );
#else
    layout->addWidget( xAxisBox, layout_y, 1 );
#endif

    layout->setColumnStretch( 0, 10 );
    layout->setColumnStretch( 1, 0 );

    m_scaleWidget->setScale( m_timeInterval.from, m_timeInterval.to);

    setCursorPos( framePos() );
}