WIP
This commit is contained in:
parent
29a9c7fb68
commit
6e00f22ce4
2
.gitignore
vendored
2
.gitignore
vendored
@ -37,3 +37,5 @@ build/
|
||||
# IDE
|
||||
.vscode/qtrocket.pro.user
|
||||
qtrocket.pro.user
|
||||
.qmake.stash
|
||||
|
||||
|
18
QtRocket.cpp
18
QtRocket.cpp
@ -1,15 +1,17 @@
|
||||
#include "QtRocket.h"
|
||||
#include "ui_QtRocket.h"
|
||||
|
||||
QtRocket::QtRocket(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::QtRocket)
|
||||
QtRocket* QtRocket::instance = nullptr;
|
||||
|
||||
QtRocket* QtRocket::getInstance()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(!instance)
|
||||
{
|
||||
instance = new QtRocket();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
QtRocket::~QtRocket()
|
||||
QtRocket::QtRocket()
|
||||
{
|
||||
delete ui;
|
||||
logger = utils::Logger::getInstance();
|
||||
}
|
||||
|
||||
|
30
QtRocket.h
30
QtRocket.h
@ -1,21 +1,27 @@
|
||||
#ifndef QTROCKET_H
|
||||
#define QTROCKET_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "utils/Logger.h"
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class QtRocket; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class QtRocket : public QMainWindow
|
||||
/**
|
||||
* @brief The QtRocket class is the master controller for the QtRocket application.
|
||||
* It is the singleton that controls the interaction of the various components of
|
||||
* the QtRocket program
|
||||
*/
|
||||
class QtRocket
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtRocket(QWidget *parent = nullptr);
|
||||
~QtRocket();
|
||||
|
||||
static QtRocket* getInstance();
|
||||
private:
|
||||
Ui::QtRocket *ui;
|
||||
QtRocket();
|
||||
|
||||
static QtRocket* instance;
|
||||
|
||||
utils::Logger* logger;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // QTROCKET_H
|
||||
|
116
QtRocket.ui
116
QtRocket.ui
@ -1,116 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QtRocket</class>
|
||||
<widget class="QMainWindow" name="QtRocket">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1031</width>
|
||||
<height>694</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QtRocket</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="qtrocket.qrc">
|
||||
<normaloff>:/qtrocket.png</normaloff>:/qtrocket.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="2">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>2</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTreeView" name="treeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>80</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>80</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QCustomPlot" name="widget_2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1031</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QCustomPlot</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qcustomplot.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="qtrocket.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
21
gui/AboutWindow.cpp
Normal file
21
gui/AboutWindow.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "AboutWindow.h"
|
||||
#include "ui_AboutWindow.h"
|
||||
|
||||
AboutWindow::AboutWindow(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AboutWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowTitle(QString("About QtRocket"));
|
||||
}
|
||||
|
||||
AboutWindow::~AboutWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AboutWindow::on_pushButton_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
25
gui/AboutWindow.h
Normal file
25
gui/AboutWindow.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef ABOUTWINDOW_H
|
||||
#define ABOUTWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class AboutWindow;
|
||||
}
|
||||
|
||||
class AboutWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutWindow(QWidget *parent = nullptr);
|
||||
~AboutWindow();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::AboutWindow *ui;
|
||||
};
|
||||
|
||||
#endif // ABOUTWINDOW_H
|
48
gui/AboutWindow.ui
Normal file
48
gui/AboutWindow.ui
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AboutWindow</class>
|
||||
<widget class="QDialog" name="AboutWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>60</y>
|
||||
<width>261</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string>Copyright (c) 2023 by Travis Hunter</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>240</y>
|
||||
<width>80</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
130
gui/MainWindow.cpp
Normal file
130
gui/MainWindow.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
#include "MainWindow.h"
|
||||
#include "ui_MainWindow.h"
|
||||
#include "AboutWindow.h"
|
||||
|
||||
#include "utils/math/Vector3.h"
|
||||
#include "sim/RK4Solver.h"
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
#include <memory>
|
||||
#include <cmath>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
{
|
||||
AboutWindow about;
|
||||
about.setModal(true);
|
||||
about.exec();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_testButton1_clicked()
|
||||
{
|
||||
auto& plot = ui->plotWindow;
|
||||
// generate some data:
|
||||
QVector<double> x(101), y(101); // initialize with entries 0..100
|
||||
for (int i=0; i<101; ++i)
|
||||
{
|
||||
x[i] = i/50.0 - 1; // x goes from -1 to 1
|
||||
y[i] = x[i]*x[i]; // let's plot a quadratic function
|
||||
}
|
||||
// create graph and assign data to it:
|
||||
plot->addGraph();
|
||||
plot->graph(0)->setData(x, y);
|
||||
// give the axes some labels:
|
||||
plot->xAxis->setLabel("x");
|
||||
plot->yAxis->setLabel("y");
|
||||
// set axes ranges, so we see all data:
|
||||
plot->xAxis->setRange(-1, 1);
|
||||
plot->yAxis->setRange(0, 1);
|
||||
plot->replot();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_testButton2_clicked()
|
||||
{
|
||||
// Get the initial conditions
|
||||
double initialVelocity =
|
||||
ui->rocketPartButtons->findChild<QLineEdit*>(QString("initialVelocity"))->text().toDouble();
|
||||
|
||||
double mass =
|
||||
ui->rocketPartButtons->findChild<QLineEdit*>(QString("mass"))->text().toDouble();
|
||||
|
||||
double initialAngle =
|
||||
ui->rocketPartButtons->findChild<QLineEdit*>(QString("initialAngle"))->text().toDouble();
|
||||
|
||||
double dragCoeff =
|
||||
ui->rocketPartButtons->findChild<QLineEdit*>(QString("dragCoeff"))->text().toDouble();
|
||||
|
||||
double initialVelocityX = initialVelocity * std::cos(initialAngle / 57.2958);
|
||||
double initialVelocityY = initialVelocity * std::sin(initialAngle / 57.2958);
|
||||
math::Vector3 initialVelVector(initialVelocityX, initialVelocityY, 0.0);
|
||||
std::vector<math::Vector3> position;
|
||||
position.emplace_back(0.0, 0.0, 0.0);
|
||||
|
||||
std::vector<math::Vector3> velocity;
|
||||
velocity.push_back(initialVelVector);
|
||||
|
||||
double ts = 0.01;
|
||||
|
||||
sim::RK4Solver velXSolver([=](double x, double t) -> double { return 0.0; });
|
||||
velXSolver.setTimeStep(ts);
|
||||
sim::RK4Solver velYSolver([=](double y, double t) -> double { return -9.8; });
|
||||
velYSolver.setTimeStep(ts);
|
||||
|
||||
sim::RK4Solver posXSolver([=](double x, double t) -> double { return velXSolver.step(x, t); });
|
||||
posXSolver.setTimeStep(ts);
|
||||
sim::RK4Solver posYSolver([=](double y, double t) -> double { return velYSolver.step(x, t); });
|
||||
posYSolver.setTimeStep(ts);
|
||||
|
||||
|
||||
// These can be solved independently for now. Maybe figure out how to merge them later
|
||||
size_t maxTs = std::ceil(100.0 / ts);
|
||||
QTextStream cout(stdout);
|
||||
cout << "Initial X velocity: " << initialVelocityX << "\n";
|
||||
cout << "Initial Y velocity: " << initialVelocityY << "\n";
|
||||
for(size_t i = 0; i < maxTs; ++i)
|
||||
{
|
||||
position.emplace_back(posXSolver.step(position[i].getX1(), i * ts),
|
||||
posYSolver.step(position[i].getX2(), i * ts),
|
||||
0.0);
|
||||
|
||||
cout << "(" << position[i].getX1() << ", " << position[i].getX2() << ")\n";
|
||||
|
||||
}
|
||||
|
||||
auto& plot = ui->plotWindow;
|
||||
// generate some data:
|
||||
QVector<double> x(position.size()), y(position.size());
|
||||
for (int i = 0; i < x.size(); ++i)
|
||||
{
|
||||
x[i] = position[i].getX1();
|
||||
y[i] = position[i].getX2();
|
||||
}
|
||||
// create graph and assign data to it:
|
||||
plot->addGraph();
|
||||
plot->graph(0)->setData(x, y);
|
||||
// give the axes some labels:
|
||||
plot->xAxis->setLabel("x");
|
||||
plot->yAxis->setLabel("y");
|
||||
// set axes ranges, so we see all data:
|
||||
plot->xAxis->setRange(*std::min_element(std::begin(x), std::end(x)), *std::max_element(std::begin(x), std::end(x)));
|
||||
plot->yAxis->setRange(*std::min_element(std::begin(y), std::end(y)), *std::max_element(std::begin(y), std::end(y)));
|
||||
plot->replot();
|
||||
}
|
||||
|
28
gui/MainWindow.h
Normal file
28
gui/MainWindow.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef QTROCKET_H
|
||||
#define QTROCKET_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_actionAbout_triggered();
|
||||
|
||||
void on_testButton1_clicked();
|
||||
|
||||
void on_testButton2_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
};
|
||||
#endif // QTROCKET_H
|
279
gui/MainWindow.ui
Normal file
279
gui/MainWindow.ui
Normal file
@ -0,0 +1,279 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1031</width>
|
||||
<height>694</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QtRocket</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../qtrocket.qrc">
|
||||
<normaloff>:/images/resources/rocket64.png</normaloff>:/images/resources/rocket64.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>6</x>
|
||||
<y>6</y>
|
||||
<width>1021</width>
|
||||
<height>631</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="RocketTreeView" name="rocketTreeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="rocketPartButtons" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QPushButton" name="testButton1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>80</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TestButton1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="testButton2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>191</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Calculate Ballistic Trajectory</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>80</y>
|
||||
<width>161</width>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Velocity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="initialVelocity"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="initialAngle"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>mass</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="mass"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Cd</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="dragCoeff"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QCustomPlot" name="plotWindow" native="true"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1031</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_As"/>
|
||||
<addaction name="actionClose"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit">
|
||||
<property name="title">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
<string>Tools</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuTools"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
<iconset theme="document-new">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="application-exit">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_As">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save-as">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save As</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>RocketTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>gui/RocketTreeView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QCustomPlot</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/qcustomplot.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../qtrocket.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
6
gui/RocketTreeView.cpp
Normal file
6
gui/RocketTreeView.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "RocketTreeView.h"
|
||||
|
||||
RocketTreeView::RocketTreeView(QWidget* parent) : QTreeView(parent)
|
||||
{
|
||||
|
||||
}
|
18
gui/RocketTreeView.h
Normal file
18
gui/RocketTreeView.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef ROCKETTREEVIEW_H
|
||||
#define ROCKETTREEVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
/**
|
||||
* @brief RocketTreeView basically just renames QTreeView with a specific
|
||||
* memorable name.
|
||||
*/
|
||||
class RocketTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RocketTreeView(QWidget* parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // ROCKETTREEVIEW_H
|
4
main.cpp
4
main.cpp
@ -1,4 +1,4 @@
|
||||
#include "QtRocket.h"
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLocale>
|
||||
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Go!
|
||||
QtRocket w;
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
19
qtrocket.pro
19
qtrocket.pro
@ -9,33 +9,41 @@ CONFIG += c++17
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
QtRocket.cpp \
|
||||
gui/AboutWindow.cpp \
|
||||
gui/qcustomplot.cpp \
|
||||
main.cpp \
|
||||
gui/RocketTreeView.cpp \
|
||||
gui/MainWindow.cpp \
|
||||
model/Motor.cpp \
|
||||
model/MotorCase.cpp \
|
||||
model/Thrustcurve.cpp \
|
||||
qcustomplot.cpp \
|
||||
sim/AtmosphericModel.cpp \
|
||||
sim/GravityModel.cpp \
|
||||
sim/Propagator.cpp \
|
||||
sim/RK4Solver.cpp \
|
||||
sim/SphericalGeoidModel.cpp \
|
||||
sim/SphericalGravityModel.cpp \
|
||||
sim/StateData.cpp \
|
||||
sim/USStandardAtmosphere.cpp \
|
||||
sim/WindModel.cpp \
|
||||
utils/BinMap.cpp \
|
||||
utils/CurlConnection.cpp \
|
||||
utils/Logger.cpp \
|
||||
utils/ThreadPool.cpp \
|
||||
utils/ThrustCurveAPI.cpp \
|
||||
utils/math/Quaternion.cpp \
|
||||
utils/math/Vector3.cpp
|
||||
|
||||
HEADERS += \
|
||||
QtRocket.h \
|
||||
gui/AboutWindow.h \
|
||||
gui/RocketTreeView.h \
|
||||
gui/MainWindow.h \
|
||||
gui/qcustomplot.h \
|
||||
model/Motor.h \
|
||||
model/MotorCase.h \
|
||||
model/Thrustcurve.h \
|
||||
qcustomplot.h \
|
||||
sim/AtmosphericModel.h \
|
||||
sim/DESolver.h \
|
||||
sim/GeoidModel.h \
|
||||
@ -44,18 +52,21 @@ HEADERS += \
|
||||
sim/RK4Solver.h \
|
||||
sim/SphericalGeoidModel.h \
|
||||
sim/SphericalGravityModel.h \
|
||||
sim/StateData.h \
|
||||
sim/USStandardAtmosphere.h \
|
||||
sim/WindModel.h \
|
||||
utils/BinMap.h \
|
||||
utils/CurlConnection.h \
|
||||
utils/Logger.h \
|
||||
utils/ThreadPool.h \
|
||||
utils/ThrustCurveAPI.h \
|
||||
utils/math/Constants.h \
|
||||
utils/math/Quaternion.h \
|
||||
utils/math/Vector3.h
|
||||
|
||||
FORMS += \
|
||||
QtRocket.ui
|
||||
gui/AboutWindow.ui \
|
||||
gui/MainWindow.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
qtrocket_en_US.ts
|
||||
|
11
qtrocket.qrc
11
qtrocket.qrc
@ -1,7 +1,6 @@
|
||||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
<qresource>
|
||||
<file alias="qtrocket.png">resources/qtrocket.png</file>
|
||||
</qresource>
|
||||
<RCC>
|
||||
<qresource prefix="/"/>
|
||||
<qresource prefix="/images">
|
||||
<file>resources/rocket64.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
BIN
resources/rocket64.png
Normal file
BIN
resources/rocket64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
@ -10,7 +10,8 @@ public:
|
||||
DESolver() {}
|
||||
virtual ~DESolver() {}
|
||||
|
||||
virtual double step(double curVal, double t, double dt) = 0;
|
||||
virtual void setTimeStep(double ts) = 0;
|
||||
virtual double step(double curVal, double t) const = 0;
|
||||
};
|
||||
|
||||
} // namespace sim
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace sim {
|
||||
|
||||
double RK4Solver::step(double curVal, double t, double dt)
|
||||
double RK4Solver::step(double curVal, double t) const
|
||||
{
|
||||
double retVal(0.0);
|
||||
|
||||
k1 = de(t, curVal);
|
||||
k2 = de(t + dt / 2.0, curVal + (dt * k1 / 2.0));
|
||||
k3 = de(t + dt / 2.0, curVal + (dt * k2 / 2.0));
|
||||
k4 = de(t + dt, curVal + dt * k3);
|
||||
double k1 = de(curVal, t);
|
||||
double k2 = de(curVal + (dt * k1 / 2.0), t + dt / 2.0);
|
||||
double k3 = de(curVal + (dt * k2 / 2.0), t + dt / 2.0);
|
||||
double k4 = de(curVal + dt * k3, t + dt);
|
||||
retVal = curVal + (1.0 / 6.0)*dt*(k1 + 2.0*k2 + 2.0*k3 + k4);
|
||||
|
||||
return retVal;
|
||||
|
@ -10,15 +10,18 @@ namespace sim {
|
||||
class RK4Solver : public DESolver
|
||||
{
|
||||
public:
|
||||
RK4Solver(const std::function<double(double, double)>& d) : de(d) {}
|
||||
RK4Solver(std::function<double(double, double)> d) : de(d) {}
|
||||
virtual ~RK4Solver() {}
|
||||
|
||||
virtual double step(double curVal, double t, double dt) override;
|
||||
void setTimeStep(double inTs) override { dt = inTs; }
|
||||
double step(double curVal, double t) const override;
|
||||
|
||||
private:
|
||||
std::function<double(double, double)> de;
|
||||
|
||||
double k1, k2, k3, k4;
|
||||
//double k1, k2, k3, k4;
|
||||
|
||||
double dt;
|
||||
|
||||
};
|
||||
|
||||
|
6
sim/StateData.cpp
Normal file
6
sim/StateData.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "StateData.h"
|
||||
|
||||
StateData::StateData()
|
||||
{
|
||||
|
||||
}
|
29
sim/StateData.h
Normal file
29
sim/StateData.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef STATEDATA_H
|
||||
#define STATEDATA_H
|
||||
|
||||
#include "utils/math/Vector3.h"
|
||||
|
||||
/**
|
||||
* @brief The StateData class holds physical state data. Things such as position, velocity,
|
||||
* and acceleration of the center of mass, as well as orientation and orientation
|
||||
* change rates.
|
||||
*/
|
||||
class StateData
|
||||
{
|
||||
public:
|
||||
StateData();
|
||||
|
||||
private:
|
||||
math::Vector3 position;
|
||||
math::Vector3 velocity;
|
||||
math::Vector3 acceleration;
|
||||
|
||||
math::Vector3 orientation; // roll, pitch, yaw
|
||||
math::Vector3 orientationVelocity; // roll-rate, pitch-rate, yaw-rate
|
||||
// Necessary?
|
||||
//math::Vector3 orientationAccel;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // STATEDATA_H
|
@ -24,6 +24,7 @@ public:
|
||||
};
|
||||
|
||||
static Logger* getInstance();
|
||||
~Logger();
|
||||
|
||||
Logger(Logger const&) = delete;
|
||||
Logger(Logger&&) = delete;
|
||||
@ -54,7 +55,6 @@ private:
|
||||
static Logger* instance;
|
||||
std::mutex mtx;
|
||||
Logger();
|
||||
~Logger();
|
||||
};
|
||||
|
||||
} // namespace utils
|
||||
|
6
utils/ThreadPool.cpp
Normal file
6
utils/ThreadPool.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "ThreadPool.h"
|
||||
|
||||
ThreadPool::ThreadPool()
|
||||
{
|
||||
|
||||
}
|
17
utils/ThreadPool.h
Normal file
17
utils/ThreadPool.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef THREADPOOL_H
|
||||
#define THREADPOOL_H
|
||||
|
||||
#include <atomic>
|
||||
|
||||
/**
|
||||
* @brief A basic ThreadPool class
|
||||
*/
|
||||
class ThreadPool
|
||||
{
|
||||
public:
|
||||
ThreadPool();
|
||||
private:
|
||||
std::atomic_bool done;
|
||||
};
|
||||
|
||||
#endif // THREADPOOL_H
|
@ -29,7 +29,7 @@ public:
|
||||
double getX3() { return x3; }
|
||||
|
||||
|
||||
private:
|
||||
//private:
|
||||
double x1;
|
||||
double x2;
|
||||
double x3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user