bool ScalePicker::eventFilter(QObject *object, QEvent *e)
{
	if (!object->inherits("QwtScaleWidget"))
		return QObject::eventFilter(object, e);

	QwtScaleWidget *scale = (QwtScaleWidget *)object;
	d_current_axis = scale;

	if ( e->type() == QEvent::MouseButtonDblClick ){
		mouseDblClicked(scale, ((QMouseEvent *)e)->pos());
		return true;
	}

	if ( e->type() == QEvent::MouseButtonPress){
		const QMouseEvent *me = (const QMouseEvent *)e;
		QPoint pos = me->pos();
		if (me->button() == Qt::LeftButton){
			scale->setFocus();
			emit clicked();

			deselect();

			if (titleRect(scale).contains(pos))
				selectTitle(scale);
			else if (!scaleTicksRect(scale).contains(pos))
				selectLabels(scale);

			return !(me->modifiers() & Qt::ShiftModifier) && !scaleTicksRect(scale).contains(pos);
		} else if (me->button() == Qt::RightButton){
			mouseRightClicked(scale, pos);
			return true;
		}
	}
	return QObject::eventFilter(object, e);
}
Example #2
0
void Spectrogram::postDataUpdate()
{
  auto *plot = this->plot();
  setLevelsNumber(levels());

  QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
  if (colorAxis)
  {
    colorAxis->setColorMap(data().range(), colorMap());
  }

  plot->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue());

  if ( d_wsData )
  {
    auto workspace = d_wsData->getWorkspace();
    if ( workspace )
    {
      using MantidQt::API::PlotAxis;
      plot->setAxisTitle(QwtPlot::xBottom,  PlotAxis(*workspace, 0).title());
      plot->setAxisTitle(QwtPlot::yLeft, PlotAxis(*workspace, 1).title());
    }
  }

  plot->replot();
}
Example #3
0
void PlotMatrix::alignVAxes( int col, int axis )
{
    if ( axis != QwtPlot::yLeft && axis != QwtPlot::yRight )
        return;

    double maxExtent = 0;
    for ( int row = 0; row < numRows(); row++ )
    {
        QwtPlot *p = plot( row, col );
        if ( p )
        {
            QwtScaleWidget *scaleWidget = p->axisWidget( axis );

            QwtScaleDraw *sd = scaleWidget->scaleDraw();
            sd->setMinimumExtent( 0.0 );

            const double extent = sd->extent( scaleWidget->font() );
            if ( extent > maxExtent )
                maxExtent = extent;
        }
    }
    for ( int row = 0; row < numRows(); row++ )
    {
        QwtPlot *p = plot( row, col );
        if ( p )
        {
            QwtScaleWidget *scaleWidget = p->axisWidget( axis );
            scaleWidget->scaleDraw()->setMinimumExtent( maxExtent );
        }
    }
}
/**
 * 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());
}
Example #5
0
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();
}
Example #6
0
void ScalePicker::determinePosition(const QPoint &pos, int coord)
{
  QwtScaleWidget *scale = static_cast<QwtScaleWidget *>(this->parent());
  QRect rect = this->scaleRect(scale);
  QPoint shiftPt;
  if (coord == 0)
  {
    if (QwtScaleDraw::LeftScale == scale->alignment())
    {
      shiftPt.setX(rect.right());
      shiftPt.setY(pos.y());
    }
    if (QwtScaleDraw::RightScale == scale->alignment())
    {
      shiftPt.setX(rect.left());
      shiftPt.setY(pos.y());
    }
  }
  if (coord == 1)
  {
    if (QwtScaleDraw::TopScale == scale->alignment())
    {
      shiftPt.setX(pos.x());
      shiftPt.setY(rect.bottom());
    }
    if (QwtScaleDraw::BottomScale == scale->alignment())
    {
      shiftPt.setX(pos.x());
      shiftPt.setY(rect.top());
    }
  }
  this->mouseClicked(scale, shiftPt, false);
}
int Spectrogram::colorBarWidth()
{
	if (!d_graph)
		return 0;

	QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis);
	return colorAxis->colorBarWidth();
}
void ScalePicker::refresh()
{
	for ( uint i = 0; i < QwtPlot::axisCnt; i++ ){
		QwtScaleWidget *scale = (QwtScaleWidget *)plot()->axisWidget(i);
		if ( scale )
			scale->installEventFilter(this);
	}
}
void Spectrogram::setColorBarWidth(int width)
{
	if (!d_graph)
		return;

	QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis);
	colorAxis->setColorBarWidth(width);
}
Example #10
0
void Spectrogram::setColorBarWidth(int width) {
  QwtPlot *plot = this->plot();
  if (!plot)
    return;

  QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
  colorAxis->setColorBarWidth(width);
}
Example #11
0
int Spectrogram::colorBarWidth() {
  QwtPlot *plot = this->plot();
  if (!plot)
    return 0;

  QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
  return colorAxis->colorBarWidth();
}
Example #12
0
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);
}
Example #13
0
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 );
}
Example #14
0
ScalePicker::ScalePicker( QwtPlot *plot ):
    QObject( plot )
{
    for ( uint i = 0; i < QwtPlot::axisCnt; i++ )
    {
        QwtScaleWidget *scaleWidget = plot->axisWidget( i );
        if ( scaleWidget )
            scaleWidget->installEventFilter( this );
    }
}
Example #15
0
void SaxsviewFrame::setMaxValue(double x) {
  if (SaxsviewFrameData *d = dynamic_cast<SaxsviewFrameData*>(data())) {
    d->setMaxValue(x);

    QwtScaleWidget *scale = plot()->axisWidget(QwtPlot::yRight);
    scale->setColorBarInterval(data()->interval(Qt::ZAxis));

    plot()->replot();
  }
}
void RasterData::flush()
{
  QwtInterval zInterval(0.0, qMax(qLn(max), 1.0));
  setInterval(Qt::ZAxis, zInterval);

  QwtScaleWidget *rightAxis = s->axisWidget(QwtPlot::yRight);
  rightAxis->setColorMap(zInterval, new ColorMap());

  s->setAxisScale(QwtPlot::yRight, 0.0, zInterval.maxValue());
}
Example #17
0
bool Spectrogram::hasColorScale() {
  QwtPlot *plot = this->plot();
  if (!plot)
    return false;

  if (!plot->axisEnabled(color_axis))
    return false;

  QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
  return colorAxis->isColorBarEnabled();
}
Example #18
0
void caStripPlot::setScaleColor(QColor c)
{
    QwtScaleWidget *scaleX =axisWidget(QwtPlot::xBottom);
    QwtScaleWidget *scaleY =axisWidget(QwtPlot::yLeft);
    thisScaleColor = c;
    QPalette palette = scaleX->palette();
    palette.setColor( QPalette::WindowText, c); // for ticks
    palette.setColor( QPalette::Text, c);       // for ticks' labels
    scaleX->setPalette( palette);
    scaleY->setPalette (palette);
    titleLabel()->setPalette(palette);
}
Example #19
0
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 Spectrogram::setCustomColorMap(const QwtLinearColorMap& map)
{
	setColorMap(map);
	color_map = map;
	color_map_policy = Custom;

	if (!d_graph)
		return;

	QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis);
	if (colorAxis)
		colorAxis->setColorMap(range(), colorMap());
}
void Spectrogram::setDefaultColorMap()
{
	if (!d_graph)
		return;

	color_map = d_graph->multiLayer()->applicationWindow()->d_3D_color_map;
	setColorMap(color_map);
	color_map_policy = Default;

	QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis);
	if (colorAxis)
		colorAxis->setColorMap(range(), colorMap());
}
void Spectrogram::setGrayScale()
{
	color_map = QwtLinearColorMap(Qt::black, Qt::white);
	setColorMap(color_map);
	color_map_policy = GrayScale;

	if (!d_graph)
		return;

	QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis);
	if (colorAxis)
		colorAxis->setColorMap(range(), colorMap());
}
Example #24
0
void Spectrogram::setCustomColorMap(const QwtColorMap &map) {
  setColorMap(map);
  // color_map = map;
  color_map_policy = Custom;
  QwtPlot *plot = this->plot();
  if (!plot)
    return;

  QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
  if (colorAxis) {
    colorAxis->setColorMap(this->data().range(), this->getColorMap());
  }
}
// Init X axis.
void DataPlot::initAxisX()
{
    //QwtText xTitle("System Uptime [h:m:s]");
    //xTitle.setFont(QFont("Ubuntu", 10));
    //setAxisTitle(QwtPlot::xBottom, xTitle);
    setAxisScaleDraw(QwtPlot::xBottom,new TimeScaleDraw(upTime()));
    setAxisScale(QwtPlot::xBottom, 0, PLOT_SIZE );
    setAxisLabelRotation(QwtPlot::xBottom, -50.0);
    setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
    QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
    const int fmh = QFontMetrics(scaleWidget->font()).height();
    scaleWidget->setMinBorderDist(0, fmh / 2);
}
Example #26
0
double Graph::getAxisPosPct(int axis, const QPoint &pos)
{
    QwtScaleWidget *w = axisWidget(axis);
    switch(axis)
    {
        case QwtPlot::yLeft:
        case QwtPlot::yRight:
            return 1.0 - (double(pos.y() - w->pos().y()) / w->height());
        case QwtPlot::xTop:
        case QwtPlot::xBottom:
            return (double(pos.x() - w->pos().x()) / w->width());
    }
    return 0.5;
}
void Spectrogram::setDefaultColorMap()
{
color_map = defaultColorMap();
setColorMap(color_map);
color_map_policy = Default;

QwtPlot *plot = this->plot();
if (!plot)
	return;

QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
if (colorAxis)
	colorAxis->setColorMap(this->data().range(), this->colorMap());
}
Example #28
0
VectorPlot::VectorPlot(QWidget *parent, const QString &title, SetLegend * externalLegend)
    : QWidget(parent), legend(externalLegend)
{
	this->setMinimumHeight(200);
	
	QwtText titleText(title);
	QFont titleTextFont(titleText.font());
	titleTextFont.setPointSize(10);
	titleText.setFont(titleTextFont);
	plot = new QwtPlot(titleText, this);

	plot->setCanvasBackground(Qt::white);

	//plot->setGeometry(ui.widget_plot->geometry());

	plot->setAxisScale(QwtPlot::xBottom, 0, 0.01);
	plot->setAxisScale(QwtPlot::yLeft, 0, 0.01);

	for ( int i = 0; i < QwtPlot::axisCnt; i++ )
    {
    	plot->setAxisAutoScale(i);
        QwtScaleWidget *scaleWidget = (QwtScaleWidget *)plot->axisWidget(i);
        if ( scaleWidget )
            scaleWidget->setMargin(0);

        QwtScaleDraw *scaleDraw = (QwtScaleDraw *)plot->axisScaleDraw(i);
        if ( scaleDraw )
            scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false);
    }
	plot->canvas()->setFrameStyle(QFrame::Box|QFrame::Plain);
	plot->setAutoReplot(true);

	//plot->setMinimumSize(QSize(200, 200));
	//this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
	plot->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
	
	QPen pen(QColor(255, 0, 0));
	
	marker1 = new QwtPlotMarker();
	marker1->setLineStyle(QwtPlotMarker::VLine);
	marker1->setLinePen(pen);
	marker1->setXValue(0);
	
	marker2 = new QwtPlotMarker();
	marker2->setLineStyle(QwtPlotMarker::VLine);
	marker2->setLinePen(pen);
	marker2->setXValue(0);	

	zoomer = 0;
}
QString Spectrogram::saveToString()
{
QString s = "<spectrogram>\n";
s += "\t<matrix>" + QString(d_matrix->objectName()) + "</matrix>\n";

if (color_map_policy != Custom)
	s += "\t<ColorPolicy>" + QString::number(color_map_policy) + "</ColorPolicy>\n";
else
	{
	s += "\t<ColorMap>\n";
	s += "\t\t<Mode>" + QString::number(color_map.mode()) + "</Mode>\n";
	s += "\t\t<MinColor>" + color_map.color1().name() + "</MinColor>\n";
	s += "\t\t<MaxColor>" + color_map.color2().name() + "</MaxColor>\n";
	QwtArray <double> colors = color_map.colorStops();
	int stops = (int)colors.size();
	s += "\t\t<ColorStops>" + QString::number(stops - 2) + "</ColorStops>\n";
	for (int i = 1; i < stops - 1; i++)
		{
		s += "\t\t<Stop>" + QString::number(colors[i]) + "\t";
		s += QColor(color_map.rgb(QwtDoubleInterval(0,1), colors[i])).name();
		s += "</Stop>\n";
		}
	s += "\t</ColorMap>\n";
	}
s += "\t<Image>"+QString::number(testDisplayMode(QwtPlotSpectrogram::ImageMode))+"</Image>\n";

bool contourLines = testDisplayMode(QwtPlotSpectrogram::ContourMode);
s += "\t<ContourLines>"+QString::number(contourLines)+"</ContourLines>\n";
if (contourLines)
	{
	s += "\t\t<Levels>"+QString::number(levels())+"</Levels>\n";
	bool defaultPen = defaultContourPen().style() != Qt::NoPen;
	s += "\t\t<DefaultPen>"+QString::number(defaultPen)+"</DefaultPen>\n";
	if (defaultPen)
		{
		s += "\t\t\t<PenColor>"+defaultContourPen().color().name()+"</PenColor>\n";
		s += "\t\t\t<PenWidth>"+QString::number(defaultContourPen().widthF())+"</PenWidth>\n";
		s += "\t\t\t<PenStyle>"+QString::number(defaultContourPen().style() - 1)+"</PenStyle>\n";
		}
	}
QwtScaleWidget *colorAxis = plot()->axisWidget(color_axis);
if (colorAxis && colorAxis->isColorBarEnabled())
	{
	s += "\t<ColorBar>\n\t\t<axis>" + QString::number(color_axis) + "</axis>\n";
	s += "\t\t<width>" + QString::number(colorAxis->colorBarWidth()) + "</width>\n";
	s += "\t</ColorBar>\n";
	}
s += "\t<Visible>"+ QString::number(isVisible()) + "</Visible>\n";
return s+"</spectrogram>\n";
}
bool Spectrogram::hasColorScale()
{
	if (!d_graph)
		return false;

	if (!d_graph->axisEnabled (color_axis))
		return false;

	QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis);
	if (colorAxis)
		return colorAxis->isColorBarEnabled();

	return false;
}