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 addRocket(std::shared_ptr<Rocket> r) { rocket = r; }
|
||||
|
||||
std::shared_ptr<Rocket> getRocket() { return rocket; }
|
||||
|
||||
private:
|
||||
QtRocket();
|
||||
|
||||
|
@ -1,11 +1,43 @@
|
||||
#include "AnalysisWindow.h"
|
||||
#include "ui_AnalysisWindow.h"
|
||||
|
||||
#include "QtRocket.h"
|
||||
|
||||
AnalysisWindow::AnalysisWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
QDialog(parent),
|
||||
ui(new Ui::AnalysisWindow)
|
||||
{
|
||||
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()
|
||||
|
@ -1,13 +1,13 @@
|
||||
#ifndef ANALYSISWINDOW_H
|
||||
#define ANALYSISWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class AnalysisWindow;
|
||||
}
|
||||
|
||||
class AnalysisWindow : public QMainWindow
|
||||
class AnalysisWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -1,48 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AnalysisWindow</class>
|
||||
<widget class="QMainWindow" name="AnalysisWindow">
|
||||
<widget class="QDialog" name="AnalysisWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
<width>989</width>
|
||||
<height>821</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QCustomPlot" name="plotWidget" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>9</y>
|
||||
<width>701</width>
|
||||
<height>351</height>
|
||||
<x>19</x>
|
||||
<y>29</y>
|
||||
<width>961</width>
|
||||
<height>671</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QCustomPlot</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/qcustomplot.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "MainWindow.h"
|
||||
#include "gui/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 "model/Rocket.h"
|
||||
|
||||
@ -79,13 +79,19 @@ void MainWindow::on_testButton2_clicked()
|
||||
|
||||
double initialVelocityX = initialVelocity * std::cos(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};
|
||||
rocket.setInitialState(initialState);
|
||||
rocket.setMass(mass);
|
||||
rocket.setDragCoefficient(dragCoeff);
|
||||
rocket.launch();
|
||||
rocket->setInitialState(initialState);
|
||||
rocket->setMass(mass);
|
||||
rocket->setDragCoefficient(dragCoeff);
|
||||
rocket->launch();
|
||||
|
||||
AnalysisWindow aWindow;
|
||||
aWindow.setModal(false);
|
||||
aWindow.exec();
|
||||
|
||||
/*
|
||||
const std::vector<std::pair<double, std::vector<double>>>& res = rocket.getStates();
|
||||
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->yAxis->setRange(*std::min_element(std::begin(zData), std::end(zData)), *std::max_element(std::begin(zData), std::end(zData)));
|
||||
plot->replot();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_loadRSE_button_clicked()
|
||||
{
|
||||
QString rseFile = QFileDialog::getOpenFileName(this,
|
||||
|
@ -27,8 +27,11 @@ public:
|
||||
void setThrustCurve(const Thrustcurve& curve);
|
||||
|
||||
bool terminateCondition(const std::pair<double, std::vector<double>>& cond);
|
||||
|
||||
void setName(const std::string& n) { name = n; }
|
||||
private:
|
||||
|
||||
std::string name;
|
||||
sim::Propagator propagator;
|
||||
double dragCoeff;
|
||||
double mass;
|
||||
|
Loading…
x
Reference in New Issue
Block a user