1 | /*
|
---|
2 | * Q3DCameraWidget.h
|
---|
3 | *
|
---|
4 | * Created on: Aug 26, 2011
|
---|
5 | * Author: lyard
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef Q3DCAMERAWIDGET_H_
|
---|
9 | #define Q3DCAMERAWIDGET_H_
|
---|
10 |
|
---|
11 | #include "BasicGlCamera.h"
|
---|
12 | #include <QtCore/QTimer>
|
---|
13 | #include <iostream>
|
---|
14 |
|
---|
15 |
|
---|
16 | using namespace std;
|
---|
17 |
|
---|
18 | struct cameraLocation
|
---|
19 | {
|
---|
20 | float rotX;
|
---|
21 | float rotY;
|
---|
22 | float position[3];
|
---|
23 |
|
---|
24 | cameraLocation() : rotX(0), rotY(0), position({0,0,0})
|
---|
25 | {}
|
---|
26 | cameraLocation(float rx, float ry, float x, float y, float z): rotX(rx), rotY(ry), position({x,y,z})
|
---|
27 | {}
|
---|
28 | };
|
---|
29 |
|
---|
30 | struct float3
|
---|
31 | {
|
---|
32 | float data[4];
|
---|
33 | float3()
|
---|
34 | {
|
---|
35 | data[0] = data[1] = data[2] = 0;
|
---|
36 | data[3] = 1.f;
|
---|
37 | }
|
---|
38 | float& operator [] (int index)
|
---|
39 | {
|
---|
40 | return data[index];
|
---|
41 | }
|
---|
42 | };
|
---|
43 | class Q3DCameraWidget : public BasicGlCamera
|
---|
44 | {
|
---|
45 | Q_OBJECT
|
---|
46 |
|
---|
47 | public:
|
---|
48 | Q3DCameraWidget(QWidget* pparent = 0);
|
---|
49 | ~Q3DCameraWidget();
|
---|
50 | void updateData(float* data);
|
---|
51 |
|
---|
52 | public Q_SLOTS:
|
---|
53 | void timedUpdate();
|
---|
54 |
|
---|
55 | Q_SIGNALS:
|
---|
56 | void dataHasChanged();
|
---|
57 |
|
---|
58 | protected:
|
---|
59 | void paintGL();
|
---|
60 | void initializeGL();
|
---|
61 | void resizeGL(int cWidth, int cHeight);
|
---|
62 | void drawCamera(bool alsoWire);
|
---|
63 | void drawCameraBody();
|
---|
64 | float rotX, rotY;
|
---|
65 | void mousePressEvent(QMouseEvent* event);
|
---|
66 | void mouseDoubleClickEvent(QMouseEvent *cEvent);
|
---|
67 | int PixelAtPosition(const QPoint &pos);
|
---|
68 | void drawSpheres();
|
---|
69 | void UpdateText();
|
---|
70 |
|
---|
71 | private:
|
---|
72 | QTimer timer;
|
---|
73 | cameraLocation currentLoc;
|
---|
74 | int steps;
|
---|
75 | int totalSteps;
|
---|
76 | int currentView;
|
---|
77 | int nextView;
|
---|
78 | vector<cameraLocation> cameraViews;
|
---|
79 | float fscTemps[60];
|
---|
80 | bool isPicking;
|
---|
81 | vector<int> highlightPatches;
|
---|
82 | vector<vector<int> > tempPatches;
|
---|
83 | bool initFinished;
|
---|
84 | vector<float3> spheresColors;
|
---|
85 | vector<float> spheresRadius;
|
---|
86 | vector<float3> spheresLocation;
|
---|
87 | };
|
---|
88 |
|
---|
89 | #endif /* Q3DCAMERAWIDGET_H_ */
|
---|