-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawwidget.cpp
53 lines (41 loc) · 1.23 KB
/
drawwidget.cpp
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
#include "drawwidget.h"
#include <QPainter>
#include <QImage>
#include <chrono>
#include <ctime>
#include <omp.h>
DrawWidget::DrawWidget(QWidget *parent) : QWidget(parent)
{
int w = width(), h = height();
mainScene = new Scene();
mainWorld = World(objects);
changeOffset(0, 0, -3, 0, 0, 0);
}
void DrawWidget::recalc(double t, QTextBrowser& TB, double dx, double dy, double dz, double dalpha, double dbeta, double dgamma){
mainWorld.interact();
mainWorld.setDescription(TB, t);
mainWorld.pushToScene(objects);
changeOffset(dx, dy, dz, dalpha, dbeta, dgamma);
int w = width(), h = height();
mainScene->setSizes(w, h);
}
void DrawWidget::restart(){
mainScene = new Scene();
mainWorld = World(objects);
changeOffset(0, 0,-3, 0, 0, 0);
}
void DrawWidget::paintEvent(QPaintEvent *event){
QPainter p(this);
int w = width(), h = height();
mainScene->setSizes(w, h);
mainScene->setObjects(objects);
QImage img(w, h, QImage::Format_RGB32);
#pragma omp parallel for
for(int x = 0; x < w; x++){
#pragma omp parallel for
for(int y = 0; y < h; y++){
img.setPixelColor(x, y, mainScene->getPixel(x,y).toQColor());
}
}
p.drawImage(0,0,img);
}