class PolarPlot: public QwtPolarPlot
{
Q_OBJECT
public:
void add_curve
(QString name, PolarCurve
* curve
);
//void update_curve(QString name, double * r, double *t);
virtual void replot();
private:
QwtPolarGrid *d_grid;
QwtInterval _radialInterval;
QwtInterval _azimuthInterval;
};
QwtPolarPlot
( QwtText( name
), parent
){
setAutoReplot( false );
setPlotBackground
( QColor("#ffffb3"));
_radialInterval.setMinValue(0);
_radialInterval.setMaxValue(360.0);
_azimuthInterval.setMinValue(0);
_azimuthInterval.setMaxValue(360.0);
setScale( QwtPolar::ScaleRadius,
_azimuthInterval.minValue(), _azimuthInterval.maxValue(),
_azimuthInterval.width());
setScaleMaxMinor( QwtPolar::Azimuth, 2 );
setScale( QwtPolar::ScaleRadius,
_radialInterval.minValue(), _radialInterval.maxValue() );
// grids, axes
d_grid = new QwtPolarGrid();
d_grid
->setPen
( QPen(Qt
::darkGray) );
for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
{
d_grid->showGrid( scaleId );
d_grid->showMinorGrid( scaleId );
QPen minorPen
( Qt
::gray );
d_grid->setMinorGridPen( scaleId, minorPen );
}
d_grid
->setAxisPen
( QwtPolar
::AxisAzimuth,
QPen( Qt
::black ) );
d_grid
->setAxisPen
( QwtPolar
::AxisTop,
QPen( Qt
::red ) );
d_grid
->setAxisPen
( QwtPolar
::AxisRight,
QPen( Qt
::black ) );
d_grid
->setAxisPen
( QwtPolar
::AxisLeft,
QPen( Qt
::black ) );
d_grid
->setAxisPen
( QwtPolar
::AxisBottom,
QPen( Qt
::black ) );
d_grid->showAxis( QwtPolar::AxisAzimuth, true);
d_grid->showAxis( QwtPolar::AxisTop, true); // <-unless this and all non azimuth axes are false, I get heap corruption
d_grid->showAxis( QwtPolar::AxisRight, false);
d_grid->showAxis( QwtPolar::AxisLeft, false );
d_grid->showAxis( QwtPolar::AxisBottom, false );
d_grid->showGrid( QwtPolar::Azimuth, true);
d_grid->showGrid( QwtPolar::Radius, true );
d_grid->attach( this );
// curves
/*for ( int curveId = 0; curveId < PlotSettings::NumCurves; curveId++ )
{
d_curve[curveId] = createCurve( curveId );
d_curve[curveId]->attach( this );
}*/
// markers
/*QwtPolarMarker *marker = new QwtPolarMarker();
marker->setPosition( QwtPointPolar( 57.3, 4.72 ) );
marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
QBrush( Qt::white ), QPen( Qt::green ), QSize( 9, 9 ) ) );
marker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
QwtText text( "Marker" );
text.setColor( Qt::black );
QColor bg( Qt::white );
bg.setAlpha( 200 );
text.setBackgroundBrush( QBrush( bg ) );
marker->setLabel( text );
marker->attach( this );
QwtLegend *legend = new QwtLegend;
insertLegend( legend, QwtPolarPlot::BottomLegend );*/
}
class PolarPlot: public QwtPolarPlot
{
Q_OBJECT
public:
PolarPlot( QString name, QWidget * = NULL );
void add_curve(QString name, PolarCurve * curve);
//void update_curve(QString name, double * r, double *t);
virtual void replot();
private:
QwtPolarGrid *d_grid;
QwtInterval _radialInterval;
QwtInterval _azimuthInterval;
};
PolarPlot::PolarPlot( QString name, QWidget *parent ):
QwtPolarPlot( QwtText( name ), parent )
{
setAutoReplot( false );
setPlotBackground( QColor("#ffffb3"));
_radialInterval.setMinValue(0);
_radialInterval.setMaxValue(360.0);
_azimuthInterval.setMinValue(0);
_azimuthInterval.setMaxValue(360.0);
setScale( QwtPolar::ScaleRadius,
_azimuthInterval.minValue(), _azimuthInterval.maxValue(),
_azimuthInterval.width());
setScaleMaxMinor( QwtPolar::Azimuth, 2 );
setScale( QwtPolar::ScaleRadius,
_radialInterval.minValue(), _radialInterval.maxValue() );
// grids, axes
d_grid = new QwtPolarGrid();
d_grid->setPen( QPen(Qt::darkGray) );
for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
{
d_grid->showGrid( scaleId );
d_grid->showMinorGrid( scaleId );
QPen minorPen( Qt::gray );
d_grid->setMinorGridPen( scaleId, minorPen );
}
d_grid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ) );
d_grid->setAxisPen( QwtPolar::AxisTop, QPen( Qt::red ) );
d_grid->setAxisPen( QwtPolar::AxisRight, QPen( Qt::black ) );
d_grid->setAxisPen( QwtPolar::AxisLeft, QPen( Qt::black ) );
d_grid->setAxisPen( QwtPolar::AxisBottom, QPen( Qt::black ) );
d_grid->showAxis( QwtPolar::AxisAzimuth, true);
d_grid->showAxis( QwtPolar::AxisTop, true); // <-unless this and all non azimuth axes are false, I get heap corruption
d_grid->showAxis( QwtPolar::AxisRight, false);
d_grid->showAxis( QwtPolar::AxisLeft, false );
d_grid->showAxis( QwtPolar::AxisBottom, false );
d_grid->showGrid( QwtPolar::Azimuth, true);
d_grid->showGrid( QwtPolar::Radius, true );
d_grid->attach( this );
// curves
/*for ( int curveId = 0; curveId < PlotSettings::NumCurves; curveId++ )
{
d_curve[curveId] = createCurve( curveId );
d_curve[curveId]->attach( this );
}*/
// markers
/*QwtPolarMarker *marker = new QwtPolarMarker();
marker->setPosition( QwtPointPolar( 57.3, 4.72 ) );
marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
QBrush( Qt::white ), QPen( Qt::green ), QSize( 9, 9 ) ) );
marker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
QwtText text( "Marker" );
text.setColor( Qt::black );
QColor bg( Qt::white );
bg.setAlpha( 200 );
text.setBackgroundBrush( QBrush( bg ) );
marker->setLabel( text );
marker->attach( this );
QwtLegend *legend = new QwtLegend;
insertLegend( legend, QwtPolarPlot::BottomLegend );*/
}
To copy to clipboard, switch view to plain text mode
Bookmarks