void Spectrogram::showColorScale(int axis, bool on) { if (hasColorScale() == on && color_axis == axis) return; QwtPlot *plot = this->plot(); if (!plot) return; QwtScaleWidget *colorAxis = plot->axisWidget(color_axis); colorAxis->setColorBarEnabled(false); color_axis = axis; // We must switch main and the color scale axes and their respective scales int xAxis = this->xAxis(); int yAxis = this->yAxis(); int oldMainAxis = yAxis; if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop) { oldMainAxis = xAxis; xAxis = 5 - color_axis; } else if (axis == QwtPlot::yLeft || axis == QwtPlot::yRight) { oldMainAxis = yAxis; yAxis = 1 - color_axis; } // First we switch axes setAxis(xAxis, yAxis); // Next we switch axes scales QwtScaleDiv *scDiv = plot->axisScaleDiv(oldMainAxis); if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop) plot->setAxisScale(xAxis, scDiv->lBound(), scDiv->hBound()); else if (axis == QwtPlot::yLeft || color_axis == QwtPlot::yRight) plot->setAxisScale(yAxis, scDiv->lBound(), scDiv->hBound()); colorAxis = plot->axisWidget(color_axis); plot->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue()); colorAxis->setColorBarEnabled(on); colorAxis->setColorMap(data().range(), colorMap()); if (!plot->axisEnabled(color_axis)) plot->enableAxis(color_axis); colorAxis->show(); plot->updateLayout(); }
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(); }
/** * Tworzy wykres spektrogramu. * * Przygotowuje mapowanie kolorów, skale osi we właściwych jednostkach itp. * * @param parent obiekt rodzica */ SpectrogramPlot::SpectrogramPlot(QWidget* parent): QwtPlot(tr("Wave file not loaded"), parent) { spectrogram = new QwtPlotSpectrogram(); QwtLinearColorMap colorMap(Qt::black, Qt::red); colorMap.addColorStop(0.3, Qt::darkBlue); colorMap.addColorStop(0.4, Qt::blue); colorMap.addColorStop(0.65, Qt::green); colorMap.addColorStop(0.85, Qt::yellow); spectrogram->setColorMap(colorMap); // kolorowa prawa oś QwtScaleWidget *rightAxis = axisWidget(yRight); rightAxis->setTitle(tr("Intensity [dB]")); rightAxis->setColorBarEnabled(true); enableAxis(yRight); spectrogram->attach(this); const QFontMetrics fmRight(rightAxis->font()); int intensityWidth = rightAxis->colorBarWidth() + fmRight.width("888 888"); axisScaleDraw(yRight)->setMinimumExtent(intensityWidth); QwtPlotPanner *panner = new QwtPlotPanner(canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); panner->setMouseButton(Qt::MidButton); // dolna oś setAxisScaleDraw(xBottom, new DurationScaleDraw()); }
void SaxsviewImage::Private::setupScales(SaxsviewImage *image) { QwtPlotScaleItem *yRight = new QwtPlotScaleItem(QwtScaleDraw::LeftScale); yRight->scaleDraw()->enableComponent(QwtAbstractScaleDraw::Labels, false); yRight->attach(image); yRight->setBorderDistance(1); scales[QwtPlot::yRight] = yRight; QwtPlotScaleItem *yLeft = new QwtPlotScaleItem(QwtScaleDraw::RightScale); yLeft->scaleDraw()->enableComponent(QwtAbstractScaleDraw::Labels, false); yLeft->attach(image); yLeft->setBorderDistance(0); scales[QwtPlot::yLeft] = yLeft; QwtPlotScaleItem *xTop = new QwtPlotScaleItem(QwtScaleDraw::BottomScale); xTop->scaleDraw()->enableComponent(QwtAbstractScaleDraw::Labels, false); xTop->attach(image); xTop->setBorderDistance(0); scales[QwtPlot::xTop] = xTop; QwtPlotScaleItem *xBottom = new QwtPlotScaleItem(QwtScaleDraw::TopScale); xBottom->scaleDraw()->enableComponent(QwtAbstractScaleDraw::Labels, false); xBottom->attach(image); xBottom->setBorderDistance(1); scales[QwtPlot::xBottom] = xBottom; SaxsviewScaleDraw *scaleDraw; scaleDraw = new SaxsviewScaleDraw; scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); scaleDraw->enableComponent(QwtAbstractScaleDraw::Ticks, false); image->setAxisScaleDraw(QwtPlot::yLeft, scaleDraw); scaleDraw = new SaxsviewScaleDraw; scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); scaleDraw->enableComponent(QwtAbstractScaleDraw::Ticks, false); image->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw); image->axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating, false); // // A color bar on the right axis. // QwtScaleWidget *rightAxis = image->axisWidget(QwtPlot::yRight); rightAxis->setTitle("Counts"); rightAxis->setColorBarEnabled(true); image->enableAxis(QwtPlot::yRight); image->plotLayout()->setAlignCanvasToScales(true); // // Allow rescaling to a fixed aspect ratio - but exempt // the color bar on the right axis. // rescaler = new QwtPlotRescaler(image->canvas(), QwtPlot::xBottom, QwtPlotRescaler::Fixed); rescaler->setAspectRatio(QwtPlot::yRight, 0.0); rescaler->setEnabled(false); }
Plot::Plot( QWidget *parent ): QwtPlot( parent ), d_formatType( 0 ), d_alpha(255) { d_spectrogram = new QwtPlotSpectrogram(); d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count d_spectrogram->setCachePolicy( QwtPlotRasterItem::PaintCache ); QList<double> contourLevels; for ( double level = 0.5; level < 10.0; level += 1.0 ) contourLevels += level; d_spectrogram->setContourLevels( contourLevels ); d_spectrogram->setData( new SpectrogramData() ); d_spectrogram->attach( this ); const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); // A color bar on the right axis QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight ); rightAxis->setTitle( "Intensity" ); rightAxis->setColorBarEnabled( true ); setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() ); enableAxis( QwtPlot::yRight ); plotLayout()->setAlignCanvasToScales( true ); setColorMap( Plot::RGBMap ); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size QwtPlotZoomer* zoomer = new MyZoomer( canvas() ); zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier ); zoomer->setMousePattern( QwtEventPattern::MouseSelect3, Qt::RightButton ); QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); panner->setAxisEnabled( QwtPlot::yRight, false ); panner->setMouseButton( Qt::MidButton ); // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically const QFontMetrics fm( axisWidget( QwtPlot::yLeft )->font() ); QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft ); sd->setMinimumExtent( fm.width( "100.00" ) ); const QColor c( Qt::darkBlue ); zoomer->setRubberBandPen( c ); zoomer->setTrackerPen( c ); }
void matrixofpixels::PixPlotSpect(int TypeOfSpec,QwtMatrixRasterData *rasterpixdata) { changeitems(); MapPlot->setData(rasterpixdata); MapPlot->setRenderThreadCount(0); setAxisAutoScale(this->xTop); setAxisAutoScale(this->xBottom); switch (TypeOfSpec) { case 1: MapPlot->setColorMap(new ColorMap(BLUERED)); break; case 2: MapPlot->setColorMap(new ColorMap(BLACKWHITE)); break; default: MapPlot->setColorMap(new ColorMap(BLUERED)); } MapPlot->attach(/*MainPlot*/this); const QwtInterval zInterval = MapPlot->data()->interval(Qt::ZAxis); setAxisScale(QwtPlot::xBottom, 0, Npix); setAxisMaxMinor(QwtPlot::xBottom, 0); setAxisScale(QwtPlot::yLeft, 0, Npix); setAxisMaxMinor(QwtPlot::yLeft, 0); //rightAxis = new QwtScaleWidget(); QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); //rightAxis = axisWidget(QwtPlot::yRight); rightAxis->setColorBarEnabled(true); rightAxis->setColorBarWidth(20); rightAxis->setColorMap(zInterval, new ColorMap(TypeOfSpec) ); //ColorMap(TypeOfSpec); plotLayout()->setAlignCanvasToScales(true); setAxisScale(QwtPlot::yRight,zInterval.minValue(),zInterval.maxValue()); enableAxis(QwtPlot::yRight); replot(); setAutoFillBackground(true); /** setAutoFillBackground(true); - autozapolnenie, ctobi isklyuchit' nalozjeniya graphikov */ }
SectionWindow::SectionWindow(QWidget *parent): QMainWindow(parent) { m_data = new RasterData(); m_plot = new QwtPlot(parent); m_spect = new QwtPlotSpectrogram(); m_spect->setColorMap(QwtLinearColorMap(Qt::darkCyan, Qt::red)); m_spect->setData(*m_data); m_spect->attach(m_plot); m_plot->axisWidget(QwtPlot::xBottom)->setTitle("Band (index)"); m_plot->axisWidget(QwtPlot::yLeft)->setTitle("Arclength (pixel)"); m_plot->setMargin(5); // A color bar on the right axis QwtScaleWidget *rightAxis = m_plot->axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); m_plot->enableAxis(QwtPlot::yRight); m_plot->plotLayout()->setAlignCanvasToScales(true); m_plot->replot(); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size m_zoomer = new MyZoomer(this, m_plot->canvas()); m_zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); m_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); const QColor c(Qt::darkBlue); m_zoomer->setRubberBandPen(c); m_zoomer->setTrackerPen(c); QwtPlotPanner *panner = new QwtPlotPanner(m_plot->canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); panner->setMouseButton(Qt::MidButton); // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically const QFontMetrics fm(m_plot->axisWidget(QwtPlot::yLeft)->font()); QwtScaleDraw *sd = m_plot->axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); setCentralWidget(m_plot); }
void Spectrogramplot::setZAxisScale(double zMin, double zMax) { zMin_ = zMin; zMax_ = zMax; data_->setInterval( Qt::ZAxis, QwtInterval( zMin_, zMax_ ) ); //Set up the intensity bar on the right const QwtInterval zInterval = spectrogram_->data()->interval( Qt::ZAxis ); QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); rightAxis->setColorBarEnabled(true); rightAxis->setColorMap( zInterval, new ColorMap()); setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() ); enableAxis(QwtPlot::yRight); plotLayout()->setAlignCanvasToScales(true); replot(); }
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); }
Plot::Plot( QWidget *parent ): QwtPlot( parent ) { QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setBorderRadius( 10 ); setCanvas( canvas ); #if 0 QwtPlotGrid *grid = new QwtPlotGrid(); grid->setPen( Qt::DotLine ); grid->attach( this ); #endif d_spectrogram = new QwtPlotSpectrogram(); d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count d_spectrogram->setColorMap( new ColorMap() ); d_spectrogram->setData( new RasterData() ); d_spectrogram->attach( this ); const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); // A color bar on the right axis QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight ); rightAxis->setColorBarEnabled( true ); rightAxis->setColorBarWidth( 40 ); rightAxis->setColorMap( zInterval, new ColorMap() ); setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() ); enableAxis( QwtPlot::yRight ); plotLayout()->setAlignCanvasToScales( true ); setAxisScale( QwtPlot::xBottom, 0.0, 3.0 ); setAxisMaxMinor( QwtPlot::xBottom, 0 ); setAxisScale( QwtPlot::yLeft, 0.0, 3.0 ); setAxisMaxMinor( QwtPlot::yLeft, 0 ); QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas ); magnifier->setAxisEnabled( QwtPlot::yRight, false ); QwtPlotPanner *panner = new QwtPlotPanner( canvas ); panner->setAxisEnabled( QwtPlot::yRight, false ); }
Plot::Plot(QWidget *parent): QwtPlot(parent) { d_spectrogram = new QwtPlotSpectrogram(); QwtLinearColorMap colorMap(Qt::darkCyan, Qt::red); colorMap.addColorStop(0.1, Qt::cyan); colorMap.addColorStop(0.6, Qt::green); colorMap.addColorStop(0.95, Qt::yellow); d_spectrogram->setColorMap(colorMap); d_spectrogram->setData(SpectrogramData()); d_spectrogram->attach(this); QwtValueList contourLevels; for ( double level = 0.5; level < 10.0; level += 1.0 ) contourLevels += level; d_spectrogram->setContourLevels(contourLevels); QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap()); setAxisScale(QwtPlot::yRight, d_spectrogram->data().range().minValue(), d_spectrogram->data().range().maxValue() ); enableAxis(QwtPlot::yRight); plotLayout()->setAlignCanvasToScales(true); replot(); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas()); #if QT_VERSION < 0x040000 zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); #else zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); #endif zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); QwtPlotPanner *panner = new QwtPlotPanner(canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); panner->setMouseButton(Qt::MidButton); // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); const QColor c(Qt::darkBlue); zoomer->setRubberBandPen(c); zoomer->setTrackerPen(c); }
SpectrogramPlot::SpectrogramPlot( QWidget *parent ) : QwtPlot(parent) , impl_( new impl( this ) ) { impl_->spectrogram_->setRenderThreadCount( 0 ); // use system specific thread count impl_->spectrogram_->setColorMap( new ColorMap() ); impl_->spectrogram_->setCachePolicy( QwtPlotRasterItem::PaintCache ); impl_->spectrogram_->setData( impl_->drawable_ ); impl_->spectrogram_->attach( this ); impl_->marker_->attach( this ); // QList<double> contourLevels; // for ( double level = 0.5; level < 10.0; level += 1.0 ) // contourLevels += level; // impl_->spectrogram_->setContourLevels( contourLevels ); const QwtInterval zInterval = impl_->spectrogram_->data()->interval( Qt::ZAxis ); // A color bar on the right axis QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight ); rightAxis->setTitle( "Intensity" ); rightAxis->setColorBarEnabled( true ); // rightAxis->setColorMap( zInterval, new ColorMap() ); setAxisZMax( 10.0 ); //setAxisScale( QwtPlot::xBottom, 0, 64 ); //setAxisScale( QwtPlot::yLeft, 64, 0 ); axisScaleEngine( QwtPlot::xBottom )->setAttribute( QwtScaleEngine::Floating, true ); axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Floating, true ); axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Inverted, true ); setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue()); enableAxis( QwtPlot::yRight ); plotLayout()->setAlignCanvasToScales( true ); replot(); if ( auto zoomer = new adplot::Zoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() ) ) { const QColor c( 0xe0, 0xff, 0xff, 0x40 ); // lightcyan zoomer->setRubberBandPen( c ); zoomer->setTrackerPen( c ); zoomer->setTrackerMode( QwtPlotPicker::ActiveOnly ); } QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); panner->setAxisEnabled( QwtPlot::yRight, false ); panner->setMouseButton( Qt::MidButton ); if ( auto picker = new adplot::Picker( canvas() ) ) { //picker->setStateMachine( new QwtPickerClickPointMachine() ); picker->setStateMachine( new QwtPickerDragRectMachine() ); picker->setRubberBand( QwtPicker::RectRubberBand ); picker->setRubberBandPen( QColor( Qt::red ) ); picker->setTrackerPen( QColor( Qt::white ) ); picker->setMousePattern( QwtEventPattern::MouseSelect1, Qt::RightButton ); picker->setTrackerMode( QwtPicker::AlwaysOff ); picker->setEnabled( true ); connect( picker, static_cast<void( QwtPlotPicker::* )( const QPointF& )>( &QwtPlotPicker::selected ), this, [this] ( const QPointF& p ) { impl_->marker_->setRect( p ); replot(); emit cellSelected( impl_->marker_->rect() ); } ); connect( picker, static_cast<void( QwtPlotPicker::* )( const QRectF& )>( &QwtPlotPicker::selected ), this, [this] ( const QRectF& rc ) { impl_->marker_->setRect( rc ); replot(); emit cellSelected( impl_->marker_->rect() ); } ); } QFont font; qtwrapper::font::setFont( font, qtwrapper::fontSizeSmall, qtwrapper::fontAxisLabel ); setAxisFont( QwtPlot::xBottom, font ); setAxisFont( QwtPlot::yLeft, font ); // Set fixed 'extent' for axis in order to avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically const QFontMetrics fm( axisWidget( QwtPlot::yLeft )->font() ); QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft ); sd->setMinimumExtent( fm.width( "888.0" ) ); setContextMenuPolicy( Qt::CustomContextMenu ); }
void ComponentPlotter::plot(bool zoom) { qwt_plot_->clear(); if(component_matrix_==NULL||component_matrix_->cols()==0) calculateComponents(); if(component_matrix_==NULL||component_matrix_->cols()<2) return; // only 1 component double min_y=1e10; double max_y=-1e10; double min_x=1e10; double max_x=-1e10; const vector<string>* feature_names; if(!plot_loadings_) feature_names = model_item_->model()->getSubstanceNames(); else feature_names = model_item_->model()->getDescriptorNames(); const unsigned int size = feature_names->size(); unsigned int comp_one=component_one_combobox_->itemData(component_one_combobox_->currentIndex()).toInt(); unsigned int comp_two=component_two_combobox_->itemData(component_two_combobox_->currentIndex()).toInt(); QwtLinearColorMap color_map; color_map.setColorInterval(QColor(255,0,0),QColor(0,255,0)); QwtDoubleInterval interval(min_response_value_,max_response_value_); const QSARData* data = model_item_->inputDataItem()->data(); for(unsigned int j=1; j<=size; j++) { QwtPlotMarker* marker= new QwtPlotMarker; QwtSymbol symbol = data_symbol; if(!plot_loadings_) { vector<double>* resp = data->getActivity(j-1); double response_value = (*resp)[selected_activity_]; delete resp; QBrush b(QColor(color_map.rgb(interval,response_value)),Qt::SolidPattern); symbol.setBrush(b); } double x_j = (*component_matrix_)(j,comp_one); double y_j = (*component_matrix_)(j,comp_two); if(y_j<min_y) min_y=y_j; if(y_j>max_y) max_y=y_j; if(x_j<min_x) min_x=x_j; if(x_j>max_x) max_x=x_j; marker->setSymbol(symbol); marker->setValue(x_j,y_j); marker->attach(qwt_plot_); // attached object will be automatically deleted by QwtPlot if(show_data_labels) { QString s =(*feature_names)[j-1].c_str(); QwtText label(s); label.setFont(data_label_font); marker->setLabel(label); marker->setLabelAlignment(data_label_alignment); } } QString s1 = component_one_combobox_->itemText(component_one_combobox_->currentIndex()); QString s2 = component_two_combobox_->itemText(component_two_combobox_->currentIndex()); LatentVariableModel* lv_model = dynamic_cast<LatentVariableModel*>(model_item_->model()); const Eigen::MatrixXd* weights = lv_model->getWeights(); if(!plot_loadings_) { s1 += " c="; s1+=String((*weights)(comp_one,1)).c_str(); s2 += " c="; s2+=String((*weights)(comp_two,1)).c_str(); } qwt_plot_->setAxisTitle(QwtPlot::yLeft,s2); qwt_plot_->setAxisTitle(QwtPlot::xBottom,s1); double x_border=(max_x-min_x)*0.05; double y_border=(max_y-min_y)*0.05; min_x-=x_border; min_y-=y_border; max_x+=x_border; max_y+=y_border; QwtPlotCurve* zero_line = new QwtPlotCurve; QwtPlotCurve* zero_line2 = new QwtPlotCurve; double x[2]; x[0]=min_x; x[1]=max_x; double y[2]; y[0]=0; y[1]=0; zero_line->setData(x,y,2); x[0]=0; x[1]=0; y[0]=min_y; y[1]=max_y; zero_line2->setData(x,y,2); QColor c(135,135,135); // grey QPen pen(c); zero_line->setPen(pen); zero_line->attach(qwt_plot_); zero_line2->setPen(pen); zero_line2->attach(qwt_plot_); if(zoom) { qwt_plot_->setAxisScale(QwtPlot::yLeft,min_y,max_y); qwt_plot_->setAxisScale(QwtPlot::xBottom,min_x,max_x); } if(!plot_loadings_) { QwtScaleWidget* rightAxis = qwt_plot_->axisWidget(QwtPlot::yRight); rightAxis->setTitle("response value"); rightAxis->setColorBarEnabled(true); rightAxis->setColorMap(interval,color_map); qwt_plot_->setAxisScale(QwtPlot::yRight,min_response_value_,max_response_value_); } }
void caWaterfallPlot::setColormap(colormap const &map) { thisColormap = map; setPropertyVisible(customcolormap, false); setPropertyVisible(discretecolormap, false); // A color bar on the right axis QwtScaleWidget *rightAxis = plot->axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); plot->setAxisScale(QwtPlot::yRight, thisIntensityMin, thisIntensityMax); plot->enableAxis(QwtPlot::yRight); switch (map) { case grey: d_spectrogram->setColorMap(new ColorMap_Grey()); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Grey()); thisColormap = grey; break; case spectrum_wavelength: d_spectrogram->setColorMap(new ColorMap_Wavelength()); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Wavelength()); thisColormap = spectrum_wavelength; break; case spectrum_hot: d_spectrogram->setColorMap(new ColorMap_Hot()); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Hot()); thisColormap = spectrum_hot; break; case spectrum_heat: d_spectrogram->setColorMap(new ColorMap_Heat()); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Heat()); thisColormap = spectrum_heat; break; case spectrum_jet: d_spectrogram->setColorMap(new ColorMap_Jet()); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Jet()); thisColormap = spectrum_jet; break; case spectrum_custom: { int *colorIndexes=NULL; setPropertyVisible(customcolormap, true); setPropertyVisible(discretecolormap, true); // user has the possibility to input its own colormap with discrete QtColors from 2 t0 18 // when nothing given, fallback to default colormap if(thisCustomMap.count() > 2) { colorIndexes=(int *) malloc(thisCustomMap.count()*sizeof(int)); // get the discrete colors for(int i=0; i< thisCustomMap.count(); i++) { bool ok; int index = thisCustomMap.at(i).toInt(&ok); if(ok) colorIndexes[i] = index; else colorIndexes[i] = 2; // black if(colorIndexes[i] < 2) colorIndexes[i] = 2; if(colorIndexes[i] > 18) colorIndexes[i] = 18; } // create colormap ColorMap_Custom * colormap = new ColorMap_Custom(); colormap->initColormap(colorIndexes, thisCustomMap.count(), thisDiscreteMap); d_spectrogram->setColorMap(colormap); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), colormap); free(colorIndexes); thisColormap = spectrum_custom; } else { d_spectrogram->setColorMap(new ColorMap_Wavelength()); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Wavelength()); thisColormap = spectrum_wavelength; } } break; default: d_spectrogram->setColorMap(new ColorMap_Wavelength()); rightAxis->setColorMap(QwtInterval(thisIntensityMin, thisIntensityMax), new ColorMap_Wavelength()); thisColormap = spectrum_wavelength; break; } myReplot(); }