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(); }
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(); d_curves.remove (index); }
Spectrogram *MantidMatrix::plotSpectrogram(Graph *plot, ApplicationWindow *app, Graph::CurveType type, bool project, const ProjectData *const prjData) { app->setPreferences(plot); plot->setTitle(tr("Workspace ") + name()); using MantidQt::API::PlotAxis; plot->setXAxisTitle(PlotAxis(*m_workspace, 0).title()); plot->setYAxisTitle(PlotAxis(*m_workspace, 1).title()); // Set the range on the third, colour axis double minz, maxz; auto fun = new MantidMatrixFunction(*this); range(&minz, &maxz); Spectrogram *spgrm = plot->plotSpectrogram(fun, m_spectrogramRows, m_spectrogramCols, boundingRect(), minz, maxz, type); app->setSpectrogramTickStyle(plot); if (spgrm) { if (project) { spgrm->mutableColorMap().loadMap(prjData->getColormapFile()); spgrm->setCustomColorMap(spgrm->mutableColorMap()); spgrm->setIntensityChange(prjData->getIntensity()); if (!prjData->getGrayScale()) spgrm->setGrayScale(); if (prjData->getContourMode()) { spgrm->setDisplayMode(QwtPlotSpectrogram::ContourMode, true); spgrm->showContourLineLabels(true); } spgrm->setDefaultContourPen(prjData->getDefaultContourPen()); spgrm->setColorMapPen(false); if (prjData->getColorMapPen()) spgrm->setColorMapPen(true); ContourLinesEditor *contourEditor = prjData->getContourLinesEditor(); if (contourEditor) { contourEditor->setSpectrogram(spgrm); contourEditor->updateContents(); contourEditor->updateContourLevels(); } } } plot->setAutoScale(); return spgrm; }
bool ex_qrs_hr_features(void *args) { ITheFramework *frame = Factory::GetFramework(); Decorator *decorator = ssi_create(Decorator, 0, true); frame->AddDecorator(decorator); ITheEventBoard *board = Factory::GetEventBoard(); //raw FileReader *reader = ssi_create(FileReader, 0, true); reader->getOptions()->setPath("data/ecg"); reader->getOptions()->block = 0.2; ITransformable *ecg_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME); frame->AddSensor(reader); // qrs detection QRSDetection *ecg_chain = ssi_create(QRSDetection, 0, true); ecg_chain->getOptions()->sendEvent = false; ITransformable *ecg_qrs_t = frame->AddTransformer(ecg_p, ecg_chain, "0.75s", "0", "60.0s"); // heart rate QRSHeartRate *qrshr = ssi_create(QRSHeartRate, 0, true); ITransformable *ecg_hr_t = frame->AddTransformer(ecg_qrs_t, qrshr, "1.0s", "0", "60.0s"); // heart rate features Spectrogram *spectogram = ssi_create(Spectrogram, 0, true); ssi_strcpy(spectogram->getOptions()->file, "hrspect.banks"); spectogram->getOptions()->nbanks = 3; ITransformable *ecg_hr_spec_t = frame->AddTransformer(ecg_hr_t, spectogram, "1", "29", "60.0s"); //hrv_spectral QRSHRVspectral *ecg_hr_spectralfeatures = ssi_create(QRSHRVspectral, 0, true); ecg_hr_spectralfeatures->getOptions()->print = true; ITransformable *ecg_hr_spectralfeatures_t = frame->AddTransformer(ecg_hr_spec_t, ecg_hr_spectralfeatures, "1", "0", "60.0s"); //hrv_time QRSHRVtime *ecg_hr_timefeatures = ssi_create(QRSHRVtime, 0, true); ecg_hr_timefeatures->getOptions()->print = true; ITransformable *ecg_hr_timefeatures_t = frame->AddTransformer(ecg_qrs_t, ecg_hr_timefeatures, "1.0s", "6.5s", "60.0s"); //visual SignalPainter *plot = 0; ssi_real_t p_size = 100.0f; //qrs plot = ssi_create_id(SignalPainter, 0, "plot"); plot->getOptions()->setTitle("qrs"); plot->getOptions()->size = p_size; frame->AddConsumer(ecg_qrs_t, plot, "0.75s"); //heart rate plot = ssi_create_id(SignalPainter, 0, "plot"); plot->getOptions()->setTitle("hr"); plot->getOptions()->size = p_size; frame->AddConsumer(ecg_hr_t, plot, "1"); //spectrgram plot = ssi_create_id(SignalPainter, 0, "plot"); plot->getOptions()->setTitle("hr spect"); plot->getOptions()->size = p_size; plot->getOptions()->type = PaintSignalType::IMAGE; frame->AddConsumer(ecg_hr_spec_t, plot, "1"); //framework decorator->add("console", 0, 0, 650, 800); decorator->add("plot*", 650, 0, 400, 400); decorator->add("monitor*", 650, 400, 400, 400); board->Start(); frame->Start(); frame->Wait(); frame->Stop(); board->Stop(); frame->Clear(); board->Clear(); return true; }