Esempio n. 1
0
int main()
{
	OpencvPlot fooplot("MyWindow",PlotSettings(2,-1,.5),10);
	OpencvPlot fumplot("other",PlotSettings(1000,200,100),10);

//	cv::namedWindow("foowindow",CV_WINDOW_AUTOSIZE);
//	cv::Mat_<unsigned char> plot1(256,1000);
//	plot1 = 255;
	for (unsigned int i = 0; i < 10000; ++i)
	{
		fooplot.update(std::sin(i/100.0));
		fumplot.update(i);
	}

	std::cout << "Foo" << std::endl;

	// close all windows..
	return 0;
}
plotter::plotter(QWidget *parent) :
    QWidget(parent)
{
    setBackgroundRole(QPalette::Light);
    setAutoFillBackground(true);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setFocusPolicy(Qt::StrongFocus);
    rubberBandIsShown = false;
    setPlotSettings(PlotSettings());

}
Esempio n. 3
0
File: plotter.cpp Progetto: Qmax/PT6
Plotter::Plotter(QWidget *parent) :
    QWidget(parent,Qt::FramelessWindowHint | Qt::WindowSystemMenuHint)
{

    Margin =15;
    m_objPlotData = new stWaveData();
    setBackgroundRole(QPalette::Shadow);
    setAutoFillBackground(true);
    setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    setFocusPolicy(Qt::StrongFocus);
    rubberBandIsShown = false;
    m_bshowZoomRect = false;
    this->setGeometry(0,0,710,490);
    setPlotSettings(PlotSettings());
    m_showData=false;
    m_moveFlag = false;
}
Esempio n. 4
0
plotter::plotter(QWidget *parent)
    : QWidget(parent)
{
    setBackgroundRole(QPalette::Dark);
    setAutoFillBackground(true);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    setFocusPolicy(Qt::StrongFocus);
    rubberBandIsShown = false;

    zoomInButton = new QToolButton(this);
    zoomInButton->adjustSize();
    connect(zoomInButton,SIGNAL(clicked()), this, SLOT(zoomIn()));

    zoomOutButton = new QToolButton(this);
    zoomOutButton->adjustSize();
    connect(zoomOutButton,SIGNAL(clicked()), this, SLOT(zoomOut()));

    setPlotSettings(PlotSettings());

}
Esempio n. 5
0
Plotter::Plotter(QWidget *parent)
: QWidget(parent)
{
    setBackgroundRole(QPalette::Shadow);
setAutoFillBackground(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setFocusPolicy(Qt::StrongFocus);
rubberBandIsShown = false;
zoomInButton = new QToolButton(this);
zoomInButton->setIcon(QIcon(":/images/zoomin.png"));
//zoomInButton->setText("+");
zoomInButton->adjustSize();
connect(zoomInButton, SIGNAL(clicked()), this, SLOT(zoomIn()));
zoomOutButton = new QToolButton(this);
zoomOutButton->setIcon(QIcon(":/images/zoomout.png"));
//zoomOutButton->setText("-");
zoomOutButton->adjustSize();
connect(zoomOutButton, SIGNAL(clicked()), this, SLOT(zoomOut()));
setPlotSettings(PlotSettings());
}
Esempio n. 6
0
MainWindow::MainWindow() {

	// create a window  
	this->setWindowTitle("PolyTelemetre");
	this->resize(800,400);

	/*
	caseCheckBox = new QCheckBox(tr("Match &case"));
	backwardCheckBox = new QCheckBox(tr("Search &backward"));
	findButton = new QPushButton(tr("&Find"));
	findButton->setDefault(true);
	findButton->setEnabled(false);
	closeButton = new QPushButton(tr("Close"));
	*/

	// Configuration - Focus
	QLabel *conf_label_focus = new QLabel(tr("Foyer (mm) :"));
	conf_edit_focus = new QLineEdit;
	conf_edit_focus->setFixedWidth(50);
	conf_edit_focus->setValidator(new QDoubleValidator(0, 100, 2, this));
	conf_edit_focus->setText("110");
	conf_label_focus->setBuddy(conf_edit_focus);
	
	// Configuration - Focus Layout
	QHBoxLayout *conf_focus_layout = new QHBoxLayout;
	conf_focus_layout->addWidget(conf_label_focus);
	conf_focus_layout->addWidget(conf_edit_focus);

	// Configuration - Gap
	QLabel *conf_label_gap= new QLabel(tr("Ecart axes (mm) :"));
	conf_edit_gap = new QLineEdit;
	conf_edit_gap->setFixedWidth(50);
	conf_edit_gap->setValidator(new QDoubleValidator(0, 100, 2, this));
	conf_edit_gap->setText("50");
	conf_label_gap->setBuddy(conf_edit_gap);
	
	// Configuration - Gap Layout
	QHBoxLayout *conf_gap_layout = new QHBoxLayout;
	conf_gap_layout->addWidget(conf_label_gap);
	conf_gap_layout->addWidget(conf_edit_gap);
	
	// Configuration - Pixel
	QLabel *conf_label_pixel = new QLabel(tr("Largeur pixel (µm) :"));
	conf_edit_pixel = new QLineEdit;
	conf_edit_pixel->setFixedWidth(50);
	conf_edit_pixel->setValidator(new QDoubleValidator(0, 100, 2, this));
	conf_edit_pixel->setText("14");
	conf_label_pixel->setBuddy(conf_edit_pixel);
	
	// Configuration - Pixel Layout
	QHBoxLayout *conf_pixel_layout = new QHBoxLayout;
	conf_pixel_layout->addWidget(conf_label_pixel);
	conf_pixel_layout->addWidget(conf_edit_pixel);

	// Configuration - Main layout
	QHBoxLayout *conf_layout = new QHBoxLayout;
	conf_layout->addLayout(conf_focus_layout);
	conf_layout->addLayout(conf_gap_layout);
	conf_layout->addLayout(conf_pixel_layout);
	
	// Configuration - Group box
	QGroupBox *conf_group_box = new QGroupBox(tr("Configuration"));
	conf_group_box->setLayout(conf_layout);

	// Acquisition - distance
	QLabel *acq_label_distance = new QLabel(tr("Distance :"));
	acq_edit_distance = new QLineEdit;
	acq_edit_distance->setReadOnly(true);
	acq_label_distance->setBuddy(acq_edit_distance);
	
	// Acquisition - Top layout (distance)
	QHBoxLayout *acq_top_dist_layout = new QHBoxLayout;
	acq_top_dist_layout->addWidget(acq_label_distance);
	acq_top_dist_layout->addWidget(acq_edit_distance);

	// Acquisition - Plotter
	plotter = new Plotter;
	plotter->setPlotSettings(PlotSettings(1,MAX_PIXEL,-2,2));

	// Acquisition - Layout (distance, plotter)
	QVBoxLayout *acq_layout = new QVBoxLayout;
    acq_layout->setAlignment(Qt::AlignTop);
	acq_layout->addLayout(acq_top_dist_layout);
	acq_layout->addStretch();
	acq_layout->addWidget(plotter);
	
	// Acquistion - Group box
	QGroupBox *acq_group_box = new QGroupBox(tr("Carte d'acquisition"));
	acq_group_box->setLayout(acq_layout);

	// Controller - ports
	QLabel *ctrl_label_port = new QLabel(tr("Port :"));
	ctrl_ports = new QComboBox(this);
	ctrl_label_port->setBuddy(ctrl_ports);
	
	// Controller - Top layout (ports)
	QHBoxLayout *ctrl_top_port_layout = new QHBoxLayout;
	ctrl_top_port_layout->addWidget(ctrl_label_port);
	ctrl_top_port_layout->addWidget(ctrl_ports);

	// Controller - pixel
	QLabel *ctrl_label_pixel = new QLabel(tr("Pixel :"));
	ctrl_edit_pixel = new QLineEdit;
	ctrl_edit_pixel->setReadOnly(true);
	ctrl_label_pixel->setBuddy(ctrl_edit_pixel);

	// Controller - Top layout (pixel)
	QHBoxLayout *ctrl_top_pixel_layout = new QHBoxLayout;
	ctrl_top_pixel_layout->addWidget(ctrl_label_pixel);
	ctrl_top_pixel_layout->addWidget(ctrl_edit_pixel);

	// Controller - distance
	QLabel *ctrl_label_distance = new QLabel(tr("Distance :"));
	ctrl_edit_distance = new QLineEdit;
	ctrl_edit_distance->setReadOnly(true);
	ctrl_label_distance->setBuddy(ctrl_edit_distance);

	// Controller - Top layout (distance)
	QHBoxLayout *ctrl_top_dist_layout = new QHBoxLayout;
	ctrl_top_dist_layout->addWidget(ctrl_label_distance);
	ctrl_top_dist_layout->addWidget(ctrl_edit_distance);

	// Controller - Layout (ports, pixel, distance)
	QVBoxLayout *ctrl_layout = new QVBoxLayout;
    ctrl_layout->setAlignment(Qt::AlignTop);
	ctrl_layout->addLayout(ctrl_top_port_layout);
	ctrl_layout->addLayout(ctrl_top_pixel_layout);
	ctrl_layout->addLayout(ctrl_top_dist_layout);
	
	// Controller - Group box
	QGroupBox *ctrl_group_box = new QGroupBox(tr("Microcontroleur"));
	ctrl_group_box->setLayout(ctrl_layout);

	// Mesure layout (acquisition and controller)
	QHBoxLayout *mesure_layout = new QHBoxLayout;
	mesure_layout->addWidget(acq_group_box);
	mesure_layout->addWidget(ctrl_group_box);

	// Log - field
	log_edit = new QTextEdit();
	log_edit->setReadOnly(true);

	// Log - Layout
	QHBoxLayout *log_layout = new QHBoxLayout;
	log_layout->addWidget(log_edit);

	// Log - Group box
	QGroupBox *log_group_box = new QGroupBox(tr("Console"));
	log_group_box->setLayout(log_layout);

	// Main layout (configuration, mesure, log)
	QVBoxLayout *main_layout = new QVBoxLayout;
	main_layout->addWidget(conf_group_box);
	main_layout->addLayout(mesure_layout);
	main_layout->addWidget(log_group_box);
	this->setLayout(main_layout);

	// Update ports list
	this->searchPorts();
	QString default_port = "";
	this->updatePortController(default_port);

	// Add signal and slot
	QObject::connect(ctrl_ports, SIGNAL(currentIndexChanged(int)), this, SLOT(selectedControllerPort(int)));

	// Init the calculator and acquisitor
	this->calculator = new Calculator(this);
	this->acquisitor = new Acquisitor(this);

	this->log("Init the programm");

	/*test*/
	int pixel = 1333;
	double sigma = 20;
	float64 data[MAX_PIXEL];
	for (int i=0; i<MAX_PIXEL; i+=1) {
		data[i] = 100*(1/(sigma*sqrt(2*M_PI)))*exp(-(pow((double)i-pixel+1, 2))/(2*pow(sigma, 2)));
	}
	this->receiveData(data);
	this->receivePixel(pixel);
	
	// Show the window
	this->show();
}
Esempio n. 7
0
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();	
	
/*********************************************************************************************************************************************/


}
Esempio n. 8
0
// Take the result of the popup menu selection, figure out
// what the user wanted, and take the appropriate action
int		CXYChart::InterpretPopupMenuItem( int result )
{
	int			whichAxis, returnVal;

	if( result >= kMinimumPopupValue ) return result;

	if( result <= 0 ) return kPopupError;

	if( result <= kMenuMinorVertGrids )
	{
		switch( result )
		{
		case kMenuMajorHorizGrids: m_UseMajorHorizontalGrids = !m_UseMajorHorizontalGrids; break;
		case kMenuMajorVertGrids: m_UseMajorVerticalGrids = !m_UseMajorVerticalGrids; break;
		case kMenuMinorHorizGrids: m_UseMinorHorizontalGrids = !m_UseMinorHorizontalGrids; break;
		case kMenuMinorVertGrids: m_UseMinorVerticalGrids = !m_UseMinorVerticalGrids; break;
		default: break;
		}

		return kPopupUpdate;
	}

	if( result >= kMenuTitleFont && result < kMenuTitleFont + nFontSizes )
	{
		m_TitleFont.lfHeight = fontSizes[result-kMenuTitleFont];
		return kPopupUpdate;
	}

	if( result == kMenuPlotSettings )
	{
		if( PlotSettings() ) return kPopupUpdate; else return kPopupNoAction;
	}

	if( result >= kMenuAxisMinimum && result < kMenuAxisMinimum + (kMaxAxes*kMenuAxisRange) )
	{
		// These must be axis sets
		whichAxis = (result-kMenuAxisMinimum) / kMenuAxisRange;

		if( whichAxis < 0 || whichAxis > GetAxisCount() ) return kPopupError;

		if( result % kMenuAxisRange == kMenuAxisRange-1 ) // have to do this one manually
			if( AxisSettings(whichAxis) ) return kPopupUpdate; else return kPopupNoAction;

		if( (returnVal = GetAxis(whichAxis)->InterpretAxisPopupMenuItem( (result-kMenuAxisMinimum) % kMenuAxisRange ) ) == kPopupError )
			return result;
		else
			return returnVal;
	}

	if( result >= kMenuDataMinimum && result < kMenuDataMinimum + kMaxDataSets*kMenuDataRange )
	{
		int			whichDataSet;

		whichDataSet = (result-kMenuDataMinimum) / kMenuDataRange;

		if( whichDataSet < 0 || whichDataSet > GetDataSetCount() ) return kPopupError;

		if( (result-kMenuDataMinimum) % kMenuDataRange == kMenuDataRange-1 ) // have to do this one manually
			if( DataSettings(whichDataSet) ) return kPopupUpdate; else return kPopupNoAction;

		if( (returnVal = InterpretDataSetPopupMenuItem( whichDataSet, (result-kMenuDataMinimum) % kMenuDataRange ) ) == kPopupError )
			return result;
		else
			return returnVal;
	}

	return kPopupError;
}