Adding AnalysisWindow dialog. Test calculate ballistic trajectory now opens trajectory plot in new AnalysisWindow
This commit is contained in:
parent
4fc92cfb64
commit
3f6342994d
@ -37,6 +37,11 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
void addMotorModels(std::vector<MotorModel>& m);
|
void addMotorModels(std::vector<MotorModel>& m);
|
||||||
|
|
||||||
|
void addRocket(std::shared_ptr<Rocket> r) { rocket = r; }
|
||||||
|
|
||||||
|
std::shared_ptr<Rocket> getRocket() { return rocket; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QtRocket();
|
QtRocket();
|
||||||
|
|
||||||
|
@ -1,14 +1,46 @@
|
|||||||
#include "AnalysisWindow.h"
|
#include "AnalysisWindow.h"
|
||||||
#include "ui_AnalysisWindow.h"
|
#include "ui_AnalysisWindow.h"
|
||||||
|
|
||||||
|
#include "QtRocket.h"
|
||||||
|
|
||||||
AnalysisWindow::AnalysisWindow(QWidget *parent) :
|
AnalysisWindow::AnalysisWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::AnalysisWindow)
|
ui(new Ui::AnalysisWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->setWindowModality(Qt::NonModal);
|
||||||
|
this->hide();
|
||||||
|
this->show();
|
||||||
|
|
||||||
|
std::shared_ptr<Rocket> rocket = QtRocket::getInstance()->getRocket();
|
||||||
|
const std::vector<std::pair<double, std::vector<double>>>& res = rocket->getStates();
|
||||||
|
/*
|
||||||
|
for(const auto& i : res)
|
||||||
|
{
|
||||||
|
std::cout << i.first << ": " << "(" << i.second[0] << ", " << i.second[1] << ", " << i.second[2] << ")\n";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
auto& plot = ui->plotWidget;
|
||||||
|
// generate some data:
|
||||||
|
QVector<double> tData(res.size()), zData(res.size());
|
||||||
|
for (int i = 0; i < tData.size(); ++i)
|
||||||
|
{
|
||||||
|
tData[i] = res[i].first;
|
||||||
|
zData[i] = res[i].second[2];
|
||||||
|
}
|
||||||
|
// create graph and assign data to it:
|
||||||
|
plot->addGraph();
|
||||||
|
plot->graph(0)->setData(tData, zData);
|
||||||
|
// give the axes some labels:
|
||||||
|
plot->xAxis->setLabel("time");
|
||||||
|
plot->yAxis->setLabel("Z");
|
||||||
|
// set axes ranges, so we see all data:
|
||||||
|
plot->xAxis->setRange(*std::min_element(std::begin(tData), std::end(tData)), *std::max_element(std::begin(tData), std::end(tData)));
|
||||||
|
plot->yAxis->setRange(*std::min_element(std::begin(zData), std::end(zData)), *std::max_element(std::begin(zData), std::end(zData)));
|
||||||
|
plot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalysisWindow::~AnalysisWindow()
|
AnalysisWindow::~AnalysisWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#ifndef ANALYSISWINDOW_H
|
#ifndef ANALYSISWINDOW_H
|
||||||
#define ANALYSISWINDOW_H
|
#define ANALYSISWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AnalysisWindow;
|
class AnalysisWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnalysisWindow : public QMainWindow
|
class AnalysisWindow : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AnalysisWindow(QWidget *parent = nullptr);
|
explicit AnalysisWindow(QWidget *parent = nullptr);
|
||||||
~AnalysisWindow();
|
~AnalysisWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AnalysisWindow *ui;
|
Ui::AnalysisWindow *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ANALYSISWINDOW_H
|
#endif // ANALYSISWINDOW_H
|
||||||
|
@ -1,48 +1,37 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>AnalysisWindow</class>
|
<class>AnalysisWindow</class>
|
||||||
<widget class="QMainWindow" name="AnalysisWindow">
|
<widget class="QDialog" name="AnalysisWindow">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>989</width>
|
||||||
<height>600</height>
|
<height>821</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QCustomPlot" name="plotWidget" native="true">
|
||||||
<widget class="QWidget" name="widget" native="true">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>9</x>
|
|
||||||
<y>9</y>
|
|
||||||
<width>701</width>
|
|
||||||
<height>351</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenuBar" name="menubar">
|
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>19</x>
|
||||||
<y>0</y>
|
<y>29</y>
|
||||||
<width>800</width>
|
<width>961</width>
|
||||||
<height>22</height>
|
<height>671</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
|
||||||
<property name="title">
|
|
||||||
<string>File</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menuFile"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>QCustomPlot</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>gui/qcustomplot.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
#include "AboutWindow.h"
|
#include "gui/AboutWindow.h"
|
||||||
|
#include "gui/AnalysisWindow.h"
|
||||||
|
|
||||||
#include "utils/math/Vector3.h"
|
|
||||||
#include "sim/RK4Solver.h"
|
#include "sim/RK4Solver.h"
|
||||||
#include "model/Rocket.h"
|
#include "model/Rocket.h"
|
||||||
|
|
||||||
@ -79,13 +79,19 @@ void MainWindow::on_testButton2_clicked()
|
|||||||
|
|
||||||
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
||||||
double initialVelocityZ = initialVelocity * std::sin(initialAngle / 57.2958);
|
double initialVelocityZ = initialVelocity * std::sin(initialAngle / 57.2958);
|
||||||
Rocket rocket;
|
std::shared_ptr<Rocket> rocket = std::make_shared<Rocket>();
|
||||||
|
QtRocket::getInstance()->addRocket(rocket);
|
||||||
std::vector<double> initialState = {0.0, 0.0, 0.0, initialVelocityX, 0.0, initialVelocityZ, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
std::vector<double> initialState = {0.0, 0.0, 0.0, initialVelocityX, 0.0, initialVelocityZ, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||||
rocket.setInitialState(initialState);
|
rocket->setInitialState(initialState);
|
||||||
rocket.setMass(mass);
|
rocket->setMass(mass);
|
||||||
rocket.setDragCoefficient(dragCoeff);
|
rocket->setDragCoefficient(dragCoeff);
|
||||||
rocket.launch();
|
rocket->launch();
|
||||||
|
|
||||||
|
AnalysisWindow aWindow;
|
||||||
|
aWindow.setModal(false);
|
||||||
|
aWindow.exec();
|
||||||
|
|
||||||
|
/*
|
||||||
const std::vector<std::pair<double, std::vector<double>>>& res = rocket.getStates();
|
const std::vector<std::pair<double, std::vector<double>>>& res = rocket.getStates();
|
||||||
for(const auto& i : res)
|
for(const auto& i : res)
|
||||||
{
|
{
|
||||||
@ -109,10 +115,10 @@ void MainWindow::on_testButton2_clicked()
|
|||||||
plot->xAxis->setRange(*std::min_element(std::begin(tData), std::end(tData)), *std::max_element(std::begin(tData), std::end(tData)));
|
plot->xAxis->setRange(*std::min_element(std::begin(tData), std::end(tData)), *std::max_element(std::begin(tData), std::end(tData)));
|
||||||
plot->yAxis->setRange(*std::min_element(std::begin(zData), std::end(zData)), *std::max_element(std::begin(zData), std::end(zData)));
|
plot->yAxis->setRange(*std::min_element(std::begin(zData), std::end(zData)), *std::max_element(std::begin(zData), std::end(zData)));
|
||||||
plot->replot();
|
plot->replot();
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_loadRSE_button_clicked()
|
void MainWindow::on_loadRSE_button_clicked()
|
||||||
{
|
{
|
||||||
QString rseFile = QFileDialog::getOpenFileName(this,
|
QString rseFile = QFileDialog::getOpenFileName(this,
|
||||||
|
@ -27,8 +27,11 @@ public:
|
|||||||
void setThrustCurve(const Thrustcurve& curve);
|
void setThrustCurve(const Thrustcurve& curve);
|
||||||
|
|
||||||
bool terminateCondition(const std::pair<double, std::vector<double>>& cond);
|
bool terminateCondition(const std::pair<double, std::vector<double>>& cond);
|
||||||
|
|
||||||
|
void setName(const std::string& n) { name = n; }
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
std::string name;
|
||||||
sim::Propagator propagator;
|
sim::Propagator propagator;
|
||||||
double dragCoeff;
|
double dragCoeff;
|
||||||
double mass;
|
double mass;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user