12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #include "xyplotwindow.h"
- #include "ui_xyplotwindow.h"
- #include "qcustomplot.h"
- #include <cmath>
-
- /// \fn XYPlotWindow::XYPlotWindow(QWidget *parent)
- /// \~English
- /// \brief Constructor
- /// \~Spanish
- /// \brief Constructor
- XYPlotWindow::XYPlotWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::XYPlotWindow)
- {
- ui->setupUi(this);
- }
-
-
- /// \fn void XYPlotWindow::AddPointToGraph(double x, double y)
- /// \~English
- /// \brief Adds a coordinate (x,y) to the XX and YY vectors.
- /// \param x value of the coordinate (x,y) to be added to vector XX.
- /// \param y value of the coordinate (x,y) to be added to vector YY.
- /// \~Spanish
- /// \brief Anade una coordenada (x,y) a los vectores XX y YY.
- /// \param x valor de la coordenada (x,y) a ser anadido al vector XX.
- /// \param y valor de la coordenada (x,y) a ser anadido al vector YY.
- void XYPlotWindow::AddPointToGraph(double x, double y) {
- XX.push_back(x);
- YY.push_back(y);
- }
-
- /// \fn void XYPlotWindow::Plot()
- /// \~English
- /// \brief Plots the coordinates inserted in the vectors XX and YY.
- /// \~Spanish
- /// \brief Grafica las coordenadas insertadas en los vectores XX y YY.
- void XYPlotWindow::Plot() {
- ui->customPlot->xAxis->setLabel("x");
- ui->customPlot->yAxis->setLabel("y");
- ui->customPlot->xAxis->setRange(-25.0, 25.0);
- ui->customPlot->yAxis->setRange(-25.0, 25.0);
-
- QCPCurve *myCurve = new QCPCurve(ui->customPlot->xAxis, ui->customPlot->yAxis);
- ui->customPlot->addPlottable(myCurve);
- myCurve->setData(XX,YY);
- }
-
- /// \fn XYPlotWindow::~XYPlotWindow()
- /// \~English
- /// \brief Destructor
- /// \~Spanish
- /// \brief Destructor
- XYPlotWindow::~XYPlotWindow()
- {
- delete ui;
- }
|