Coupure prévue mercredi 4 Août pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

camera.cpp 1.79 KB
Newer Older
1
2
3
#include "camera.h"
#include "scene.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
4
5
6
7
static unsigned int Camera::cameraCount = 0;

Camera::Camera(Window* window, View* v) :
	m_window(window),
8
9
10
11
12
13
14
15
	m_draw(false),
	m_drawFarPlane(false),
	m_drawScale(1.0),
	m_drawPath(false),
	m_drawPathAxis(false),
	m_drawPathScale(1.0),
	m_snapCount(0)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
16
17
	m_name = "camera_" + cameraCount;
	++cameraCount;
18
19
20
21
22
	if(v)
		l_views.push_back(v);
	this->setZClippingCoefficient(100);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
23
Camera::Camera(Window* window, View* v, const qglviewer::Camera& c) :
24
	qglviewer::Camera(c),
Pierre Kraemer's avatar
Pierre Kraemer committed
25
	m_window(window),
26
27
28
29
30
31
32
33
	m_draw(false),
	m_drawFarPlane(false),
	m_drawScale(1.0),
	m_drawPath(false),
	m_drawPathAxis(false),
	m_drawPathScale(1.0),
	m_snapCount(0)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
34
35
	m_name = "camera_" + cameraCount;
	++cameraCount;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	if(v)
		l_views.push_back(v);
	this->setZClippingCoefficient(100);
}

Camera::~Camera()
{}

void Camera::draw()
{
	if(m_draw)
	{
		qglviewer::Camera::draw(m_drawFarPlane, m_drawScale);
		if(m_drawPath)
		{
			int mask = 1;
			if(m_drawPathAxis)
				mask = mask | 4;
			if(this->keyFrameInterpolator(0))
				this->keyFrameInterpolator(0)->drawPath(mask, 6, m_drawPathScale);
		}
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
60
void Camera::linkView(View* view)
61
{
Pierre Kraemer's avatar
Pierre Kraemer committed
62
63
	if(view && !l_views.contains(view))
		l_views.push_back(view);
64
65
}

Pierre Kraemer's avatar
Pierre Kraemer committed
66
void Camera::unlinkView(View* view)
67
{
Pierre Kraemer's avatar
Pierre Kraemer committed
68
	l_views.removeOne(view);
69
70
}

Pierre Kraemer's avatar
Pierre Kraemer committed
71
bool Camera::isLinkedWithView(View* view)
72
{
Pierre Kraemer's avatar
Pierre Kraemer committed
73
74
75
76
77
78
	return l_views.contains(view);
}

void Camera::fitParamWith(View* view)
{
	setScreenWidthAndHeight(view->width(), view->height());
79
80
81
82
83
}

void Camera::saveSnapshot(QString snapPathName)
{
	foreach(View* view, l_views)
Pierre Kraemer's avatar
Pierre Kraemer committed
84
		view->saveSnapshot(snapPathName + view->getName() + '_' + QString::number(m_snapCount) + ".jpg", true);
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	++m_snapCount;
}

void Camera::updateGL()
{
	foreach(View* view, l_views)
		view->updateGL();
}

void Camera::viewShowButton(bool b)
{
	foreach(View* view, l_views)
		view->setShowButtons(b);
}