示例#1
0
void CMenuRecord::slot_do_boxing()
{
   // CDlgRecordWave *dlg = new CDlgRecordWave(this);

    Plotter *plotter = new Plotter(this);

    int numPoints = 100;
    QVector<QPointF> points0;
    QVector<QPointF> points1;
    for (int x = 0; x < numPoints; ++x) {
        points0.append(QPointF(x, uint(qrand()) % 100));
        points1.append(QPointF(x, uint(qrand()) % 100));
    }
    plotter->setCurveData(0, points0);
    plotter->setCurveData(1, points1);

    PlotSettings settings;
    settings.minX = 0.0;
    settings.maxX = 100.0;
    settings.minY = 0.0;
    settings.maxY = 100.0;
    plotter->setPlotSettings(settings);

   plotter->show();
}
示例#2
0
文件: main.cpp 项目: pyrech/telemetre
int main(int argc, char *argv[])
{

/************************************************* example as a standalone window ************************************************************/
/*	
	//create an application
	QApplication app(argc, argv);					
   
	// create and fill the data vector
	QVector<QPointF> data1;
	for (float i=0;i<20;i+=0.1)
		data1.append(QPointF(i,sin(i)));

	// create and fill another data vector
	QVector<QPointF> data2;
	for (float i=0;i<20;i+=0.1)
		data2.append(QPointF(i,sin(i/2)));

	//creat the plotter and set its data
	Plotter *plotter = new Plotter;							// create a plotter
	plotter->setPlotSettings(PlotSettings(0,20,-2,2));		//initialise the axis
	plotter->setCurveData(0,data1);							//set the first plotter data set
	plotter->setCurveData(1,data2);							//set the second plotter data set
	
	//show the plotter widget
	plotter->show();										
    
	//execute the application
	return app.exec();						
*/
/*********************************************************************************************************************************************/


/******************************************** example of use as a widget among others *********************************************************/
	
	//create an application
	QApplication app(argc, argv);				

	// create a window
    QWidget *window = new QWidget;
	window->setWindowTitle("Plotter widget application");

	// create a label
	QLabel *label = new QLabel("<h2><i><font color=blue> Plot example </font> </i></h2>");
	
	//create the plotter and its data
	Plotter *plotter = new Plotter;	
	plotter->setPlotSettings(PlotSettings(0,20,-2,2));		
	
	QVector<QPointF> data1;
	for (float i=0;i<20;i+=0.1)
		data1.append(QPointF(i,sin(i)));
	QVector<QPointF> data2;
	for (float i=0;i<20;i+=0.1)
		data2.append(QPointF(i,sin(i/2)));
	
	plotter->setCurveData(0,data1);							
	plotter->setCurveData(1,data2);							
	

	//layout the widgets
	QVBoxLayout *layout = new QVBoxLayout;
	layout -> addWidget (label);
	layout -> addWidget (plotter);
	window->setLayout(layout);
	
	//show the window
	window->show();

	//execute the application
	return app.exec();	
	
/*********************************************************************************************************************************************/


}