示例#1
0
/*!
 * \brief LocationGraph::LocationGraph Constructs a LocationGraph
 * \param mainPlot The main plot for this graph.
 * \param auxPlot The auxiliary plot for this graph, which lives in the sidebar.
 * \param colors A vector of the colors to be given to the points in this graph.
 * \param displayUnit A string containing the name of the units to use in this graph's displays.
 * \param numPoints The number of points to display on this graph.
 */
LocationGraph::LocationGraph(QCustomPlot* mainPlot, QCustomPlot* auxPlot, std::vector<QColor> colors, QString displayUnit, int numPoints) {
    this->mainPlot = mainPlot;
    this->auxPlot = auxPlot;
    this->colors = colors;
    this->displayUnit = displayUnit;
    this->numPoints = numPoints;
    maxPoints = std::vector<QPointF> (numPoints, QPointF(std::numeric_limits<qreal>::min(), std::numeric_limits<qreal>::min()));
    currentPoints = std::vector<QPointF> (numPoints);

    setupPlot(mainPlot, true, colors, numPoints);
    setupPlot(auxPlot, false, colors, numPoints);
}
示例#2
0
/*!
 * \brief ScrollingTimeGraph::ScrollingTimeGraph Constructs the ScrollingTimeGraph.
 * \param mainWindow A pointer to the mainWindow, used for connecting ranges of the graph.
 * \param mainPlot The main plot for this graph.
 * \param auxPlot The auxiliary plot for this graph, which lives in the sidebar.
 * \param primaryColor The color of the primary line of this graph.
 * \param secondaryColor The color of the secondary line of this graph.
 * \param displayUnit The units to use in displays.
 * \param numDisplayValues The number of values to display in maxDisplay and currentDisplay.
 */
ScrollingTimeGraph::ScrollingTimeGraph(QMainWindow* mainWindow, QCustomPlot* mainPlot, QCustomPlot* auxPlot,
                                       QColor primaryColor, QColor secondaryColor, QString displayUnit, int numDisplayValues) {
    this->mainPlot = mainPlot;
    this->auxPlot = auxPlot;
    this->primaryColor = primaryColor;
    this->secondaryColor = secondaryColor;
    this->displayUnit = displayUnit;
    this->numDisplayValues = numDisplayValues;

    setupPlot(mainWindow, mainPlot, true, primaryColor, secondaryColor);
    mainPlot->yAxis->setLabel(displayUnit);
    setupPlot(mainWindow, auxPlot, false, primaryColor, secondaryColor);
}
示例#3
0
void MainWindow::updateSettings()
{
    setupPlot();
    kwp.setLabelDir(QDir::fromNativeSeparators(settingsDialog->labelDir));
    kwp.setTimeouts(settingsDialog->slow, settingsDialog->norm, settingsDialog->fast);
    kwp.setKeepAliveInterval(settingsDialog->keepAliveInterval);
}
示例#4
0
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
{
  ui->setupUi(this);
  setupPlot();
  
  // configure scroll bars:
  // Since scroll bars only support integer values, we'll set a high default range of -500..500 and
  // divide scroll bar position values by 100 to provide a scroll range -5..5 in floating point
  // axis coordinates. if you want to dynamically grow the range accessible with the scroll bar,
  // just increase the the minimum/maximum values of the scroll bars as needed.
  ui->horizontalScrollBar->setRange(-500, 500);
  ui->verticalScrollBar->setRange(-500, 500);
  
  // create connection between axes and scroll bars:
  connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horzScrollBarChanged(int)));
  connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vertScrollBarChanged(int)));
  connect(ui->plot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
  connect(ui->plot->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange)));
  
  // initialize axis range (and scroll bar positions via signals we just connected):
  ui->plot->xAxis->setRange(0, 6, Qt::AlignCenter);
  ui->plot->yAxis->setRange(0, 10, Qt::AlignCenter);
}
示例#5
0
void VectorPlot::addDotPlot(const MarkupQwtAdapter&adapter,
		QColor color,
		const QString &name,
		bool addToLegend) {
	QwtPlotCurve *curve = new QwtPlotCurve(name);

    QwtSymbol sym;
    sym.setPen(QColor(color));
    sym.setBrush(QColor(color));
    sym.setStyle(QwtSymbol::Rect);
    sym.setSize(
			QSize(1, 20)
			);
	curve->setSymbol(sym);
	curve->setStyle(QwtPlotCurve::NoCurve);

	if(adapter.size() > 0) {
		setupPlot(adapter.boundingRect());
		curve->setData(adapter);
		curve->attach(plot);
	}

	if(!legend) {
		return;
	}

    // Добавляем кривую в легенду
	QwtLegendItem *item = new QwtLegendItem(0);
	item->setText(curve->title());
	item->setSymbol(sym);
	item->setIdentifierMode(QwtLegendItem::ShowLine | QwtLegendItem::ShowSymbol | QwtLegendItem::ShowText);
	legend->insert(curve, item);
}
AMTESTCentralWidgetView::AMTESTCentralWidgetView(QWidget *parent)
	: QWidget(parent)
{
	AMTESTServerConnectionButton *scalerButton = new AMTESTServerConnectionButton(AMTESTStripTool::stripTool()->serverConnectionByName("Scaler"));
	AMTESTServerConnectionButton *ampteksButton = new AMTESTServerConnectionButton(AMTESTStripTool::stripTool()->serverConnectionByName("Ampteks"));
	AMTESTServerConnectionButton *pvsButton = new AMTESTServerConnectionButton(AMTESTStripTool::stripTool()->serverConnectionByName("PVs"));

	QHBoxLayout *connectionButtonsLayout = new QHBoxLayout;
	connectionButtonsLayout->addWidget(scalerButton);
	connectionButtonsLayout->addWidget(ampteksButton);
	connectionButtonsLayout->addWidget(pvsButton);

	setupPlot();

	AMTESTStripTool *stripTool = AMTESTStripTool::stripTool();
	dataModelListView_ = new AMTESTDataModelListView;
	connect(stripTool, SIGNAL(dataModelsCreated(AMTESTServerConnection*)), dataModelListView_, SLOT(addNewDataModels(AMTESTServerConnection*)));
	connect(stripTool, SIGNAL(dataModelsDeleted(QStringList)), dataModelListView_, SLOT(removeDataModels(QStringList)));
	connect(stripTool, SIGNAL(dataModelsDeleted(QStringList)), this, SLOT(onDataModelsDeleted(QStringList)));
	connect(stripTool, SIGNAL(dataModelsCreated(AMTESTServerConnection*)), this, SLOT(updateWidgetAppearance()));
	connect(stripTool, SIGNAL(dataModelsDeleted(QStringList)), this, SLOT(updateWidgetAppearance()));
	connect(dataModelListView_, SIGNAL(dataModelToBeAdded(QString)), this, SLOT(onDataModelToBeAdded(QString)));
	connect(dataModelListView_, SIGNAL(dataModelToBeRemoved(QString)), this, SLOT(onDataModelToBeRemoved(QString)));

	QHBoxLayout *horizontalLayout = new QHBoxLayout;
	horizontalLayout->addWidget(plotWidget_);
	horizontalLayout->addWidget(dataModelListView_);

	timeIntervalSpinBox_ = new QDoubleSpinBox;
	timeIntervalSpinBox_->setAlignment(Qt::AlignCenter);
	timeIntervalSpinBox_->setDecimals(3);
	timeIntervalSpinBox_->setSuffix("s");
	timeIntervalSpinBox_->setValue(1.0);
	startButton_ = new QPushButton(QIcon(":/22x22/media-playback-start.png"), "Start");
	startButton_->setEnabled(false);
	stopButton_ = new QPushButton(QIcon(":/22x22/media-playback-stop.png"), "Stop");
	stopButton_->setEnabled(false);

	connect(startButton_, SIGNAL(clicked(bool)), this, SLOT(startAcquisition()));
	connect(stopButton_, SIGNAL(clicked(bool)), this, SLOT(stopAcquisition()));

	imageDataModelName_ = "";

	QHBoxLayout *bottomBarLayout = new QHBoxLayout;
	bottomBarLayout->addWidget(timeIntervalSpinBox_);
	bottomBarLayout->addWidget(startButton_);
	bottomBarLayout->addWidget(stopButton_);

	QVBoxLayout *centralWidgetLayout = new QVBoxLayout;
	centralWidgetLayout->addLayout(connectionButtonsLayout);
	centralWidgetLayout->addLayout(horizontalLayout);
	centralWidgetLayout->addLayout(bottomBarLayout);

	setLayout(centralWidgetLayout);
}
void viewGVpropertieslayout::actionAddGraph_triggered() {

    QCustomPlot * plot = new QCustomPlot;
    setupPlot(plot);

    QMdiSubWindow * mdiSubWin = viewGV->mdiarea->addSubWindow(plot);

    if (mdiSubWin != NULL) {
        mdiSubWin->setVisible(true);
    }
}
示例#8
0
dialog_inputs::dialog_inputs(XMLReadWrite &XmlObj, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::dialog_inputs)
{
    ui->setupUi(this);

    XmlDoc = XmlObj;
    closeOk = true;

    readXml();

    setupPlot();
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setupPlot(ui->customPlot);

    isMyComOpen = false;
    isStart = false;
    ui->button_close->setEnabled(false);

    read_saved_pid_parameter();
    select_serial_port();
}
示例#10
0
void VectorPlot::addLinePlot(const VectorQwtAdapter &adapter) {
	setupPlot(adapter.boundingRect());
	QwtPlotCurve *curve = new QwtPlotCurve();

    QwtSymbol sym;
    sym.setStyle(QwtSymbol::Cross);
    sym.setPen(QColor(Qt::black));
    sym.setSize(2);
	curve->setSymbol(sym);
	curve->setPen(QColor(Qt::darkGreen));

	curve->setData(adapter);
	curve->attach(plot);
}
示例#11
0
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
{
  ui->setupUi(this);
  connect(ui->cbUseCurrentSize, SIGNAL(toggled(bool)), ui->sbWidth, SLOT(setDisabled(bool)));
  connect(ui->cbUseCurrentSize, SIGNAL(toggled(bool)), ui->sbHeight, SLOT(setDisabled(bool)));
  
  ui->plot->axisRect()->setMinimumSize(300, 180);
  setupPlot();
  
  // register the plot document object (only needed once, no matter how many plots will be in the QTextDocument):
  QCPDocumentObject *plotObjectHandler = new QCPDocumentObject(this);
  ui->textEdit->document()->documentLayout()->registerHandler(QCPDocumentObject::PlotTextFormat, plotObjectHandler);
}
示例#12
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setupPlot();

    socket = new TCPSocket(this);
    connect(socket, SIGNAL(sendPosition(qreal,qreal,qreal,qreal,qreal)),
            ui->widget, SLOT(paintPosition(qreal,qreal,qreal,qreal,qreal)));

    connect(socket, SIGNAL(sendError(qreal,qreal,qreal,qreal)), this, SLOT(setError(qreal,qreal,qreal,qreal)));
    connect(socket, SIGNAL(sendSpeed(qreal,qreal,qreal,qreal)), this, SLOT(setSpeed(qreal,qreal,qreal,qreal)));
    connect(socket, SIGNAL(taskDone()), this, SLOT(enableButton()));

    time = 0;
}
示例#13
0
void VectorPlot::addPrelabelingPlot(const std::vector<double> &preLabeling)
{
	QwtDoubleRect boundingRect(0, 1, preLabeling.size() - 1, 2);

	setupPlot(boundingRect);

	QwtPlotCurve* curve = new QwtPlotCurve;

	QwtArray<double> xData, yData;
	for(unsigned i = 0; i < preLabeling.size(); ++i) {
		xData.push_back(i);
		yData.push_back(preLabeling[i] >= 0 ? preLabeling[i] : 1);
	}

	curve->setData(xData, yData);

	curve->attach(plot);
}
示例#14
0
void VectorPlot::addMarking(const std::vector<int> &marking)
{
	QwtDoubleRect boundingRect(0, 1, marking.size() - 1, 2);

	setupPlot(boundingRect);

	// this is gonna be slow...
	for(unsigned i = 0; i < marking.size(); ++i) {
		QwtPlotMarker* marker = new QwtPlotMarker();
		QwtText text;
		text.setText(QString::number(marking[i]));

		marker->setLabel(text);

		marker->setXValue((double)i);
		marker->setYValue(0.0);

		marker->attach(plot);
	}
}
示例#15
0
//BeamPositionMonitor::BeamPositionMonitor(QString name, AMProcessVariable *x, AMProcessVariable *y, AMProcessVariable *intensity, QWidget *parent)
BeamPositionMonitor::BeamPositionMonitor(QString name, AMProcessVariable *x, AMProcessVariable *y, QWidget *parent)
	: QWidget(parent)
{
	xy_ = new AMXYScatterPVDataSource(x, y, name, this);

	/// These can be added back in when an intensity PV is available.
	//intensity_ = intensity;
	//connect(intensity_, SIGNAL(valueChanged(double)), this, SLOT(onIntensityChanged(double)));

	// This has to come after xy_ is set because we make a series in here using the member variable xy_.  If it's not valid, the class would never work because we haven't
	// programmed a way to change xy_ or intensity_ after the class is instantiated.
	setupPlot();

	// Make a layout and put the plot window in it.
	QVBoxLayout *plotLayout = new QVBoxLayout;
	plotLayout->addWidget(view_);

	// Pushes all changes to the layout to be viewed.
	setLayout(plotLayout);
}
示例#16
0
BeamPositionMonitor::BeamPositionMonitor(QWidget *parent) :
	QWidget(parent)
{
	// Data source that takes in the new PVs for the x and y position.
	xy_ = new AMXYScatterPVDataSource(new AMProcessVariable("AO2023-02:Stage1:Voltage:X", true, this), new AMProcessVariable("AO2023-02:Stage1:Voltage:Y", true, this), "Look at me go!", this);

	/// These can be added back in when an intensity PV is available.
	//intensity_ = new AMProcessVariable("darrenIsAwesome:Intensity", true, this);
	//connect(intensity_, SIGNAL(valueChanged(double)), this, SLOT(onIntensityChanged(double)));

	// This has to come after xy_ is set because we make a series in here using the member variable xy_.  If it's not valid, the class would never work because we haven't
	// programmed a way to change xy_ or intensity_ after the class is instantiated.
	setupPlot();

	// Make a layout and put the plot window in it.
	QVBoxLayout *plotLayout = new QVBoxLayout;
	plotLayout->addWidget(view_);

	// Pushes all changes to the layout to be viewed.
	setLayout(plotLayout);
}