-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.h
123 lines (94 loc) · 3.43 KB
/
MainWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Copyright © 2021 TokiNoBug
This file is part of UniSimulator.
UniSimulator is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
UniSimulator is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with UniSimulator. If not, see <https://www.gnu.org/licenses/>.
Contact with me:
github:https://github.com/ToKiNoBug
bilibili:https://space.bilibili.com/351429231
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtCharts>
#include <stack>
#include <QKeyEvent>
#include "Simulator.h"
#include "tests.h"
#define SIMU_INTERPOLT
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
extern const QColor DefaultColors[];
const uint32_t pathChartCount=DIM_COUNT*(DIM_COUNT-1)/2;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void runSimulaton(Simulator::Algorithm);
void runSimulaton(Simulator::Algorithm,
const double,
const TimeSpan &,
const Statue &,
const BodyVector &,
bool * noCollide=nullptr);
void drawConservativeCharts();
void drawPathCharts();
private slots:
void on_timeSlider_valueChanged(int value);
void on_timeSlider_sliderPressed();
void on_timeSlider_sliderReleased();
void on_cbShowCurves_stateChanged(int arg1);
void on_cbShowDots_stateChanged(int arg1);
void onUserInput();
void on_BtnRunSimulation_clicked();
void on_BtnClear_clicked();
void on_BtnRandom_clicked();
void saveParameters();
void loadParameters();
void savePath();
void loadPath();
private:
Ui::MainWindow *ui;
Simulator Simu;
QChartView * MotionView;
QChartView * EnergyView;
std::array<QChartView * ,pathChartCount> pathViews;
std::array<std::pair<uint16_t,uint16_t>,pathChartCount> dimPairs;
std::array<QLineEdit*,BODY_COUNT> massWidgets;
std::array<std::array<QLineEdit*,BODY_COUNT>,DIM_COUNT> positionWidgets;
std::array<std::array<QLineEdit*,BODY_COUNT>,DIM_COUNT> velocityWidgets;
bool isRunning;
private:
void buildMotionEnergyUI();
void buildPathUI();
void buildParameterUI();
void setParamaters(const BodyVector & mass,
const Statue & y0,
TimeSpan ts,
double step,
Simulator::Algorithm);
bool grabParameters(BodyVector & mass,
Statue & y0,
TimeSpan & ts,
double & step,
Simulator::Algorithm&);
void keyPressEvent(QKeyEvent *event);
public:
static QChart * createEmptyChart();
static void addSeriesToChart(QChart *,QList<QVector<QPointF>>&,
int * =nullptr);
static void createScatters(QChart*);
static QPointF moveScatterIndex(QChart*,int index);
};
#endif // MAINWINDOW_H