void MainWindow::setupPlot()
{
    plotTimer.setInterval(1000/settingsDialog->rate);
    connect(&plotTimer, SIGNAL(timeout()), this, SLOT(plotUpdate()));
    plotTimer.start();

    if (!ui->plot->legend()) {
        QwtLegend* legend = new QwtLegend;
        legend->setItemMode(QwtLegend::CheckableItem);
        ui->plot->insertLegend(legend, QwtPlot::RightLegend);
    }

    ui->plot->setAxisTitle(QwtPlot::xBottom, "seconds");
    ui->plot->setCanvasBackground(Qt::white);

    QColor gridColor;
    gridColor.setNamedColor("grey");
    QPen gridPen(gridColor);
    gridPen.setStyle(Qt::DotLine);
    QwtPlotGrid* grid = new QwtPlotGrid;
    grid->setMajPen(gridPen);
    grid->attach(ui->plot);

    connect(ui->plot, SIGNAL(legendChecked(QwtPlotItem*,bool)), this, SLOT(showCurve(QwtPlotItem*,bool)));
}
Example #2
0
DataPlotFFT::DataPlotFFT(QWidget *parent):
    QwtPlot(parent),
    d_data(NULL),
    d_curve(NULL)
{
    setAutoReplot(false);

    setFrameStyle(QFrame::NoFrame);
    setLineWidth(0);
    setCanvasLineWidth(2);

    //plotLayout()->setAlignCanvasToScales(true);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach(this);

    setCanvasBackground(Qt::white);
    //setCanvasBackground(QColor(29, 100, 141)); // nice blue

    //setAxisAutoScale(xBottom);
    //s/etAxisAutoScale(yLeft);

    setAxisScale(xBottom, 0.5, -0.5);
    setAxisScale(yLeft, -10.00, 10.00);
    setAxisAutoScale(yLeft);
    //setAxisAutoScale(xBottom);

    replot();
}
Example #3
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QwtPlot plot;
    plot.setCanvasBackground(QColor(Qt::white));
    plot.setTitle("Bar Chart");

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableX(false);
	grid->enableYMin(true);
	grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
	grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
	grid->attach(&plot);

	BarChartItem *item = new BarChartItem();
	item->attach(&plot);
	QList< QPair<int, QString> > barHeights;
	barHeights.append(QPair<int, QString>(10, ""));
	barHeights.append(QPair<int, QString>(100, ""));
	barHeights.append(QPair<int, QString>(20, ""));
	item->setData(barHeights);

	plot.enableAxis(QwtPlot::xBottom, false);

	plot.resize(600, 400);
	plot.show();

	return app.exec();
}
Example #4
0
RandomPlot::RandomPlot(QWidget *parent):
    IncrementalPlot(parent),
    d_timer(0),
    d_timerCount(0)
{
    setFrameStyle(QFrame::NoFrame);
    setLineWidth(0);
    setCanvasLineWidth(2);

    plotLayout()->setAlignCanvasToScales(true);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach(this);

    setCanvasBackground(QColor(29, 100, 141)); // nice blue

    setAxisScale(xBottom, 0, c_rangeMax);
    setAxisScale(yLeft, 0, c_rangeMax);
    
    replot();

    // enable zooming

    (void) new Zoomer(canvas());
}
Example #5
0
void HistPlot::populate()
{
	setTitle("Watching TV during a weekend");
	setAxisTitle(QwtPlot::yLeft, "Number of People");
	setAxisTitle(QwtPlot::xBottom, "Number of Hours");

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableX(false);
	grid->enableY(true);
	grid->enableXMin(false);
	grid->enableYMin(false);
	grid->setMajPen(QPen(Qt::black, 0, Qt::SolidLine));
	grid->attach(this);

	const double juneValues[] = { 7, 19, 24, 32, 10, 5, 3 };
	const double novemberValues[] = { 4, 15, 22, 34, 13, 8, 4 };

	Histogram *histogramJune = new Histogram("Summer", Qt::red);
	histogramJune->setValues(
		sizeof(juneValues) / sizeof(double), juneValues);
	histogramJune->attach(this);

	Histogram *histogramNovember = new Histogram("Winter", Qt::blue);
	histogramNovember->setValues(
		sizeof(novemberValues) / sizeof(double), novemberValues);
	histogramNovember->attach(this);
}
EcgCh::EcgCh(QWidget *parent) :
    QwtPlot(parent)
{
     setMinimumHeight(10);
     setMinimumWidth(10);
     QwtPlotGrid *grid = new QwtPlotGrid;
     grid->enableXMin(true);
     grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
     grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
     grid->attach(this);
     setAxisTitle(QwtPlot::xBottom, "Czas [s]");
     setAxisTitle(QwtPlot::yLeft, "Amplituda [mv]");
//     picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas());
//     picker->setStateMachine(new QwtPickerDragPointMachine());
//     picker->setRubberBandPen(QColor(Qt::green));
//     picker->setRubberBand(QwtPicker::CrossRubberBand);
//     picker->setTrackerPen(QColor(Qt::white));
     curve = new QwtPlotCurve("signal");
     curve->setYAxis(QwtPlot::yLeft);
     curve->attach(this);
     peaksCurve = new QwtPlotCurve("signal");
     peaksCurve->setYAxis(QwtPlot::yLeft);
     peaksCurve->setStyle(QwtPlotCurve::CurveStyle::Dots);
     peaksCurve->setPen(QPen(Qt::red, 5));
     peaksCurve->attach(this);
     samples = new QVector<QPointF>;
     data = new QwtPointSeriesData;
     peaksSamples = new QVector<QPointF>;
     peaksData = new QwtPointSeriesData;
     replot();
}
Example #7
0
SimDialog::SimDialog( QWidget * parent, Qt::WFlags f) 
	: QDialog(parent, f)
{
  setupUi(this);

  // setup the plot ...
  m_plot->setTitle("Comparing Similarity Measures");
  m_plot->insertLegend(new QwtLegend(), QwtPlot::BottomLegend);

  // set up the axes ...
  m_plot->setAxisTitle(QwtPlot::xBottom, "Variations");
  m_plot->setAxisScale(QwtPlot::xBottom, -10, 10);

  m_plot->setAxisTitle(QwtPlot::yLeft, "Similarity");
  m_plot->setAxisScale(QwtPlot::yLeft, -1.5, 1.5);

  // enable grid ...
  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);

  //  Insert zero line at y = 0
  QwtPlotMarker *mY = new QwtPlotMarker();
  mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
  mY->setLineStyle(QwtPlotMarker::HLine);
  mY->setYValue(0.0);
  mY->attach(m_plot);

  //  Insert zero line at x = 0
  QwtPlotMarker *mX = new QwtPlotMarker();
  mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
  mX->setLineStyle(QwtPlotMarker::VLine);
  mX->setXValue(0.0);
  mX->attach(m_plot);

  // Insert new curves
  cReg = new QwtPlotCurve("Regular Similarity Measure");
  cReg->attach(m_plot);

  cOct = new QwtPlotCurve("Octree based Similarity Measure");
  cOct->attach(m_plot);

  // Set curve styles
  cReg->setPen(QPen(Qt::red, 2));
  cOct->setPen(QPen(Qt::blue, 2));

  // Populate the volume combos ...
  MainWindow* _win  = (MainWindow *)this->parent();
  viewer3d *  _view = (viewer3d *) _win->getViewer();
  QList<Volume*> _vols = _view->getVolumes();

  // append Volume names to combo boxes ...
  // Need to modify Volume class so that it stored patient name ...
  // More importantly modify PatientBrowser so that the data can be directly
  // loaded.
}
Example #8
0
StPlot::StPlot(QWidget* parent): 
  QwtPlot(parent),
  viewFactor(-1.0)
{
  setMinimumHeight(10);
  setMinimumWidth(10);
  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
  grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(this);
  setAxisTitle(QwtPlot::xBottom, "Czas [s]");
  setAxisTitle(QwtPlot::yLeft, "Amplituda [mv]");
  
  curve = new QwtPlotCurve("Filtered signal");
  curve->setYAxis(QwtPlot::yLeft);
  curve->attach(this);

  ISOPoints = new QwtPlotCurve("ISO");
  ISOPoints->setStyle(QwtPlotCurve::NoCurve);
  ISOPoints->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(Qt::green), QColor(Qt::green), QSize(5, 5)));
  ISOPoints->setYAxis(QwtPlot::yLeft);
  ISOPoints->attach(this);
  
  JPoints = new QwtPlotCurve("J");
  JPoints->setStyle(QwtPlotCurve::NoCurve);
  JPoints->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(Qt::blue), QColor(Qt::blue), QSize(5, 5)));
  JPoints->setYAxis(QwtPlot::yLeft);
  JPoints->attach(this);
  
  STPoints = new QwtPlotCurve("ST");
  STPoints->setStyle(QwtPlotCurve::NoCurve);
  STPoints->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(Qt::red), QColor(Qt::red), QSize(5, 5)));
  STPoints->setYAxis(QwtPlot::yLeft);
  STPoints->attach(this);

  RPoints = new QwtPlotCurve("R");
  RPoints->setStyle(QwtPlotCurve::NoCurve);
  RPoints->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(Qt::yellow), QColor(Qt::yellow), QSize(5, 5)));
  RPoints->setYAxis(QwtPlot::yLeft);
  //RPoints->attach(this);

  legend = new QwtLegend();
  legend->setItemMode(QwtLegend::ReadOnlyItem);
  legend->setWhatsThis("Click on an item to show/hide the plot");
  this->insertLegend(legend, QwtPlot::RightLegend);
  
  samples = new QVector<QPointF>;
  data = new QwtPointSeriesData;
  replot();
  
  zoomer = new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, canvas());
  zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
  zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton);
  zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
  zoomer->setMousePattern(QwtEventPattern::MouseSelect4, Qt::NoButton);
  zoomer->setMousePattern(QwtEventPattern::MouseSelect5, Qt::NoButton);
  zoomer->setMousePattern(QwtEventPattern::MouseSelect6, Qt::NoButton);
}
// Init X axis.
void DataPlot::setGridPlot()
{
    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(this);
}
Example #10
0
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 &)));
}
void GenericHistogramView::populate()
{
  QwtPlotGrid* grid = new QwtPlotGrid();
  grid->enableX(false);
  grid->enableY(true);
  grid->enableXMin(false);
  grid->enableYMin(false);
  grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->attach(_qwtPlot);

	for(unsigned int i = 0; i < _image->getNbChannels(); ++i)
	{
		imagein::Array<unsigned int>* histogram;
		if(_projection)
			histogram = new imagein::ProjectionHistogram(*_image, _value, _horizontal, *_rectangle, i);
		else
			histogram = new imagein::Histogram(*_image, i, *_rectangle);
		
		int values[histogram->getWidth()];

		for(unsigned int j = 0; j < histogram->getWidth(); ++j)
			values[j] = (*histogram)[j];
		
		GraphicalHistogram* graphicalHisto;
		switch(i)
		{
			case 0:
				if(_image->getNbChannels() == 1 || _image->getNbChannels() == 2)
					graphicalHisto = new GraphicalHistogram("Black", Qt::black);
				else
					graphicalHisto = new GraphicalHistogram("Red", Qt::red);
			break;
			case 1:
				if(_image->getNbChannels() == 1 || _image->getNbChannels() == 2)
					graphicalHisto = new GraphicalHistogram("Alpha", Qt::white);
				else
					graphicalHisto = new GraphicalHistogram("Green", Qt::green);
			break;
			case 2:
				graphicalHisto = new GraphicalHistogram("Blue", Qt::blue);
			break;
			case 3:
				graphicalHisto = new GraphicalHistogram("Alpha", Qt::black);
			break;
			default:
				graphicalHisto = new GraphicalHistogram("Default", Qt::black);
		}
		graphicalHisto->setValues(sizeof(values) / sizeof(int), values);
		if(_horizontal)
			graphicalHisto->setOrientation(Qt::Horizontal);
		graphicalHisto->attach(_qwtPlot);
    _graphicalHistos.push_back(graphicalHisto);
	}
}
Example #12
0
RTVTPlotWindow::RTVTPlotWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::RTVTPlotWindow)
{
    ui->setupUi(this);

    connect(ui->plotChannelListView, SIGNAL(clicked(QModelIndex)), this, SLOT(curveSelected(QModelIndex)));
    // Setup curves
    numberOfCurves = 10;
    startColorIndex = 0;
    channelListStringModel = new QStringListModel();
    channelListStringModel->setStringList(channelStringList);
    ui->plotChannelListView->setModel(channelListStringModel);

    // Setup the plot view
    ui->plotQwtView->setCanvasBackground(QColor(Qt::darkBlue));
    ui->plotQwtView->setTitle("Frequency Response of Amplifier");
    ui->plotQwtView->setTitle("Amplitude");
    ui->plotQwtView->setAxisTitle(QwtPlot::yLeft,"dBm");
    ui->plotQwtView->setAxisTitle(QwtPlot::xBottom,"Frequency (Hz)");

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
    grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
    grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
    grid->attach(ui->plotQwtView);

    ui->plotQwtView->setAxisMaxMajor(QwtPlot::xBottom, 6);
    ui->plotQwtView->setAxisMaxMinor(QwtPlot::xBottom, 10);
    ui->plotQwtView->setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine);

    //QwtPlotGrid *gridy = new QwtPlotGrid();
    //gridy->attach(ui->plotQwtView);


    /*QwtLog10ScaleEngine * log10SE = new QwtLog10ScaleEngine();
    double x1=0.0, x2=4.3, stepSize=0.1;

    log10SE->autoScale(100, x1, x2, stepSize);

    QwtLinearScaleEngine * yAxisEngine = new  QwtLinearScaleEngine();
    double y1=-100.0, y2 = 10.0, yStep = 10.0;

    yAxisEngine->autoScale(10, y1, y2, yStep);*/

    //ui->plotQwtView->setAxisScaleEngine(QwtPlot::xBottom,log10SE);
    //ui->plotQwtView->setAxisScaleEngine(QwtPlot::yLeft,yAxisEngine);

    //ui->plotQwtView->setAxis

    ui->plotQwtView->replot();

}
Example #13
0
MavPlot::MavPlot(QWidget *parent) : QwtPlot(parent), _havePrintColors(false) {
    setAutoReplot(false);
    setTitle("MAV System Data Plot");
    setCanvasBackground(QColor(Qt::darkGray));

    // legend
    QwtLegend *legend = new QwtLegend;
    insertLegend(legend, QwtPlot::BottomLegend);
    #if (QWT_VERSION < QWT_VERSION_CHECK(6,1,0))
        legend->setItemMode(QwtLegend::ClickableItem);
        connect(this, SIGNAL(legendClicked(QwtPlotItem*)), SLOT(legendClicked(QwtPlotItem*)));
    #else
        legend->setDefaultItemMode(QwtLegendData::Clickable);        
        connect(legend, SIGNAL(clicked(const QVariant&, int)), SLOT(legendClickedNew(const QVariant&, int)));
    #endif    

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
    #if (QWT_VERSION < QWT_VERSION_CHECK(6,1,0))
        grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
        grid->setMinPen(QPen(QColor(0x8, 0x8, 0x8), 0 , Qt::DotLine));
    #else
        grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
        grid->setMinorPen(QPen(QColor(0x8, 0x8, 0x8), 0 , Qt::DotLine));
    #endif
    grid->attach(this);

    // axes
    //enableAxis(QwtPlot::yRight);
    setAxisTitle(QwtPlot::xBottom, "time");
    setAxisScaleDraw(QwtPlot::xBottom, new HumanReadableTime()); // no need to de-alloc or store, plot does it

    // A-B markers
    for (int i=0; i<2; i++) {
        _user_markers[i].setLineStyle(QwtPlotMarker::VLine);
        _user_markers[i].setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
        _user_markers[i].setLinePen(QPen(QColor(255, 140, 0), 0, Qt::SolidLine));
        _user_markers_visible[i] = false;
    }
    _user_markers[0].setLabel(QwtText("A"));
    _user_markers[1].setLabel(QwtText("B"));

    // data marker
    _data_marker.setLineStyle(QwtPlotMarker::VLine);
    _data_marker.setLinePen(QPen(QColor(255, 160, 47), 2, Qt::SolidLine));
    _data_marker.setLabel(QwtText("data"));
    _data_marker.setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
    _data_marker_visible = false;
    _data_marker.setZ(9999); // higher value -> paint on top of everything else

    setAutoReplot(true);
}
Example #14
0
int qfit::setupGui()
{
//   if(QApplication::arguments().size() > 1)
//     filePath->setText(QApplication::arguments().at(1));
    if(QApplication::argc() == 2) {
        filePath->setText(QApplication::argv()[1]);
    }
    selectFit->addItem(tr("Fit Linear"));/*TODO add once are available in FitTools
  selectFit->addItem(tr("Fit Slope"));
  selectFit->addItem(tr("Fit Horizontal"));
  selectFit->addItem(tr("Fit Exponential"));
  selectFit->addItem(tr("Fit Logarithmic"));*/

#ifdef Qwt6_FOUND
    // plot stuff
    // panning with the middle mouse button
    QwtPlotPanner *panner = new QwtPlotPanner(qwtPlot->canvas());
    panner->setMouseButton(Qt::MidButton);
    // zoom in/out with the wheel
    (void) new QwtPlotMagnifier(qwtPlot->canvas());
    // zoom an area with left button
    QwtPlotZoomer *zoomer = new QwtPlotZoomer(qwtPlot->canvas());
    zoomer->setRubberBandPen(QColor(Qt::black));
    zoomer->setTrackerPen(QColor(Qt::black));
    zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
    zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);

    // canvas
    qwtPlot->canvas()->setLineWidth(1);
    qwtPlot->canvas()->setFrameStyle(QFrame::Box | QFrame::Plain);
    qwtPlot->canvas()->setBorderRadius(10);
    qwtPlot->canvas()->setPalette(Qt::darkGray);
    //grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
//   grid->setMinPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach(qwtPlot);
#endif

    // tooltips
    infoButton->setToolTip(trUtf8("About"));
    openFileButton->setToolTip(trUtf8("Open file"));
    selectFit->setToolTip(trUtf8("Fit typology"));
    startFit->setToolTip(trUtf8("GO!"));
    cleanLogButton->setToolTip(trUtf8("Clear log"));

#ifdef Qwt6_FOUND
    savePlotButton->setToolTip(trUtf8("Save plot"));
#endif

    return(0);
}
Example #15
0
int main(int argc, char **argv)
{
    QApplication a(argc, argv);

    QwtPlot plot;
    plot.setCanvasBackground(QColor(Qt::white));
    plot.setTitle("Histogram");

    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(&plot);

    HistogramItem *histogram = new HistogramItem();
    histogram->setColor(Qt::darkCyan);

    const int numValues = 20;

    QwtArray<QwtDoubleInterval> intervals(numValues);
    QwtArray<double> values(numValues);

    double pos = 0.0;
    for ( int i = 0; i < (int)intervals.size(); i++ )
    {
        const int width = 5 + rand() % 15;
        const int value = rand() % 100;

        intervals[i] = QwtDoubleInterval(pos, pos + double(width));
        values[i] = value; 

        pos += width;
    }

    histogram->setData(QwtIntervalData(intervals, values));
    histogram->attach(&plot);

    plot.setAxisScale(QwtPlot::yLeft, 0.0, 100.0);
    plot.setAxisScale(QwtPlot::xBottom, 0.0, pos);
    plot.replot();

#if QT_VERSION < 0x040000
    a.setMainWidget(&plot);
#endif

    plot.resize(600,400);
    plot.show();

    return a.exec(); 
}
Example #16
0
void AnalogGraph::populate()
{
    QwtPlotGrid *grid = new QwtPlotGrid;

    grid->enableX(false);
    grid->enableY(false);
    grid->enableXMin(false);
    grid->enableYMin(false);
    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));

    grid->attach(this);

    analogHistogram_ = new Histogram("", QColor(80, 180, 220, 150));
    //analogHistogram_->setValues(analogChannels_);
    analogHistogram_->attach(this);
}
Example #17
0
TempCompCurve::TempCompCurve(QWidget *parent) :
    QwtPlot(parent), dataCurve(NULL), fitCurve(NULL)
{
    setMouseTracking(true);

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

    setCanvasBackground(QColor(64, 64, 64));

    //Add grid lines
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::gray, 0, Qt::DashLine));
    grid->setMinPen(QPen(Qt::lightGray, 0, Qt::DotLine));
    grid->setPen(QPen(Qt::darkGray, 1, Qt::DotLine));
    grid->attach(this);
}
Example #18
0
HarmPlot::HarmPlot(const QString& aDir, IRInfo anIi, QWidget *parent) throw (QLE) : QwtPlot(parent)
{
    this->setAttribute(Qt::WA_DeleteOnClose);

    this->dir = aDir;
    this->ii = anIi;

    this->data = (HarmData**) new char[sizeof(HarmData*) * (MAX_HARM - 1)];

    this->setAutoReplot(false);
    this->setCanvasBackground(BG_COLOR);

    this->setAxisScale(QwtPlot::yLeft, -120.0, 20.0);
    this->setAxisMaxMajor(QwtPlot::yLeft, 7);
    this->setAxisMaxMinor(QwtPlot::yLeft, 10);

    this->setAxisMaxMajor(QwtPlot::xBottom, 6);
    this->setAxisMaxMinor(QwtPlot::xBottom, 10);
#if QWT_VERSION > 0x060000
    QwtLogScaleEngine* logEngine = new QwtLogScaleEngine(10.0);
#else
    QwtLog10ScaleEngine* logEngine = new QwtLog10ScaleEngine();
#endif
    this->setAxisScaleEngine(QwtPlot::xBottom, logEngine);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
#if QWT_VERSION > 0x060000
    grid->setMajorPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinorPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#else
    grid->setMajPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#endif
    grid->attach(this);

    this->addCurves();

    QwtPlotPanner* panner = new QwtPlotPanner(this->canvas());
    panner->setMouseButton(Qt::MidButton);
    panner->setEnabled(true);

    this->setAutoReplot(true);

}
Example #19
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    m_pPlotWidget = ui->plotWidget;
    m_pPlotWidget->setMargin(4);

    m_pPlotWidget->updateLayout();


    m_pPlotWidget->setFrameStyle(QFrame::NoFrame);
    m_pPlotWidget->setLineWidth(0);
    m_pPlotWidget->setCanvasLineWidth(2);


    m_pPlotWidget->plotLayout()->setAlignCanvasToScales(true);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
    grid->attach( m_pPlotWidget);

    m_pPlotWidget->setCanvasBackground(QColor(60, 60, 60));

    m_pPlotWidget->setAxisScale(m_pPlotWidget->xBottom, 0, 10);
    m_pPlotWidget->setAxisScale(m_pPlotWidget->yLeft, 0, 100);

    m_pPlotWidget->replot();



    tcpSocket = NULL;
    tcpServer = new QTcpServer(this);
    if (!tcpServer->listen(QHostAddress::Any, 12345))
    {
        QMessageBox::critical(this, "ResourceViewer",
            "Unable to start the server: " + tcpServer->errorString());
    }
    connect(tcpServer, SIGNAL(newConnection()), this, SLOT(OnNewConnection()));

    qDebug()<< "Starting";
}
Example #20
0
void HistPlot::setValueHist(const vector<double>& histogram, int origin)
{
	setTitle("Histogram");
	setAxisTitle(QwtPlot::yLeft, "Count");
	setAxisTitle(QwtPlot::xBottom, "Value");

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableX(false);
	grid->enableY(true);
	grid->enableXMin(false);
	grid->enableYMin(false);
	grid->setMajPen(QPen(Qt::darkGreen, 0, Qt::SolidLine));
	grid->attach(this);

	Histogram *histogramJune = new Histogram("Summer", Qt::red);
	histogramJune->setValues(
		histogram.size(), &histogram[0], origin);
	histogramJune->attach(this);
}
PowerBarHistoryPlot::PowerBarHistoryPlot(double defaultTime, double defaultPowerLevel, QWidget* parent)
	: QWidget(parent)
	, m_overalTime(0.0)
	, m_lastSampleTime(0.0)
	, m_firstTime(true)
	, m_defaultTime(defaultTime)
	, m_defaultPowerLevel(defaultPowerLevel)
	, m_powerAxisMax(defaultPowerLevel)
	, m_powerAxisMin(-1*defaultPowerLevel)
	, m_timeAxisMax(defaultTime)
{
	m_plot = new QwtPlot();
	m_plot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
	m_plot->setAxisScale(QwtPlot::xBottom, 0, defaultTime, defaultTime/20.0);
	m_plot->setAxisScale(QwtPlot::yLeft, -1 * defaultPowerLevel, defaultPowerLevel, defaultPowerLevel/2.0);
	m_plot->setAxisAutoScale(QwtPlot::xBottom, false);
	m_plot->setCanvasBackground(QBrush(Qt::white));
	m_plot->setAxisTitle(QwtPlot::xBottom, tr(TIME_AXIS_NAME));
	m_plot->setAxisTitle(QwtPlot::yLeft, tr(POWER_AXIS_NAME));
	
	// legend
	QwtLegend *legend = new QwtLegend;
	legend->setFrameStyle(QFrame::Box|QFrame::Sunken);
	m_plot->insertLegend(legend, QwtPlot::BottomLegend);

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableX(false);
	grid->enableYMin(true);
	grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
	grid->setMinPen(QPen(Qt::transparent, 0 , Qt::NoPen));
	grid->attach(m_plot);

	setupCurves();

	QHBoxLayout* historyPlotlayout = new QHBoxLayout;
	historyPlotlayout->addWidget(m_plot);
	historyPlotlayout->setSpacing(0);

	setColors(Qt::blue, Qt::red);

	setLayout(historyPlotlayout);
}
Example #22
0
BasicPlot::BasicPlot(QWidget *parent) :
  QwtPlot(parent)
{
  setFrameStyle(QFrame::NoFrame);
  setLineWidth(0);
  setCanvasLineWidth(2);
  plotLayout()->setAlignCanvasToScales(true);
  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
  grid->attach(this);
  setCanvasBackground(QColor(29, 100, 141)); // nice blue

  // enable zooming
  Zoomer *zoomer = new Zoomer(canvas());
  zoomer->setRubberBandPen(QPen(Qt::white, 2, Qt::DotLine));
  zoomer->setTrackerPen(QPen(Qt::white));
  QObject::connect(this, SIGNAL(setNewBase(QwtScaleDiv*,QwtScaleDiv*)), zoomer,
      SLOT(setNewBase(QwtScaleDiv*,QwtScaleDiv*)));

}
Example #23
0
PlotHRT::PlotHRT(QWidget *parent) :
    QwtPlot(parent)
{
	setMinimumHeight(10);
	setMinimumWidth(10);
	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableXMin(true);
	grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
	grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
	grid->attach(this);
	setAxisTitle(QwtPlot::xBottom, "relative interval number");
	setAxisTitle(QwtPlot::yLeft, "RR [ms]");
	rr = new QwtPlotCurve("RR");
	ts = new QwtPlotCurve("TS");
	ts->setPen(QPen(Qt::red, 2));
	rr->setYAxis(QwtPlot::yLeft);
	ts->setYAxis(QwtPlot::yLeft);
	rr->attach(this);
	ts->attach(this);
	replot();
}
Example #24
0
IRPlot::IRPlot(const QString& aDir, IRInfo anIi, QWidget *parent) throw (QLE) : QwtPlot(parent)
{
    this->dir = aDir;
    this->ii = anIi;

    this->time = 0;
    this->amps = 0;

    this->setAutoReplot(false);
    this->setCanvasBackground(BG_COLOR);

    unsigned curveLength = this->calculate();

    this->setAxisScale( xBottom, this->time[0], this->time[curveLength-1]);
    this->setAxisAutoScale( xBottom);
    this->setAxisScale( yLeft, -1.5, 1.5);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
#if QWT_VERSION > 0x060000
    grid->setMajorPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinorPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#else
    grid->setMajPen(QPen(MAJ_PEN_COLOR, 0, Qt::DotLine));
    grid->setMinPen(QPen(MIN_PEN_COLOR, 0 , Qt::DotLine));
#endif
    grid->attach(this);

    QwtPlotCurve* ampCurve = new QwtPlotCurve("IR_Plot");
    ampCurve->setPen(QPen(AMP_CURVE_COLOR));
    ampCurve->setYAxis(QwtPlot::yLeft);
    ampCurve->attach(this);
    ampCurve->setSamples(this->time, this->amps, curveLength);

    QwtPlotPanner* panner = new QwtPlotPanner(this->canvas());
    panner->setMouseButton(Qt::MidButton);
    panner->setEnabled(true);

    this->setAutoReplot(true);
}
Example #25
0
MainWindow::MainWindow():
    PlotMatrix(3, 4)
{
    enableAxis(QwtPlot::yLeft);
    enableAxis(QwtPlot::yRight);
    enableAxis(QwtPlot::xBottom);

    for ( int row = 0; row < numRows(); row++ )
    {
        const double v = qPow(10.0, row);
        setAxisScale(QwtPlot::yLeft, row, -v, v);
        setAxisScale(QwtPlot::yRight, row, -v, v);
    }

    for ( int col = 0; col < numColumns(); col++ )
    {
        const double v = qPow(10.0, col);
        setAxisScale(QwtPlot::xBottom, col, -v, v);
        setAxisScale(QwtPlot::xTop, col, -v, v);
    }

    for ( int row = 0; row < numRows(); row++ )
    {
        for ( int col = 0; col < numColumns(); col++ )
        {
            QwtPlot *plt = plot(row, col);
            plt->setCanvasBackground(QColor(Qt::darkBlue));

            QwtPlotGrid *grid = new QwtPlotGrid();
            grid->enableXMin(true);
            grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
            grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
            grid->attach(plt);
        }
    }
}
//---------------------------------------------------------------------------
JrkPlotDialog::JrkPlotDialog(jrk_variables *indata, jrk_pid_variables *pid_indata, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::JrkPlotDialog)
{
    int i;

    ui->setupUi(this);
    setLayout(ui->mainLayout);

    interval(200);
    history(10);
    setSamples();

    data_ptr = indata;
    pid_data_ptr = pid_indata;

    timeData = (double *) malloc(SAMPLES * sizeof(double));
    reset();

    ui->jrkPlot->setAutoReplot(false);
    ui->jrkPlot->canvas()->setBorderRadius(0);
    ui->jrkPlot->plotLayout()->setAlignCanvasToScales(true);
    ui->jrkPlot->setCanvasBackground(Qt::white);

    QwtLegend *legend = new QwtLegend;
    legend->setItemMode(QwtLegend::CheckableItem);
    ui->jrkPlot->insertLegend(legend, QwtPlot::RightLegend);

    ui->jrkPlot->setAxisTitle(QwtPlot::xBottom, "Seconds");
    ui->jrkPlot->setAxisScale(QwtPlot::xBottom, timeData[0], timeData[SAMPLES - 1]);

//    ui->jrkPlot->setAxisLabelRotation( QwtPlot::xBottom, -50.0 );
    ui->jrkPlot->setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom );
    QwtScaleWidget *scaleWidget = ui->jrkPlot->axisWidget(QwtPlot::xBottom);
    i = QFontMetrics(scaleWidget->font()).height();
    scaleWidget->setMinBorderDist(0, i / 2);

    ui->jrkPlot->setAxisTitle(QwtPlot::yLeft, "%");
    ui->jrkPlot->setAxisScale(QwtPlot::yLeft, -100, 100);

    // picker, panner, zoomer
    plot_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                                    QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
                                    ui->jrkPlot->canvas());
#if 0
    plot_picker->setStateMachine(new QwtPickerDragPointMachine());
    plot_picker->setRubberBandPen(QColor(Qt::black));
    plot_picker->setRubberBand(QwtPicker::CrossRubberBand );
#endif
    plot_picker->setTrackerPen(QColor(Qt::black));

    // panning with the left mouse button
    plot_panner = new QwtPlotPanner(ui->jrkPlot->canvas());
    plot_panner->setUpdatesEnabled(true);

    // zoom in/out with the wheel
    plot_zoomer = new QwtPlotMagnifier(ui->jrkPlot->canvas());

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin( true );
    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
    grid->setMinPen(QPen(Qt::black, 0, Qt::DotLine));
    grid->attach(ui->jrkPlot);

    // curves, scale is in %
    createCurve("Input",                Qt::gray,           false,  4095);
    createCurve("Target",               Qt::blue,           false,  4095);
    createCurve("Feedback",             Qt::darkBlue,       false,  4095);
    createCurve("Scaled feedback",      Qt::magenta,        false,  4095);
    createCurve("Error",                Qt::red,            true,   4095);
    createCurve("Integral",             Qt::darkGreen,      false,  1000);
    createCurve("Derivative",           Qt::yellow,         false,  1000);
    createCurve("Duty cycle target",    Qt::darkCyan,       false,  0600);
    createCurve("Duty cycle",           Qt::darkRed,        false,  0600);
    createCurve("Current",              Qt::black,          true,   0050);

    plot_timer = new QTimer(this);
    plot_timer->setInterval(INTERVAL);

    connect(plot_timer, SIGNAL(timeout()), this, SLOT(onUpdateGraph()));
    connect(ui->jrkPlot, SIGNAL(legendChecked(QwtPlotItem *, bool)),
            SLOT(showCurve(QwtPlotItem *, bool)));

#if 0
    connect(plot_picker, SIGNAL(moved(const QPoint &)),
            SLOT(picker_moved(const QPoint &)));
    connect(plot_picker, SIGNAL(selected(const QPolygon &)),
            SLOT(picker_selected(const QPolygon &)));
#endif

    connect(this, SIGNAL(finished(int)), this, SLOT(onFinished(int)));

//    plot_timer->start();
}
Example #27
0
chooseCyclesForm::chooseCyclesForm(model* mainModelGiven, bool showAlreadyPrecalcedCycles){

	// open log file
	log.open("chooseCyclesForm.log");
	log << "constructor call" << std::endl;
	FFTSignal = NULL;
	justDeletedMaker = NULL;


	// attach ui form
	setupUi(this);


	mainModel = mainModelGiven;
	peakSignal = mainModel->givePeakSignal();
	// ask to evaluate peak signal
	//askMainModelToEvaluate();
	// and take it
	//peakSignal = mainModel->givePeakSignal();




	// peak signal plot
	qwtPlot_peakSignal->setAutoReplot(false);

	qwtPlot_peakSignal->setCanvasBackground(QColor(Qt::darkBlue));
	qwtPlot_peakSignal->setTitle("peak signal");
	qwtPlot_peakSignal->setAxisTitle(QwtPlot::xBottom, "FFT cycles");
	qwtPlot_peakSignal->setAxisTitle(QwtPlot::yLeft, "Amplitude");

	QwtLegend *legend = new QwtLegend;
    qwtPlot_peakSignal->insertLegend(legend, QwtPlot::BottomLegend);

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

	peakSignalCurve1 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	peakSignalCurve1->setPen(QPen(Qt::cyan));
	peakSignalCurve1->attach(qwtPlot_peakSignal);

	peakSignalCurve2 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	peakSignalCurve2->setPen(QPen(Qt::yellow));
	peakSignalCurve2->attach(qwtPlot_peakSignal);

	showPeakSignal1(0);
	showPeakSignal2(0);

	qwtPlot_peakSignal->setAutoReplot(true);
	// end of peak signal plot




	//FFTSignal
	qwtPlot_FFTCycle->setAutoReplot(false);

	qwtPlot_FFTCycle->setCanvasBackground(QColor(Qt::darkBlue));
	qwtPlot_FFTCycle->setTitle("FFT signal");
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::xBottom, "FFT beans");
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::yLeft, "Amplitude");
	
	/*
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::xTop, "FFT beans");
	QwtInterval interval = qwtPlot_FFTCycle->axisInterval(QwtPlot::xBottom);
	double left = interval.minValue();
	double right = interval.maxValue();
	qwtPlot_FFTCycle->setAxisScale(QwtPlot::xTop, left, right);
	*/

	QwtLegend *legendFFTSignal = new QwtLegend;
    qwtPlot_FFTCycle->insertLegend(legendFFTSignal, QwtPlot::BottomLegend);

	QwtPlotGrid *gridFFTSignal = new QwtPlotGrid;
	gridFFTSignal->enableXMin(true);
	gridFFTSignal->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
	gridFFTSignal->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
	gridFFTSignal->attach(qwtPlot_FFTCycle);

	FFTSignalCurve1 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	FFTSignalCurve1->setPen(QPen(Qt::cyan));
	FFTSignalCurve1->attach(qwtPlot_FFTCycle);

	FFTSignalCurve2 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	FFTSignalCurve2->setPen(QPen(Qt::yellow));
	FFTSignalCurve2->attach(qwtPlot_FFTCycle);

	qwtPlot_FFTCycle->setAutoReplot(true);
	// end of FFT signal plot



	// zoomer and picker and smth else
	// recreare zoomer each time we get new data in the plot
	reCreateZoomer();
	reCreateZoomer2nd();
	// end of zoomer and picker and smth else




	// toolbar
	QToolBar *toolBar = new QToolBar(this);




	// zoom button
    btnZoom = new QToolButton(toolBar);
    btnZoom->setText("Zoom");
    btnZoom->setIcon(QIcon(zoom_xpm));
    btnZoom->setCheckable(true);
    btnZoom->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    toolBar->addWidget(btnZoom);
    connect(btnZoom, SIGNAL(toggled(bool)), SLOT(enableZoomMode(bool)));
	// end of zoom button

	// zoom button 2nd
    toolButton_zoom2nd->setText("Zoom");
    toolButton_zoom2nd->setIcon(QIcon(zoom_xpm));
    toolButton_zoom2nd->setCheckable(true);
    toolButton_zoom2nd->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    connect(toolButton_zoom2nd, SIGNAL(toggled(bool)), SLOT(enableZoomMode2nd(bool)));
	// end of zoom button 2nd




	// marker
	peakSignalMarker = new QwtPlotMarker();
	peakSignalMarker->setValue(0.0, 0.0);
	peakSignalMarker->setLineStyle(QwtPlotMarker::VLine);
	peakSignalMarker->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
	peakSignalMarker->setLinePen(QPen(Qt::green, 0, Qt::DashDotLine));
	peakSignalMarker->attach(qwtPlot_peakSignal);
	// end of marker




	// marker list
	listOfMarkers = new markerList(listWidget_FFTCycles, qwtPlot_peakSignal, peakSignalMarker);
	// end of marker list




	// spin boxes
	spinBox_gidrophone1->setMinimum(0);
	spinBox_gidrophone1->setMaximum(peakSignal->sizex() - 1);
	spinBox_gidrophone2->setMinimum(0);
	spinBox_gidrophone2->setMaximum(peakSignal->sizex() - 1);

	connect(spinBox_gidrophone1, SIGNAL( valueChanged(int) ), this, SLOT( showPeakSignal1(int) ) );
	connect(spinBox_gidrophone2, SIGNAL( valueChanged(int) ), this, SLOT( showPeakSignal2(int) ) );
	// end of spin boxes




	// spin boxes 2
	spinBox_FFTGidrophone1->setMinimum(0);
	spinBox_FFTGidrophone1->setMaximum(0);
	spinBox_FFTGidrophone2->setMinimum(0);
	spinBox_FFTGidrophone2->setMaximum(0);
	connect(spinBox_FFTGidrophone1, SIGNAL( valueChanged(int) ), this, SLOT( showFFTSignal1(int) ) );
	connect(spinBox_FFTGidrophone2, SIGNAL( valueChanged(int) ), this, SLOT( showFFTSignal2(int) ) );
	// end of spin boxes 2




	// evaluate button
	// (defined in ui form)
	//connect( pushButton_evaluate, SIGNAL( clicked() ), this, SLOT( evaluatePeakSignal() ) );
	// end of evaluate button




	// signal picker
	// (defined in function reCreateZoomer())
	connect(peakSignalPicker, SIGNAL(moved(const QPoint &)), this, SLOT(showCurrentMarker(const QPoint &)));
	connect(peakSignalPicker, SIGNAL(appended(const QPoint &)), this, SLOT(showCurrentMarker(const QPoint &)));
	// end of signal picker

	connect(pushButton_addFFTCycle, SIGNAL( clicked() ), listOfMarkers, SLOT( addMarker() ) );
	connect(pushButton_removeCycle, SIGNAL( clicked() ), listOfMarkers, SLOT( removeMarker() ) );
	connect(pushButton_FFTCycleShiftLeft, SIGNAL( clicked() ), listOfMarkers, SLOT( shiftCurrentMarkerLeft() ) );
	connect(pushButton_FFTCycleShiftRight, SIGNAL( clicked() ), listOfMarkers, SLOT( shiftCurrentMarkerRight() ) );
	connect(pushButton_calibrate, SIGNAL( clicked() ), this, SLOT( proceedCalibrate() ) );


	//connect(listWidget_FFTCycles, SIGNAL( currentItemChanged( QListWidgetItem*, QListWidgetItem* ) ), this, SLOT( chooseCycleItem( QListWidgetItem*, QListWidgetItem* ) ) );
	connect(listWidget_FFTCycles, SIGNAL( 	itemActivated( QListWidgetItem* ) ), listOfMarkers, SLOT( markerSelected( QListWidgetItem* ) ) );
	if(showAlreadyPrecalcedCycles){
		std::vector<double>* sourceFrequencies = mainModel->giveFrequencies();
		std::vector<int>* alreadyPrecalcedCycles = mainModel->giveCycles();
		int alreadyPrecalcedCyclesAmount = alreadyPrecalcedCycles->size();
		for(int i = 0; i < alreadyPrecalcedCyclesAmount; i++){
			listOfMarkers->addPrecalcedMarker((*alreadyPrecalcedCycles)[i], (*sourceFrequencies)[i]);
		}
	}
}
void QwtPlotPrintFilter::apply(QwtPlotItem *item) const
{
    PrivateData::Cache &cache = *d_data->cache;

    switch(item->rtti())
    {
        case QwtPlotItem::Rtti_PlotGrid:
        {
            QwtPlotGrid *grid = (QwtPlotGrid *)item;

            QPen pen = grid->majPen();
            cache.gridColors[0] = pen.color();
            pen.setColor(color(pen.color(), MajorGrid));
            grid->setMajPen(pen);

            pen = grid->minPen();
            cache.gridColors[1] = pen.color();
            pen.setColor(color(pen.color(), MinorGrid));
            grid->setMinPen(pen);

            break;
        }
        case QwtPlotItem::Rtti_PlotCurve:
        {
            QwtPlotCurve *c = (QwtPlotCurve *)item;

            QwtSymbol symbol = c->symbol();

            QPen pen = symbol.pen();
            cache.curveSymbolPenColors.insert(c, pen.color());
            pen.setColor(color(pen.color(), CurveSymbol));
            symbol.setPen(pen);

            QBrush brush = symbol.brush();
            cache.curveSymbolBrushColors.insert(c, brush.color());
            brush.setColor(color(brush.color(), CurveSymbol));
            symbol.setBrush(brush);

            c->setSymbol(symbol);

            pen = c->pen();
            cache.curveColors.insert(c, pen.color());
            pen.setColor(color(pen.color(), Curve));
            c->setPen(pen);

            break;
        }
        case QwtPlotItem::Rtti_PlotMarker:
        {
            QwtPlotMarker *m = (QwtPlotMarker *)item;

            QwtText label = m->label();
            cache.markerFonts.insert(m, label.font());
            label.setFont(font(label.font(), Marker));
            cache.markerLabelColors.insert(m, label.color());
            label.setColor(color(label.color(), Marker));
            m->setLabel(label);
            
            QPen pen = m->linePen();
            cache.markerLineColors.insert(m, pen.color());
            pen.setColor(color(pen.color(), Marker));
            m->setLinePen(pen);

            QwtSymbol symbol = m->symbol();

            pen = symbol.pen();
            cache.markerSymbolPenColors.insert(m, pen.color());
            pen.setColor(color(pen.color(), MarkerSymbol));
            symbol.setPen(pen);

            QBrush brush = symbol.brush();
            cache.markerSymbolBrushColors.insert(m, brush.color());
            brush.setColor(color(brush.color(), MarkerSymbol));
            symbol.setBrush(brush);

            m->setSymbol(symbol);

            break;
        }
        default:    
            break;
    }
}
void QwtPlotPrintFilter::reset(QwtPlotItem *item) const
{
    if ( d_data->cache == 0 )
        return;

    const PrivateData::Cache &cache = *d_data->cache;

    switch(item->rtti())
    {
        case QwtPlotItem::Rtti_PlotGrid:
        {
            QwtPlotGrid *grid = (QwtPlotGrid *)item;

            QPen pen = grid->majPen();
            pen.setColor(cache.gridColors[0]);
            grid->setMajPen(pen);

            pen = grid->minPen();
            pen.setColor(cache.gridColors[1]);
            grid->setMinPen(pen);

            break;
        }
        case QwtPlotItem::Rtti_PlotCurve:
        {
            QwtPlotCurve *c = (QwtPlotCurve *)item;

            QwtSymbol symbol = c->symbol();

            if ( cache.curveSymbolPenColors.contains(c) )
            {
                symbol.setPen(cache.curveSymbolPenColors[c]);
            }

            if ( cache.curveSymbolBrushColors.contains(c) )
            {
                QBrush brush = symbol.brush();
                brush.setColor(cache.curveSymbolBrushColors[c]);
                symbol.setBrush(brush);
            }
            c->setSymbol(symbol);

            if ( cache.curveColors.contains(c) )
            {
                QPen pen = c->pen();
                pen.setColor(cache.curveColors[c]);
                c->setPen(pen);
            }

            break;
        }
        case QwtPlotItem::Rtti_PlotMarker:
        {
            QwtPlotMarker *m = (QwtPlotMarker *)item;

            if ( cache.markerFonts.contains(m) )
            {
                QwtText label = m->label();
                label.setFont(cache.markerFonts[m]);
                m->setLabel(label);
            }

            if ( cache.markerLabelColors.contains(m) )
            {
                QwtText label = m->label();
                label.setColor(cache.markerLabelColors[m]);
                m->setLabel(label);
            }

            if ( cache.markerLineColors.contains(m) )
            {
                QPen pen = m->linePen();
                pen.setColor(cache.markerLineColors[m]);
                m->setLinePen(pen);
            }
            
            QwtSymbol symbol = m->symbol();

            if ( cache.markerSymbolPenColors.contains(m) )
            {
                QPen pen = symbol.pen();
                pen.setColor(cache.markerSymbolPenColors[m]);
                symbol.setPen(pen);
            }

            if ( cache.markerSymbolBrushColors.contains(m) )
            {
                QBrush brush = symbol.brush();
                brush.setColor(cache.markerSymbolBrushColors[m]);
                symbol.setBrush(brush);
            }

            m->setSymbol(symbol);

            break;
        }
        default:
            break;
    }
}
Example #30
0
Plot::Plot(QWidget *parent):
    QwtPlot(parent)
{
    setTitle("Interactive Plot");

    setCanvasColor(Qt::darkCyan);

    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
    grid->attach(this);

    // axes

    setAxisScale(QwtPlot::xBottom, 0.0, 100.0);
    setAxisScale(QwtPlot::yLeft, 0.0, 100.0);

    // Avoid jumping when label with 3 digits
    // appear/disappear when scrolling vertically

    QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
    sd->setMinimumExtent( sd->extent(axisWidget(QwtPlot::yLeft)->font()));

    plotLayout()->setAlignCanvasToScales(true);

    insertCurve(Qt::Vertical, Qt::blue, 30.0);
    insertCurve(Qt::Vertical, Qt::magenta, 70.0);
    insertCurve(Qt::Horizontal, Qt::yellow, 30.0);
    insertCurve(Qt::Horizontal, Qt::white, 70.0);

    replot();

    // ------------------------------------
    // We add a color bar to the left axis
    // ------------------------------------

    QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(yLeft);
    scaleWidget->setMargin(10); // area for the color bar
    d_colorBar = new ColorBar(Qt::Vertical, scaleWidget);
    d_colorBar->setRange(Qt::red, Qt::darkBlue);
    d_colorBar->setFocusPolicy(Qt::TabFocus);

    connect(d_colorBar, SIGNAL(selected(const QColor &)),
        SLOT(setCanvasColor(const QColor &)));

    // we need the resize events, to lay out the color bar
    scaleWidget->installEventFilter(this); 

    // ------------------------------------
    // We add a wheel to the canvas
    // ------------------------------------

    d_wheel = new QwtWheel(canvas());
    d_wheel->setOrientation(Qt::Vertical);
    d_wheel->setRange(-100, 100);
    d_wheel->setValue(0.0);
    d_wheel->setMass(0.2);
    d_wheel->setTotalAngle(4 * 360.0);

    connect(d_wheel, SIGNAL(valueChanged(double)),
        SLOT(scrollLeftAxis(double)));

    // we need the resize events, to lay out the wheel
    canvas()->installEventFilter(this);

    d_colorBar->setWhatsThis(
        "Selecting a color will change the background of the plot.");
    scaleWidget->setWhatsThis(
        "Selecting a value at the scale will insert a new curve.");
    d_wheel->setWhatsThis(
        "With the wheel you can move the visible area.");
    axisWidget(xBottom)->setWhatsThis(
        "Selecting a value at the scale will insert a new curve.");
}