示例#1
0
/**
 * Rysuje "spektrogram" cech obliczonych przez podany ekstraktor.
 *
 * Ekstraktor już nie wykonuje obliczeń, zakładamy że dane są już gotowe.
 * Jedyne obliczenia wykonywane są w klasie FeatureData, która szuka maksimum
 * i minimum potrzebnego do wyskalowania spektrogramu.
 *
 * @param extractor obiekt ekstraktora cech
 */
void ChartsWidget::drawFeatureChart(Aquila::Extractor* extractor)
{
    FeatureData data(extractor);
    if (data.isCanceled())
    {
        emit sendMessage(tr("Feature chart canceled"));
        return;
    }

    SpectrogramPlot* plot = new SpectrogramPlot(this);
    // minimalna szerokośœć lewej osi, żeby wykres nie skakał
    const QFontMetrics fm(plot->axisWidget(QwtPlot::yLeft)->font());
    plot->axisScaleDraw(QwtPlot::yLeft)->setMinimumExtent(fm.width("100"));
    // przypisanie danych
    plot->setSpectrogramData(data);
    // skalowanie osi intensywności
    plot->setAxisScale(QwtPlot::yRight, data.getMinParam(), data.getMaxParam());

    plot->setTitle(tr("File: %1, feature type: %2").
        arg(extractor->getWaveFilename().c_str()).
        arg(extractor->getType().c_str()));
    QFileInfo info(QString::fromStdString(extractor->getWaveFilename()));
    QString featureInfo = tr("%1 (%2)").arg(info.fileName()).arg(data.getInfo());

    // add a detailed overlay, but only when requested in settings
    SimpleBirdSettings settings;
    if (settings.addOverlay())
    {
        plot->setExtraCaption(featureInfo, 0, extractor->getParamsPerFrame());
    }

    addPlot(plot, tr("%1 - feature chart").arg(info.fileName()));
    emit sendMessage(tr("Drawn feature chart: %1").arg(featureInfo));
}
bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
{
    m_plots.clear();
    m_plotNotebook->DeleteAllPages();

    wxTextFile file( aPath );

    if( !file.Open() )
        return false;

    long plotsCount;

    if( !file.GetFirstLine().ToLong( &plotsCount ) )        // GetFirstLine instead of GetNextLine
        return false;

    for( long i = 0; i < plotsCount; ++i )
    {
        long plotType, tracesCount;

        if( !file.GetNextLine().ToLong( &plotType ) )
            return false;

        SIM_PLOT_PANEL* plotPanel = NewPlotPanel( (SIM_TYPE) plotType );
        m_plots[plotPanel].m_simCommand = file.GetNextLine();
        StartSimulation();

        // Perform simulation, so plots can be added with values
        do
        {
            wxThread::This()->Sleep( 50 );
        }
        while( IsSimulationRunning() );

        if( !file.GetNextLine().ToLong( &tracesCount ) )
            return false;

        for( long j = 0; j < tracesCount; ++j )
        {
            long traceType;
            wxString name, param;

            if( !file.GetNextLine().ToLong( &traceType ) )
                return false;

            name = file.GetNextLine();
            param = file.GetNextLine();

            if( name.IsEmpty() || param.IsEmpty() )
                return false;

            addPlot( name, (SIM_PLOT_TYPE) traceType, param );
        }
    }

    return true;
}
    virtual void run()
    {
      int argc = 1;
      QByteArray argvStr = QString("").toLatin1();
      char* argv = argvStr.data();
      QApplication app(argc, &argv);
	  
	  // Wait until data is available to run time series timeSeriesPlotter
	  while (!m_dataObserver->isReceivingData());

      // Setting up time series plotter with new incoming data feeds
      int processSize = m_dataObserver->data()->getProcessSize();
// 	  std::cout << " - Monitoring "<< processSize << " process(es) "<<endl; 
	  
	  // Setting up step value
	  int step = 0;
	  int plot_options = m_plotOtions;
	  int plot_value	= plot_max;	//MAX PLOT VALUE
	  while (plot_options > 0)
	  {
		  if (plot_options & plot_value){
			  step++;
			  plot_options = (plot_options ^ plot_value);
		  }
		  plot_value >>= 1;
	  }
	  
	  // Plotting for desired processes
	  std::vector<std::shared_ptr<MainWindow>> my_plots;
      for (int i=0, a=0; i<processSize*step; i+=step, a++)
      {
		int curr_ind = i;
		// Add memory plot
		if (m_plotOtions & plot_mem)
			curr_ind = addPlot(my_plots, curr_ind, a, kMemory);
		
		// Add cpu usage plot
		if (m_plotOtions & plot_cpu)
			curr_ind = addPlot(my_plots, curr_ind, a, kCPU);
      }
     
      app.exec();
    }
示例#4
0
gLineChart::gLineChart(ChannelID code,QColor col,bool square_plot, bool disable_accel)
:Layer(code),m_square_plot(square_plot),m_disable_accel(disable_accel)
{
    addPlot(code,col,square_plot);
    m_line_color=col;
    m_report_empty=false;
    addVertexBuffer(lines=new gVertexBuffer(100000,GL_LINES));
    lines->setColor(col);
    lines->setAntiAlias(true);
    lines->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
示例#5
0
/**
 * Rysuje przebieg nagrania z obiektu typu WaveFile.
 *
 * @param wavefile wskaźnik do obiektu nagrania
 */
void ChartsWidget::drawWaveform(Aquila::WaveFile* wavefile)
{
    WaveformPlot* plotWaveform = new WaveformPlot(this);
    SimpleBirdSettings settings;
    plotWaveform->setColor(settings.getWaveformColor());
    plotWaveform->setWaveFile(wavefile);

    QFileInfo info(QString::fromStdString(wavefile->getFilename()));
    addPlot(plotWaveform, tr("%1 - waveform").arg(info.fileName()));
    emit sendMessage(tr("Drawn waveform: %1").arg(info.fileName()));
}
示例#6
0
void MainWindow::routePlotsMenu()
{
    {
        connect(ui->actionCloseAllPlots, SIGNAL(triggered()), SLOT(tryClearWindows()));
    }
    {
        connect(ui->actionAddPlot,             SIGNAL(triggered()), groups, SLOT(addPlot()));
        connect(ui->actionTile,                SIGNAL(triggered()), groups, SLOT(tileActiveGroup()));
        connect(ui->actionExportPlotsToImages, SIGNAL(triggered()), groups, SLOT(exportActiveGroupToPng()));
        connect(ui->actionExportPlotsToPdf,    SIGNAL(triggered()), groups, SLOT(exportActiveGroupToPdf()));
    }

}
示例#7
0
KstQuickPSDDialogI::KstQuickPSDDialogI(QWidget* parent, const char* name,
                                           bool modal, WFlags fl)
: KstQuickPSDDialog(parent, name, modal, fl) {
    connect(Apply, SIGNAL(clicked()), this, SLOT(apply()));
    connect(ApplyPlotCols, SIGNAL(clicked()), this, SLOT(addPlot()));
    connect(SourceVector, SIGNAL(stateChanged(int)),
            this, SLOT(updateActiveEntry(int)));

    FileName->setMode(KFile::File | KFile::Directory | KFile::ExistingOnly
                      | KFile::LocalOnly);
    
    DataFileEntry->setEnabled(false);
}
void CvPlotGroup::init(int iID, PlayerTypes eOwner, CvPlot* pPlot)
{
	//--------------------------------
	// Init saved data
	reset(iID, eOwner);

	//--------------------------------
	// Init non-saved data

	//--------------------------------
	// Init other game data
	addPlot(pPlot);
}
示例#9
0
/**
 * Rysuje diagram DTW.
 *
 * Ekstraktor już nie wykonuje obliczeń, zakładamy że dane są już gotowe.
 * Funkcja dobiera sobie drugi obiekt ekstraktora.
 *
 * @param extractor obiekt ekstraktora cech
 */
void ChartsWidget::drawDtwChart(Aquila::Extractor* extractor)
{
    QString patternFile = QFileDialog::getOpenFileName(this, tr("Choose pattern file"),
        "L:\\_ptaki", FormatFactory::getFeatureFormatsFilter());
    if (patternFile.isEmpty())
        return;

    Aquila::Extractor* pattern = FormatFactory::readIntoExtractor(patternFile);
    if (!extractor->isCompatible(pattern))
    {
        emit sendMessage(tr("Feature files are incompatible with each other!"));
        delete pattern;
        return;
    }
    DtwData data(extractor, pattern);

    SpectrogramPlot* plot = new SpectrogramPlot(this);

    // skalowanie lewej osi w jednostkach czasu
    DurationScaleDraw* dsd = new DurationScaleDraw();
    dsd->setFrameLength(pattern->getFrameLength());
    dsd->setFrameOverlap(0.66); // FIXME
    plot->setAxisScaleDraw(QwtPlot::yLeft, dsd);
    // minimalna szerokośœć lewej osi, żeby wykres nie skakał
    const QFontMetrics fm(plot->axisWidget(QwtPlot::yLeft)->font());
    plot->axisScaleDraw(QwtPlot::yLeft)->setMinimumExtent(fm.width("10000 ms"));

    plot->setSpectrogramData(data);
    // skalowanie osi odległości
    plot->axisWidget(QwtPlot::yRight)->setTitle(tr("Distance"));
    plot->setAxisScale(QwtPlot::yRight, data.range().minValue(), data.range().maxValue());

    plot->setTitle(tr("DTW chart: %1 against %2").
        arg(QFileInfo(extractor->getWaveFilename().c_str()).fileName()).
        arg(QFileInfo(pattern->getWaveFilename().c_str()).fileName()));

    QString dtwInfo = data.getInfo();
    SimpleBirdSettings settings;
    // add a detailed overlay, but only when requested in settings
    if (settings.addOverlay())
    {
        plot->setExtraCaption(dtwInfo, 0, pattern->getFramesCount());
    }

    delete pattern;

    addPlot(plot, tr("DTW chart"));
    emit sendMessage(tr("Drawn DTW chart: %1").arg(dtwInfo));
}
示例#10
0
/**
 * Rysuje spektrogram z obiektu typu WaveFile.
 *
 * @param wavefile wskaźnik do obiektu nagrania
 */
void ChartsWidget::drawSpectrogram(Aquila::WaveFile* wavefile)
{
    SpectrogramData data(wavefile);
    if (data.isCanceled())
    {
        emit sendMessage(tr("Spectrogram canceled"));
        return;
    }

    SpectrogramPlot* plot = new SpectrogramPlot(this);
    // w przypadku tradycyjnego spektrogramu, na lewej osi częstotliwość
    FrequencyScaleDraw* freqSD = new FrequencyScaleDraw();
    freqSD->setSampleFrequency(wavefile->getSampleFrequency());
    freqSD->setSpectrumSize(wavefile->getSamplesPerFrameZP());
    plot->setAxisScaleDraw(QwtPlot::yLeft, freqSD);
    // minimalna szerokośœć lewej osi, żeby wykres nie skakał
    const QFontMetrics fm(plot->axisWidget(QwtPlot::yLeft)->font());
    freqSD->setMinimumExtent(fm.width("10000000 Hz"));
    // przypisanie danych
    plot->setSpectrogramData(data);
    // skalowanie osi intensywności
    plot->setAxisScale(QwtPlot::yRight, data.range().minValue(), data.range().maxValue());
    // zoomer musi być utworzony po przypisaniu danych
    SpectrogramPlotZoomer* zoomer = new SpectrogramPlotZoomer(plot->canvas());
    SimpleBirdSettings settings;
    zoomer->setFrameLength(settings.getFrameLength());
    zoomer->setFrameOverlap(settings.getOverlap());
    zoomer->setSampleFrequency(wavefile->getSampleFrequency());
    zoomer->setSpectrumSize(wavefile->getSamplesPerFrameZP());

    plot->setTitle(tr("File: %1").arg(wavefile->getFilename().c_str()));

    QFileInfo info(QString::fromStdString(wavefile->getFilename()));
    QString spectrogramInfo = tr("%1 (%2)").arg(info.fileName()).arg(data.getInfo());

    // add a detailed overlay, but only when requested in settings
    if (settings.addOverlay())
    {
        plot->setExtraCaption(spectrogramInfo, 0, wavefile->getSamplesPerFrameZP()/2);
    }

    addPlot(plot, tr("%1 - spectrogram").arg(info.fileName()));
    emit sendMessage(tr("Drawn spectrogram: %1").arg(spectrogramInfo));
}
void SIM_PLOT_FRAME::AddVoltagePlot( const wxString& aNetName )
{
    addPlot( aNetName, SPT_VOLTAGE, "V" );
}
示例#12
0
void KstQuickPSDDialogI::apply(bool autolabel) {
  KstDataSourcePtr file;
  KstVectorPtr vx;
  KstRVectorPtr trv;
  KstPlot *plot;
  int i_v;
  QString v_name, c_name;
  bool x_is_new;
  KstPSDCurvePtr curve;
  double new_freq;
  int new_len;

  if (KST::plotList.count() < 1) {
    addPlot();
    return;
  }

  if (SourceVector->isChecked()) { // set vx from existing vectors
    i_v = Vectors->currentItem();
    KstReadLocker ml(&KST::vectorList.lock());
    if (i_v >= (int)KST::vectorList.count()) {
      return;
    }
    vx = KST::vectorList[i_v];
  } else { // set vx from data file specification
    KstReadLocker ml(&KST::dataSourceList.lock());

    /* generate or find the kstfile */
    KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(FileName->url());

    if (it == KST::dataSourceList.end()) {
      file = KstDataSource::loadSource(FileName->url());
      if (!file || !file->isValid()) {
        KMessageBox::sorry(0L, i18n("The file could not be loaded."));
        return;
      }
      if (file->frameCount() < 1) {
        KMessageBox::sorry(0L, i18n("The file does not contain data."));
        return;
      }
      KST::dataSourceList.append(file);
    } else {
      file = *it;
    }

    KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
    x_is_new = true;
    /**** Build the XVector ***/
    /* make sure there are no vectors with the current vectors props */
    for (i_v = 0; unsigned(i_v) < rvl.count(); i_v++) {
      trv = rvl[i_v];
      if ((trv->filename() == FileName->url()) &&
          (trv->getField() == Field->text()) &&
          (trv->reqStartFrame() == F0->value()) &&
          (trv->reqNumFrames() == N->value()) &&
          (trv->skip() == Skip->value()) &&
          (trv->doSkip() == DoSkip->isChecked()) &&
          (trv->doAve() == DoFilter->isChecked()) &&
          (trv->readToEOF() == ReadToEnd->isChecked()) &&
          (trv->countFromEOF() == CountFromEnd->isChecked())) {
        x_is_new = false;
        i_v = rvl.count();
        vx = trv;
      }
    }

    if (x_is_new) {
      KST::vectorList.lock().readLock();
      /* If not, Generate a unique vector name */
      v_name = "V" + QString::number(KST::vectorList.count()+1)+"-"
               + Field->text();
      while (KST::vectorList.findTag(v_name) != KST::vectorList.end()) {
        v_name += "'";
      }
      KST::vectorList.lock().readUnlock();
      KST::dataObjectList.lock().readLock();
      while (KST::dataObjectList.findTag(v_name) != KST::dataObjectList.end()) {
        v_name += "'";
      }
      KST::dataObjectList.lock().readUnlock();

      if (!file->isValidField(Field->text())) {
        KMessageBox::sorry(0L, i18n("The requested field is not defined for the requested file."));
        return;
      }

      /* generate and append the vector */
      trv = new KstRVector(file, Field->text(),
                          v_name,
                          (CountFromEnd->isChecked() ? -1 : F0->value()),
                          (ReadToEnd->isChecked() ? -1 : N->value()),
                          Skip->value(),
                          DoSkip->isChecked(),
                          DoFilter->isChecked());
      KST::addVectorToList(KstVectorPtr(trv));
      vx = trv;
    }
  }
  /**** Build the PSD ***/
  /* find new_freq */
  new_freq = PSDSampRate->text().toDouble();
  if (new_freq <= 0) {
      KMessageBox::sorry(0L, i18n("The sample rate must be greater than 0."));
      return;
  }

  /* find new_len */
  new_len = PSDFFTLen->text().toInt();
  if (new_len < 2) {
      KMessageBox::sorry(0L, i18n("The FFT length must be greater than 2^2."));
      return;
  }

  /* create the psd curve name */
  KST::dataObjectList.lock().writeLock();
  c_name = "PSD"+QString::number(KST::dataObjectList.count()+1) + "-" + vx->tagName();
  while (KST::dataObjectList.findTag(c_name) != KST::dataObjectList.end()) {
    c_name+="'";
  }
  KST::vectorList.lock().readLock();
  while (KST::vectorList.findTag(c_name) != KST::vectorList.end()) {
    c_name+="'";
  }
  KST::vectorList.lock().readUnlock();

  /* create the psd curve */
  curve = new KstPSDCurve(c_name, vx, new_freq, new_len,
                        PSDVectorUnits->text(), PSDRateUnits->text(),
                        _curveAppearance->color());
  curve->setHasPoints(_curveAppearance->showPoints());
  curve->setHasLines(_curveAppearance->showLines());
  curve->setLineWidth(_curveAppearance->lineWidth());
  curve->setLineStyle(_curveAppearance->lineStyle());
  curve->Point.setType(_curveAppearance->pointType());

  KST::dataObjectList.append(curve.data());
  KST::dataObjectList.lock().writeUnlock();
  /* assign curve to plot */
  plot = KST::plotList.FindKstPlot(PlotList->currentText());
  plot->addCurve(curve);
  if (autolabel)
    plot->GenerateDefaultLabels();

  close();
  emit docChanged();
  update();
}
示例#13
0
void
PlotWidget::indicatorDialog2 (QString plugin, int row, QString name)
{
  addPlot(plugin, row, name);
  refresh();
}
示例#14
0
void MainWindow::createActions()
{
    pt_fileAct = new QAction(tr("&File"), this);
    pt_fileAct->setStatusTip(tr("Open video file"));
    connect(pt_fileAct, SIGNAL(triggered()), this, SLOT(callFileSelectDialog()));

    pt_resumeAct = new QAction(tr("&Resume"), this);
    pt_resumeAct->setStatusTip("Resume");
    connect(pt_resumeAct, SIGNAL(triggered()), pt_videocapture, SLOT(resume()));

    pt_pauseAct = new QAction(tr("&Pause"), this);
    pt_pauseAct->setStatusTip("Pause");
    connect(pt_pauseAct, SIGNAL(triggered()), pt_videocapture, SLOT(pause()));

    pt_backwardAct = new QAction(this);
    connect(pt_backwardAct, SIGNAL(triggered()), pt_videocapture, SLOT(stepBackward()));

    pt_forwardAct = new QAction(this);
    connect(pt_forwardAct, SIGNAL(triggered()), pt_videocapture, SLOT(stepForward()));

    pt_speedupAct = new QAction(tr("Speedx2.0"), this);
    pt_speedupAct->setStatusTip("Increase speed of playback by two times");
    connect(pt_speedupAct, SIGNAL(triggered(bool)), pt_videocapture, SLOT(speedUp()));

    pt_speeddownAct = new QAction(tr("Speedx0.5"), this);
    pt_speeddownAct->setStatusTip("Decrease speed of playback by two times");
    connect(pt_speeddownAct, SIGNAL(triggered(bool)), pt_videocapture, SLOT(speedDown()));

    pt_aboutAct = new QAction(tr("&About"), this);
    pt_aboutAct->setStatusTip("Show about");
    connect(pt_aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    pt_helpAct = new QAction(tr("&Help"), this);
    pt_helpAct->setStatusTip("Show help");
    connect(pt_helpAct, SIGNAL(triggered()), this, SLOT(help()));

    pt_numAct = new QAction(tr("&Numbers"), this);
    pt_numAct->setStatusTip("Toogle show numbers");
    pt_numAct->setCheckable(true);
    pt_numAct->setChecked(true);
    connect(pt_numAct, SIGNAL(triggered(bool)), ui->display, SLOT(setNumbersVisualization(bool)));

    pt_imageAct = new QAction(tr("&Image"), this);
    pt_imageAct->setStatusTip("Toogle show image");
    pt_imageAct->setCheckable(true);
    pt_imageAct->setChecked(true);
    connect(pt_imageAct, SIGNAL(triggered(bool)), ui->display, SLOT(setImageVisualization(bool)));

    pt_selectionAct = new QAction(tr("&Select"), this);
    pt_selectionAct->setStatusTip("Toogle show selection");
    pt_selectionAct->setCheckable(true);
    pt_selectionAct->setChecked(true);
    connect(pt_selectionAct, SIGNAL(triggered(bool)), ui->display, SLOT(setSelectionVisualization(bool)));

    pt_deviceAct = new QAction(tr("&Device"),this);
    pt_deviceAct->setStatusTip(tr("Open video device"));
    connect(pt_deviceAct, SIGNAL(triggered()), this, SLOT(callDeviceSelectDialog()));

    pt_plotAct = new QAction(tr("&Plot"),this);
    pt_plotAct->setStatusTip(tr("New plot"));
    connect(pt_plotAct, SIGNAL(triggered()), this, SLOT(addPlot()));

    pt_writeAct = new QAction(tr("&Video"), this);
    pt_writeAct->setStatusTip(tr("Write processed frames to a file"));
    pt_writeAct->setCheckable(true);
    pt_writeAct->setChecked(false);
    connect(pt_writeAct, SIGNAL(triggered(bool)), this, SLOT(callVideoWriteDialog(bool)));

    pt_dsAct = new QAction(tr("DSdialog"), this);
    pt_dsAct->setStatusTip(tr("Call DirectShow device settings dialog"));
    connect(pt_dsAct, SIGNAL(triggered()), this, SLOT(callDSDialog()));

    pt_saveWFAct = new QAction(tr("Waterfall"), this);
    pt_saveWFAct->setStatusTip(tr("Save waterfall image on disk"));
    connect(pt_saveWFAct, SIGNAL(triggered()), this, SLOT(saveFileDialog()));
}
示例#15
0
void plotWindow::setupPlotWindow()
{
  plot = new QGraphicsView(this);
  plot->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
  plot->setScene(&plotdata);
  QWidget *centralWidget = new QWidget;
  QVBoxLayout *centralLayout = new QVBoxLayout;
  QHBoxLayout *topContainerLayout = new QHBoxLayout;
  QGridLayout *topLayout = new QGridLayout;
  centralWidget->setLayout(centralLayout);
  const int margin = centralLayout->margin();
  centralLayout->setMargin(0);
  centralLayout->addLayout(topContainerLayout);
  centralLayout->addWidget(plot);
  topContainerLayout->setMargin(margin);
  topContainerLayout->addLayout(topLayout);
  topContainerLayout->addStretch();

  QLabel *matfileLabel = new QLabel("MAT file");
  QLabel *xvarLabel = new QLabel("X Coordinate");
  QLabel *yvarLabel = new QLabel("Y Coordinate");
  QLabel *ptlabelLabel = new QLabel("LABEL");
  QLabel *dimLabel = new QLabel("DIM");

  matfile = new QLineEdit;
  matfile->setReadOnly(true);
  QAction *matfileAct = new QAction(QIcon(":/res/images/cr16-action-fileopen.png"), tr("&Open"), this);
  QToolButton *matfileButton = new QToolButton();
  matfileButton->setDefaultAction(matfileAct);
  connect(matfileAct, SIGNAL(triggered()), this, SLOT(open()));

  xvar = new QComboBox;
  yvar = new QComboBox;
  ptlabel = new QSpinBox;
  dim = new QSpinBox;

  plotSelect = new QListWidget;
  plotSelect->setSelectionMode(QAbstractItemView::SingleSelection);
  QVBoxLayout *dockLayout = new QVBoxLayout;
  QHBoxLayout *buttonsLayout = new QHBoxLayout;
  QWidget     *dockWidget = new QWidget;
  QAction     *removePlotAct = new QAction(QIcon(":/res/images/cr16-action-eraser.png"), "Remove Selected", this);
  QToolButton *removePlotButton = new QToolButton;
  removePlotButton->setDefaultAction(removePlotAct);
  connect(removePlotAct, SIGNAL(triggered()), this, SLOT(removePlot()));

  QAction     *colorizePlotAct = new QAction(QIcon(":/res/images/cr16-action-colorize.png"), "Change Color", this);
  QToolButton *colorizePlotButton = new QToolButton;
  colorizePlotButton->setDefaultAction(colorizePlotAct);
  connect(colorizePlotAct, SIGNAL(triggered()), this, SLOT(colorizePlot()));

  dockWidget->setLayout(dockLayout);
  dockLayout->setMargin(0);
  dockLayout->addSpacing(margin);
  dockLayout->addLayout(buttonsLayout);
  dockLayout->addWidget(plotSelect);
  buttonsLayout->addWidget(removePlotButton);
  buttonsLayout->addWidget(colorizePlotButton);

  QAction *addPlotAct = new QAction(QIcon(":/res/images/cr16-action-add.png"), tr("Add Plot"), this);
  QToolButton *addPlotButton = new QToolButton();
  addPlotButton->setDefaultAction(addPlotAct);
  connect(addPlotAct, SIGNAL(triggered()), this, SLOT(addPlot()));

  QAction *clearAllPlotAct = new QAction(QIcon(":/res/images/cr16-action-remove.png"), tr("Clear All"), this);
  QToolButton *clearAllPlotButton = new QToolButton();
  clearAllPlotButton->setDefaultAction(clearAllPlotAct);
  connect(clearAllPlotAct, SIGNAL(triggered()), this, SLOT(clearPlot()));

  QAction *printAct = new QAction(QIcon(":/res/images/cr16-action-fileprint.png"), tr("Print"), this);
  QToolButton *printButton = new QToolButton();
  printButton->setDefaultAction(printAct);
  connect(printAct, SIGNAL(triggered()), this, SLOT(print()));

  QAction *exportSvgAct = new QAction(QIcon(":/res/images/cr16-action-svg-export.png"), tr("Export to SVG"), this);
  QToolButton *exportSvgButton = new QToolButton();
  exportSvgButton->setDefaultAction( exportSvgAct );
  connect( exportSvgAct, SIGNAL(triggered()), this, SLOT(exportSvg()) );
  
  QComboBox* xyLog = new QComboBox;
  xyLog->insertItem(0, "Linear");
  xyLog->insertItem(1, "SemiLogX");
  xyLog->insertItem(2, "SemiLogY");
  xyLog->insertItem(3, "LogLog");
  xyLog->setCurrentIndex(0);
  connect( xyLog, SIGNAL(currentIndexChanged(int)), &plotdata, SLOT(setAxes(int)) );

  this->addWidget(dockWidget);
  this->addWidget(centralWidget);

  topLayout->addWidget(matfileLabel, 0, 0);
  topLayout->addWidget(xvarLabel, 0, 2);
  topLayout->addWidget(yvarLabel, 0, 3);
  topLayout->addWidget(ptlabelLabel, 0, 4);
  topLayout->addWidget(dimLabel, 0, 5);
  topLayout->addWidget(matfile, 1, 0);
  topLayout->addWidget(matfileButton, 1, 1);
  topLayout->addWidget(xvar, 1, 2);
  topLayout->addWidget(yvar, 1, 3);
  topLayout->addWidget(ptlabel, 1, 4);
  topLayout->addWidget(dim, 1, 5);
  topLayout->addWidget(addPlotButton, 1, 6);
  topLayout->addWidget(clearAllPlotButton, 1, 7);
  topLayout->addWidget(printButton, 1, 8);
  topLayout->addWidget(exportSvgButton, 1, 9 );
  topLayout->addWidget(xyLog, 2, 0 );

  plot->setMinimumSize(plot->mapFromScene(plotdata.sceneRect()).boundingRect().size()*1.1 +
                       QSize(2*plot->frameWidth(), 2*plot->frameWidth()));
}
void SIM_PLOT_FRAME::AddCurrentPlot( const wxString& aDeviceName, const wxString& aParam )
{
    addPlot( aDeviceName, SPT_CURRENT, aParam );
}
示例#17
0
void
PlotWidget::loadSettings ()
{
  DataBase db(g_session);
  
  // load controlWidget settings
  _cw->loadSettings(&db);
  
  // load indicator/plot settings
  QStringList l;
  db.getTypes(QString("indicator"), l);
  for (int pos = 0; pos < l.size(); pos++)
  {
    // get the plugin, row first
    Entity te;
    te.setName(l.at(pos));
    te.set(QString("plugin"), new QVariant(QString()));
    te.set(QString("row"), new QVariant(0));
    
    if (! db.get(&te))
      continue;
    
    QVariant *plugin = te.get(QString("plugin"));
    QVariant *row = te.get(QString("row"));
    addPlot(plugin->toString(), row->toInt(), l.at(pos));
    
    Entity *is = _settings.value(l.at(pos));
    if (! is)
      continue;
    
    if (! db.get(is))
      continue;

    // load plot settings
    Plot *plot = _plots.value(l.at(pos));
    if (! plot)
      continue;

    QVariant *tset = is->get(QString("date"));
    if (tset)
      plot->showDate(tset->toBool());

    tset = is->get(QString("grid"));
    if (tset)
      plot->setGrid(tset->toBool());

    tset = is->get(QString("info"));
    if (tset)
      plot->setInfo(tset->toBool());
  }

  // load this settings
  Entity *e = settings();
  if (! db.get(e))
  {
    delete e;
    return;
  }
  
  QVariant *tset = e->get(QString("sizes"));
  if (! tset)
    return;
  
  l = tset->toStringList();
  QList<int> sizes;
  for (int pos = 0; pos < l.size(); pos++)
    sizes << l.at(pos).toInt();
  _csplitter->setSizes(sizes);
  
  refresh();
}
示例#18
0
void selection::analyze(size_t childid /* this info can be used for printouts */){

	/*
	 * This skeleton analyser runs directly on the Delphes output.
	 * It can be used to create histograms directly or a skim.
	 * If a skim is created, a new input configuration will be written automatically
	 * and stored in the output directory together with the ntuples.
	 * The skim can contain delphes objects again or can be flat. This is up
	 * to the user.
	 * Examples for both are given here.
	 *
	 * The same skeleton can be used to read the skim. Please refer to the comments
	 * marked with "==SKIM=="
	 *
	 * These parts are commented, since the code is supposed to work as an example without
	 * modifications on Delphes output directly.
	 */



	/*
	 * Define the branches that are to be considered for the analysis
	 * This branch handler (notice the "d")
	 * is used to run directly in Delphes output.
	 * For skimmed ntuples, see below
	 */
	d_ana::dBranchHandler<Electron> elecs(tree(),"Electron");


	/* ==SKIM==
	 *
	 * If a skim of the Delphes outout was created in a way indicated
	 * further below, use the tBranchHandler (please notive the "t")
	 * to access vectors of objects...
	 *
	 */
	// d_ana::tBranchHandler<std::vector<Electron> > electrons(tree(),"Electrons");

	/*==SKIM==
	 *
	 * Or an object directly
	 *
	 */
	//d_ana::tBranchHandler<MissingET> met(tree(),"MET");



	/*
	 * Always use this function to add a new histogram (can also be 2D)!
	 * Histograms created this way are automatically added to the output file
	 */
	TH1* histo=addPlot(new TH1D("histoname1","histotitle1",100,0,100),"p_{T} [GeV]","N_{e}");


	/*
	 * If (optionally) a skim or a flat ntuple is to be created, please use the following function to initialize
	 * the tree.
	 * The output files will be written automatically, and a config file will be created.
	 */
	TTree* myskim=addTree();
	/*
	 * Add a simple branch to the skim
	 */
	Double_t elecPt=0;
	myskim->Branch("elecPt", &elecPt);
	/*
	 * Or store a vector of objects (also possible to store only one object)
	 */
	std::vector<Electron> skimmedelecs;
	myskim->Branch("Electrons",&skimmedelecs);



	size_t nevents=tree()->entries();
	if(isTestMode())
		nevents/=100;
	for(size_t eventno=0;eventno<nevents;eventno++){
		/*
		 * The following two lines report the status and set the event link
		 * Do not remove!
		 */
		reportStatus(eventno,nevents);
		tree()->setEntry(eventno);



		/*
		 * Begin the event-by-event analysis
		 */
		for(size_t i=0;i<elecs.size();i++){
			histo->Fill(elecs.at(i)->PT);
		}

		/*
		 * Or to fill the skim
		 */
		skimmedelecs.clear();
		for(size_t i=0;i<elecs.size();i++){
			//flat info
			elecPt=elecs.at(i)->PT;
			if(elecs.at(i)->PT < 20) continue;
			//or objects
			skimmedelecs.push_back(*elecs.at(i));
		}

		myskim->Fill();


		/*==SKIM==
		 * Access the branches of the skim
		 */
		//std::vector<Electron> * skimelecs=electrons.content();
		//for(size_t i=0;i<skimelecs->size();i++){
		//	histo->Fill(skimelecs->at(i).PT);
		//}
	}


	/*
	 * Must be called in the end, takes care of thread-safe writeout and
	 * call-back to the parent process
	 */
	processEndFunction();
}