本文整理汇总了C++中QwtPlotCanvas::setPalette方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCanvas::setPalette方法的具体用法?C++ QwtPlotCanvas::setPalette怎么用?C++ QwtPlotCanvas::setPalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCanvas
的用法示例。
在下文中一共展示了QwtPlotCanvas::setPalette方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QwtPlot
Plotter::Plotter( QWidget *parent ):
QwtPlot( parent )
{
// Assign a title
setTitle( "WAVE DATA" );
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setLineWidth( 1 );
canvas->setPalette( Qt::white );
setCanvas( canvas );
alignScales();
// Insert grid
d_grid = new QwtPlotGrid();
d_grid->attach( this );
// Axis
setAxisTitle( QwtPlot::xBottom, "Time" );
// setAxisScale( QwtPlot::xBottom, -d_interval, 0.0 );
setAxisTitle( QwtPlot::yLeft, "Amplitude" );
// setAxisScale( QwtPlot::yLeft, -1.0, 1.0 );
resize(600, 350);
}
示例2: canvasPalette
BarChart::BarChart( QWidget *parent ):
QwtPlot( parent )
{
const struct
{
const char *distro;
const int hits;
QColor color;
} pageHits[] =
{
{ "Arch", 1114, QColor( "DodgerBlue" ) },
{ "Debian", 1373, QColor( "#d70751" ) },
{ "Fedora", 1638, QColor( "SteelBlue" ) },
{ "Mageia", 1395, QColor( "Indigo" ) },
{ "Mint", 3874, QColor( 183, 255, 183 ) },
{ "openSuSE", 1532, QColor( 115, 186, 37 ) },
{ "Puppy", 1059, QColor( "LightSkyBlue" ) },
{ "Ubuntu", 2391, QColor( "FireBrick" ) }
};
setAutoFillBackground( true );
setPalette( QColor( "Linen" ) );
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setLineWidth( 2 );
canvas->setFrameStyle( QFrame::Box | QFrame::Sunken );
canvas->setBorderRadius( 10 );
QPalette canvasPalette( QColor( "Plum" ) );
canvasPalette.setColor( QPalette::Foreground, QColor( "Indigo" ) );
canvas->setPalette( canvasPalette );
setCanvas( canvas );
setTitle( "DistroWatch Page Hit Ranking, April 2012" );
d_barChartItem = new DistroChartItem();
QVector< double > samples;
for ( uint i = 0; i < sizeof( pageHits ) / sizeof( pageHits[ 0 ] ); i++ )
{
d_distros += pageHits[ i ].distro;
samples += pageHits[ i ].hits;
d_barChartItem->addDistro(
pageHits[ i ].distro, pageHits[ i ].color );
}
d_barChartItem->setSamples( samples );
d_barChartItem->attach( this );
insertLegend( new QwtLegend() );
setOrientation( 0 );
setAutoReplot( false );
}
示例3: QwtPlot
TVPlot::TVPlot( QWidget *parent ):
QwtPlot( parent )
{
setTitle( "Watching TV during a weekend" );
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setPalette( Qt::gray );
canvas->setBorderRadius( 10 );
setCanvas( canvas );
plotLayout()->setAlignCanvasToScales( true );
setAxisTitle( QwtPlot::yLeft, "Number of People" );
setAxisTitle( QwtPlot::xBottom, "Number of Hours" );
QwtLegend *legend = new QwtLegend;
legend->setDefaultItemMode( QwtLegendData::Checkable );
insertLegend( legend, QwtPlot::RightLegend );
populate();
connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ),
SLOT( showItem( const QVariant &, bool ) ) );
replot(); // creating the legend items
QwtPlotItemList items = itemList( QwtPlotItem::Rtti_PlotHistogram );
for ( int i = 0; i < items.size(); i++ )
{
if ( i == 0 )
{
const QVariant itemInfo = itemToInfo( items[i] );
QwtLegendLabel *legendLabel =
qobject_cast<QwtLegendLabel *>( legend->legendWidget( itemInfo ) );
if ( legendLabel )
legendLabel->setChecked( true );
items[i]->setVisible( true );
}
else
{
items[i]->setVisible( false );
}
}
setAutoReplot( true );
}
示例4: canvasPalette
FrameNumberVisualizator::FrameNumberVisualizator(int duree,int dataFreq,int min, int max, QWidget *parent):
QWidget(parent),
duree_de_visualisation(duree),
frequency(dataFreq)
{
QHBoxLayout * mainLayout = new QHBoxLayout;
this->setLayout(mainLayout);
plot = new QwtPlot();
mainLayout->addWidget(plot,5);
//Axis
plot->enableAxis(QwtPlot::xBottom,false);
plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation );
plot->setAxisScale( QwtPlot::yLeft, 0, 1000 );
// canvas
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setBorderRadius( 15 );
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
plot->setCanvas( canvas );
curve = new QwtPlotCurve("frame");
curve->setRenderHint( QwtPlotItem::RenderAntialiased );
curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
curve->setPen( Qt::red );
curve->attach( plot );
timerReplot = new QTimer;
timerReplot->setInterval(50);
connect(timerReplot,SIGNAL(timeout()),plot,SLOT(replot()));
timerRescale = new QTimer;
timerRescale->setInterval(1000);
connect(timerRescale,SIGNAL(timeout()),SLOT(rescale()));
}
示例5: initQwtPlot
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void StatsGenMDFWidget::initQwtPlot(QString xAxisName, QString yAxisName, QwtPlot* plot)
{
QPalette pal;
pal.setColor(QPalette::Text, Qt::white);
pal.setColor(QPalette::Foreground, Qt::white);
pal.setColor(QPalette::Window, Qt::black);
plot->setPalette( pal );
plot->plotLayout()->setAlignCanvasToScales( true );
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
plot->axisWidget( axis )->setMargin( 0 );
plot->axisWidget(axis)->setPalette(pal);
}
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setAutoFillBackground( false );
canvas->setFrameStyle( QFrame::NoFrame );
canvas->setPalette(pal);
plot->setCanvas( canvas );
QFont font;
font.setBold(true);
QwtText xAxis(xAxisName);
xAxis.setColor(Qt::white);
xAxis.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );
xAxis.setFont(font);
QwtText yAxis(yAxisName);
yAxis.setColor(Qt::white);
yAxis.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );
yAxis.setFont(font);
const int margin = 5;
plot->setContentsMargins( margin, margin, margin, margin );
plot->setAxisTitle(QwtPlot::xBottom, xAxis);
plot->setAxisTitle(QwtPlot::yLeft, yAxis);
}
示例6: canvasPalette
Plot::Plot(QWidget *parent):
QwtPlot( parent )
{
setAutoFillBackground( true );
setPalette( QPalette( QColor( 165, 193, 228 ) ) );
updateGradient();
setTitle( "График аппроксимации" );
insertLegend( new QwtLegend(), QwtPlot::RightLegend );
// axes
setAxisTitle( xBottom, "" );
setAxisScale( xBottom, 0.0, 60.0 );
setAxisTitle( yLeft, "Функция принадлежности -->" );
setAxisScale( yLeft, -0.1, 1.1 );
// canvas
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setBorderRadius( 15 );
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
setCanvas( canvas );
// panning with the left mouse button
//( void ) new QwtPlotPanner( canvas );
// zoom in/out with the wheel
( void ) new QwtPlotMagnifier( canvas );
zoom = new QwtPlotZoomer(canvas);
zoom->setRubberBandPen(QPen(Qt::red));
clear();
// ...a horizontal line at y = 0...
<<<<<<< HEAD
示例7: canvasPalette
CallLogPlot::CallLogPlot(QwtPlot* plot, QObject* parent)
:QObject(parent)
, m_plot(plot)
, m_barScaleDrawX(NULL)
, m_barCount(0)
{
Q_ASSERT(m_plot);
m_plot->setAutoReplot(false);
// 设置图表颜色
m_plot->setAutoFillBackground(true);
m_plot->setPalette(QColor("Linen"));
// 设置图表画布
QwtPlotCanvas* canvas = new QwtPlotCanvas();
canvas->setLineWidth(2);
canvas->setFrameStyle(QFrame::Box | QFrame::Sunken);
QPalette canvasPalette(QColor("Plum"));
canvasPalette.setColor(QPalette::Foreground, QColor("Indigo"));
canvas->setPalette(canvasPalette);
m_plot->setCanvas(canvas);
// 创建柱状图表
m_barChart = new BarChart();
m_barChart->attach(m_plot);
m_barChart->setOrientation(Qt::Vertical);
// 设置X坐标轴
m_barScaleDrawX = new BarScaleDrawX();
m_plot->setAxisMaxMajor(QwtPlot::xBottom, 0);
m_plot->setAxisScaleDraw(QwtPlot::xBottom, m_barScaleDrawX);
// 设置Y坐标轴
m_barScaleDrawY = new BarScaleDrawY();
m_plot->setAxisMaxMinor(QwtPlot::yLeft, 3);
m_plot->setAxisScaleDraw(QwtPlot::yLeft, m_barScaleDrawY);
// 设置布局
m_plot->plotLayout()->setCanvasMargin(0);
m_plot->replot();
}
示例8: canvasPalette
Psd::Psd(QWidget *parent) :
QWidget(parent),
ui(new Ui::Psd)
{
ui->setupUi(this);
ui->plot->setTitle("原信号:cos(2*PI*40*i)+3*cos(2*PI*100*i)+w(n)");
ui->plot->setAutoFillBackground( true );
ui->plot->insertLegend( new QwtLegend(), QwtPlot::RightLegend );
ui->plot->setAutoReplot( false );
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setBorderRadius( 15 );
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
ui->plot->setCanvas( canvas );
( void ) new QwtPlotPanner( canvas );
( void ) new QwtPlotMagnifier( canvas );
cSin->setRenderHint( QwtPlotItem::RenderAntialiased );
cSin->setLegendAttribute( QwtPlotCurve::LegendShowLine, false );
cSin->setPen( Qt::red );
cSin->attach( ui->plot );
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY->setLineStyle( QwtPlotMarker::HLine );
mY->setYValue( 0.0 );
mY->attach( ui->plot );
init();
pf();
populate();
}
示例9: QwtPlot
Plot::Plot( QWidget *parent ):
QwtPlot( parent ),
d_interval( 10.0 ), // seconds
d_timerId( -1 )
{
// Assign a title
setTitle( "Testing Refresh Rates" );
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setLineWidth( 1 );
canvas->setPalette( Qt::white );
setCanvas( canvas );
alignScales();
// Insert grid
d_grid = new QwtPlotGrid();
d_grid->attach( this );
// Insert curve
d_curve = new QwtPlotCurve( "Data Moving Right" );
d_curve->setPen( Qt::black );
d_curve->setData( new CircularBuffer( d_interval, 10 ) );
d_curve->attach( this );
// Axis
setAxisTitle( QwtPlot::xBottom, "Seconds" );
setAxisScale( QwtPlot::xBottom, -d_interval, 0.0 );
setAxisTitle( QwtPlot::yLeft, "Values" );
setAxisScale( QwtPlot::yLeft, -1.0, 1.0 );
d_clock.start();
setSettings( d_settings );
}
示例10: QwtPlotMagnifier
Curve::Curve(int device_port, int ele_max,QColor color, QWidget *parent)
: QwtPlot(parent),device_port(device_port),color(color),ele_max(ele_max)
{
reset();
setObjectName(tr("%1-%2 Real-Eletric").arg(device_port));
setTitle(tr("实时电流"));
setAxisTitle(QwtPlot::xBottom,"时间(s)");
setAxisTitle(QwtPlot::yLeft,tr("电流(A)"));
setAxisScale(QwtPlot::xBottom,x_min,x_max);
setAxisScale(QwtPlot::yLeft,0.0,50.0);
QwtPlotCanvas *canvas = new QwtPlotCanvas;
canvas->setPalette(QColor("#404040"));
canvas->setBorderRadius(10);
canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
setCanvas(canvas);
insertLegend(new QwtLegend(),QwtPlot::RightLegend);
QwtPlotZoomer *zoomer = new QwtPlotZoomer(canvas);
zoomer->setRubberBandPen(QPen(QColor(Qt::red),1));
zoomer->setTrackerPen(QColor(Qt::red));
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton,Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
QwtPlotPanner *panner = new QwtPlotPanner(canvas);
panner->setMouseButton(Qt::MidButton);
panner->setCursor(Qt::OpenHandCursor);
panner->setEnabled(true);
panner->setAxisEnabled(QwtPlot::yLeft,false);
connect(panner,SIGNAL(panned(int,int)),this,SLOT(get_coord(int,int)));
new QwtPlotMagnifier(this->canvas());
QwtPlotPicker *m_picker = new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft,
QwtPlotPicker::HLineRubberBand , QwtPicker::AlwaysOn,
this->canvas() );
m_picker->setTrackerPen(QPen(Qt::red,1));
QFont font;
font.setPixelSize(15);
m_picker->setTrackerFont(font);
d_curve = new QwtPlotCurve(tr("支路%1").arg(device_port));
d_curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,Qt::blue,QPen(Qt::blue),QSize(5,5)));
d_curve->setStyle(QwtPlotCurve::Lines);
d_curve->setCurveAttribute( QwtPlotCurve::Fitted );
d_curve->setPen(QPen(Qt::magenta));
d_curve->setRenderHint(QwtPlotItem::RenderAntialiased,true);
d_curve->attach(this);
d_curve_Max = new QwtPlotCurve(tr("最大值"));
d_curve_Max->setStyle(QwtPlotCurve::Lines);
d_curve_Max->setCurveAttribute(QwtPlotCurve::Fitted);
d_curve_Max->setPen(QPen(Qt::red));
d_curve_Max->setRenderHint(QwtPlotItem::RenderAntialiased,true);
d_curve_Max->attach(this);
}
示例11: QwtPlot
//---------------------------------------------------------------------------
Plot::Plot( size_t streamPos, size_t Type, size_t Group, QWidget *parent ) :
QwtPlot( parent ),
m_streamPos( streamPos ),
m_type( Type ),
m_group( Group )
{
setAutoReplot( false );
QwtPlotCanvas* canvas = dynamic_cast<QwtPlotCanvas*>( this->canvas() );
if ( canvas )
{
canvas->setFrameStyle( QFrame::Plain | QFrame::Panel );
canvas->setLineWidth( 1 );
#if 1
canvas->setPalette( QColor("Cornsilk") );
#endif
}
setAxisMaxMajor( QwtPlot::yLeft, 0 );
setAxisMaxMinor( QwtPlot::yLeft, 0 );
setAxisScaleDraw( QwtPlot::yLeft, new PlotScaleDrawY() );
enableAxis( QwtPlot::xBottom, false );
// something invalid
setAxisScale( QwtPlot::xBottom, -1, 0 );
setAxisScale( QwtPlot::yLeft, -1, 0 );
// Plot grid
QwtPlotGrid *grid = new QwtPlotGrid();
grid->enableXMin( true );
grid->enableYMin( true );
grid->setMajorPen( Qt::darkGray, 0, Qt::DotLine );
grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
grid->attach( this );
m_cursor = new PlotCursor( canvas );
m_cursor->setPosition( 0 );
// curves
for( unsigned j = 0; j < PerStreamType[m_type].PerGroup[m_group].Count; ++j )
{
QwtPlotCurve* curve = new QwtPlotCurve( PerStreamType[m_type].PerItem[PerStreamType[m_type].PerGroup[m_group].Start + j].Name );
curve->setPen( curveColor( j ) );
curve->setRenderHint( QwtPlotItem::RenderAntialiased );
curve->setZ( curve->z() - j ); //Invert data order (e.g. MAX before MIN)
curve->attach( this );
m_curves += curve;
}
// visual helpers
if ( m_type == Type_Video )
switch (m_group)
{
case Group_Y :
Plot_AddHLine( this, 16, 61, 89, 171);
Plot_AddHLine( this, 235, 220, 20, 60);
break;
case Group_U :
case Group_V :
Plot_AddHLine( this, 16, 61, 89, 171);
Plot_AddHLine( this, 240, 220, 20, 60);
break;
case Group_Sat :
Plot_AddHLine( this, 88, 255, 0, 255);
Plot_AddHLine( this, 118, 220, 20, 60);
break;
default : ;
}
PlotPicker* picker = new PlotPicker( canvas, &PerStreamType[m_type], m_group, &m_curves );
connect( picker, SIGNAL( moved( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
connect( picker, SIGNAL( selected( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
connect( axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ), SLOT( onXScaleChanged() ) );
// legend
m_legend = new PlotLegend();
connect( this, SIGNAL( legendDataChanged( const QVariant &, const QList<QwtLegendData> & ) ),
m_legend, SLOT( updateLegend( const QVariant &, const QList<QwtLegendData> & ) ) );
updateLegend();
}
示例12: canvasPalette
Plot::Plot(QWidget *parent):
QwtPlot( parent )
{
setAutoFillBackground( true );
setPalette( QPalette( QColor( 165, 193, 228 ) ) );
updateGradient();
setTitle( "График аппроксимации" );
insertLegend( new QwtLegend(), QwtPlot::RightLegend );
// axes
setAxisTitle( xBottom, "" );
setAxisScale( xBottom, 0.0, 10.0 );
setAxisTitle( yLeft, "Функция принадлежности -->" );
setAxisScale( yLeft, 0, 2 );
// canvas
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setBorderRadius( 15 );
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
setCanvas( canvas );
// panning with the left mouse button
( void ) new QwtPlotPanner( canvas );
// zoom in/out with the wheel
( void ) new QwtPlotMagnifier( canvas );
// ...a horizontal line at y = 0...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel( QString::fromLatin1( "y = 0" ) );
mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY->setLineStyle( QwtPlotMarker::HLine );
mY->setYValue( 0.0 );
mY->attach( this );
// ...a horizontal line at y = 1...
QwtPlotMarker *mY1 = new QwtPlotMarker();
mY1->setLabel( QString::fromLatin1( "y = 1" ) );
mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY1->setLineStyle( QwtPlotMarker::HLine );
mY1->setYValue( 1.0 );
mY1->setLinePen(Qt::black, 1, Qt::DashLine);
mY1->attach( this );
// ...a vertical line at x = 0
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel( QString::fromLatin1( "x = 0" ) );
mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom );
mX->setLabelOrientation( Qt::Vertical );
mX->setLineStyle( QwtPlotMarker::VLine );
mX->setLinePen( Qt::black, 0, Qt::DashDotLine );
mX->setXValue( 0 );
mX->attach( this );
// curvePoints = new QwtPlotCurve();
// curvePoints->setStyle( QwtPlotCurve::Dots );
// curvePoints->attach( this );
}
示例13: canvasPalette
ThreeAxisDataVisualizator::ThreeAxisDataVisualizator(int duree,int dataFreq,int min, int max, int _type, QWidget *parent):
QWidget(parent),
duree_de_visualisation(duree),
frequency(dataFreq),
type(_type),
min(0),
max(0)
{
curves = QList<QString>();
QString typeStr;
if(type==DataType::acc){
typeStr = "accelerometre";
}else if(type==DataType::gyro){
typeStr = "gyroscope";
}else if(type==DataType::euler){
typeStr = "euler";
}else if(type==DataType::qua){
typeStr = "quaternion";
}
curves.append(typeStr+" x");
curves.append(typeStr+" y");
curves.append(typeStr+" z");
QHBoxLayout * mainLayout = new QHBoxLayout;
this->setLayout(mainLayout);
plot = new QwtPlot();
mainLayout->addWidget(plot,5);
QWidget * checkBoxGroup = new QWidget(this);
mainLayout->addWidget(checkBoxGroup,1);
QVBoxLayout * checkBoxGroupLayout = new QVBoxLayout;
checkBoxGroup->setLayout(checkBoxGroupLayout);
QPushButton * resetScaleButton = new QPushButton;
resetScaleButton->setText("reset y scale");
setStyleSheet("QPushButton{"
"font-family: Futura;"
"color:#4C6BCF;"
"font-size: 14px;"
"border:2px solid ;"
"border-color: #4C6BCF;"
"border-radius:5px;"
"min-height:60;}");
checkBoxGroupLayout->addWidget(resetScaleButton);
checkBoxX = new QCheckBox(curves.at(0),checkBoxGroup);
checkBoxGroupLayout->addWidget(checkBoxX);
checkBoxY = new QCheckBox(curves.at(1),checkBoxGroup);
checkBoxGroupLayout->addWidget(checkBoxY);
checkBoxZ = new QCheckBox(curves.at(2),checkBoxGroup);
checkBoxGroupLayout->addWidget(checkBoxZ);
timeSlider = new QSlider(Qt::Horizontal,checkBoxGroup);
checkBoxGroupLayout->addWidget(timeSlider);
checkBoxX->setChecked(true);
checkBoxY->setChecked(true);
checkBoxZ->setChecked(true);
QSignalMapper * mapper = new QSignalMapper;
mapper->setMapping(checkBoxX,0);
mapper->setMapping(checkBoxY,1);
mapper->setMapping(checkBoxZ,2);
connect(checkBoxX,SIGNAL(stateChanged(int)),mapper,SLOT(map()));
connect(checkBoxY,SIGNAL(stateChanged(int)),mapper,SLOT(map()));
connect(checkBoxZ,SIGNAL(stateChanged(int)),mapper,SLOT(map()));
connect(mapper,SIGNAL(mapped(int)),SLOT(handleCheckBox(int)));
// canvas
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::Box | QFrame::Plain );
canvas->setBorderRadius( 15 );
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
plot->setCanvas( canvas );
QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0);
it1->attach(plot);
plot->enableAxis(QwtPlot::xBottom,false);
plot->setAxisScale( QwtPlot::xBottom, 0.0, duree_de_visualisation );
plot->setAxisScale( QwtPlot::yLeft, min, max );
xCurve = new QwtPlotCurve( curves.at(0));
xCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
xCurve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
xCurve->setPen( Qt::red );
xCurve->attach( plot );
//.........这里部分代码省略.........
示例14: setSettings
void Plot::setSettings( const Settings &s )
{
if ( d_timerId >= 0 )
killTimer( d_timerId );
d_timerId = startTimer( s.updateInterval );
d_grid->setPen( s.grid.pen );
d_grid->setVisible( s.grid.pen.style() != Qt::NoPen );
CircularBuffer *buffer = static_cast<CircularBuffer *>( d_curve->data() );
if ( s.curve.numPoints != buffer->size() ||
s.curve.functionType != d_settings.curve.functionType )
{
switch( s.curve.functionType )
{
case Settings::Wave:
buffer->setFunction( wave );
break;
case Settings::Noise:
buffer->setFunction( noise );
break;
default:
buffer->setFunction( NULL );
}
buffer->fill( d_interval, s.curve.numPoints );
}
d_curve->setPen( s.curve.pen );
d_curve->setBrush( s.curve.brush );
d_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons,
s.curve.paintAttributes & QwtPlotCurve::ClipPolygons );
d_curve->setPaintAttribute( QwtPlotCurve::FilterPoints,
s.curve.paintAttributes & QwtPlotCurve::FilterPoints );
d_curve->setRenderHint( QwtPlotItem::RenderAntialiased,
s.curve.renderHint & QwtPlotItem::RenderAntialiased );
#ifndef QWT_NO_OPENGL
if ( s.canvas.openGL )
{
QwtPlotGLCanvas *plotCanvas = qobject_cast<QwtPlotGLCanvas *>( canvas() );
if ( plotCanvas == NULL )
{
plotCanvas = new GLCanvas();
plotCanvas->setPalette( QColor( "khaki" ) );
setCanvas( plotCanvas );
}
}
else
#endif
{
QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas() );
if ( plotCanvas == NULL )
{
plotCanvas = new QwtPlotCanvas();
plotCanvas->setFrameStyle( QFrame::Box | QFrame::Plain );
plotCanvas->setLineWidth( 1 );
plotCanvas->setPalette( Qt::white );
setCanvas( plotCanvas );
}
plotCanvas->setAttribute( Qt::WA_PaintOnScreen, s.canvas.paintOnScreen );
plotCanvas->setPaintAttribute(
QwtPlotCanvas::BackingStore, s.canvas.useBackingStore );
plotCanvas->setPaintAttribute(
QwtPlotCanvas::ImmediatePaint, s.canvas.immediatePaint );
}
QwtPainter::setPolylineSplitting( s.curve.lineSplitting );
d_settings = s;
}
示例15: canvasPalette
Plot::Plot( QWidget *parent ):
QwtPlot( parent )
{
//setAutoFillBackground( true );
//setPalette( QPalette( QColor( 165, 193, 228 ) ) );
//updateGradient();
//setTitle( "A Simple QwtPlot Demonstration" );
//insertLegend( new QwtLegend(), QwtPlot::BottomLegend );
// axes
setAxisTitle( xBottom, "x -->" );
setAxisScale( xBottom, 0.0, 360.0 );
setAxisTitle( yLeft, "y -->" );
setAxisScale( yLeft, -10.0, 10.0 );
// canvas
QwtPlotCanvas *canvas = new QwtPlotCanvas();
//canvas->setLineWidth( 1 );
canvas->setFrameStyle( QFrame::StyledPanel );
//canvas->setBorderRadius( 15 );
QwtPlotGrid* grid = new QwtPlotGrid();
grid->setPen(Qt::black, 0.1, Qt::DashLine);
grid->attach(this);
QPalette canvasPalette( Qt::white );
canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) );
canvas->setPalette( canvasPalette );
setCanvas( canvas );
// panning with the left mouse button
QwtPlotPanner* panner = new QwtPlotPanner( canvas );
panner->setMouseButton(Qt::LeftButton, Qt::ControlModifier);
// zoom in/out with the wheel
QwtPlotMagnifier* magnifier = new QwtPlotMagnifier( canvas );
magnifier->setAxisEnabled(xBottom, false);
QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas);
zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier );
zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier );
zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home );
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ShiftModifier);
canvas->setFocusPolicy(Qt::StrongFocus);
canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
canvas->setFocus();
//canvas->setFrameShadow(QwtPlot::Plain);
//canvas->setCursor(Qt::arrowCursor);
canvas->setLineWidth(0);
//canvas->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
//canvas->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
//populate();
}