-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
75 lines (61 loc) · 2.1 KB
/
Copy pathmainwindow.cpp
File metadata and controls
75 lines (61 loc) · 2.1 KB
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
cronometro=new QTimer(this); //crea el timer
scene=new QGraphicsScene(this); // crea la escena
ui->pushButton->show();
scene->setSceneRect(-200,-200,400,400);
ui->graphicsView->setBackgroundBrush(QBrush(QImage(":/fondo")));
ui->graphicsView->setScene(scene);
ui->pushButton->show();
ui->graphicsView->resize(scene->width()+500,scene->height()+250); //Modificar la dimensión del scene
this->resize(ui->graphicsView->width()+2000,ui->graphicsView->height()+100);
//Movimiento en el sistema 2 (4 planetas)
Cuerpos[0]=new Planetas(0,0,0,0,50000,60); //Pinix,PiniY,VeliniX,VeliniY,Masa,radio
Cuerpos[1]=new Planetas(-5000,0,0,-2,70,30);
Cuerpos[2]=new Planetas(5000,0,0,2,70,30);
Cuerpos[3]=new Planetas(0,5000,-2,0,70,30);
/*
//Movimiento en el sistema 1 (3 planetas)
Cuerpos[0]=new Planetas(0.-7000,2,0,70,15);
Cuerpos[1]=new Planetas(0,0,0,0,70000,30);
Cuerpos[2]=new Planetas(4000,5000,-1.6,1.2,25,10);
*/
scene->addItem(Cuerpos[0]);
scene->addItem(Cuerpos[1]);
scene->addItem(Cuerpos[2]);
scene->addItem(Cuerpos[3]);
connect(cronometro,SIGNAL(timeout()),this,SLOT(update()));
//cronometro->start(20);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::update()
{
for(int j=0; j<4; j++)
{
for(int k=0; k<4; k++)
{
if(j != k){
Cuerpos[j]->CalcularAcelx(Cuerpos[k]);
Cuerpos[j]->CalcularAcely(Cuerpos[k]);
Cuerpos[j]->getPosx();
Cuerpos[j]->getPosy();
Cuerpos[j]->CalcularVelx();
Cuerpos[j]->CalcularVely();
Cuerpos[j]->mover();
}
}
Cuerpos[j]->ModValor();
}
}
void MainWindow::on_pushButton_clicked()
{
cronometro->start(0.5);
}