camera.cpp 1.33 KB
Newer Older
1
2
#include "camera.h"

3
4
5
6
unsigned int Camera::cameraCount = 0;

Camera::Camera(const QString& name, Window* window) :
	m_name(name),
Pierre Kraemer's avatar
Pierre Kraemer committed
7
	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
	++cameraCount;
17
	this->setZClippingCoefficient(100);
18
19

//	connect(m_window, SIGNAL(viewRemoved(View*)), this, SLOT(cb_viewRemoved(View*)));
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
}

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
41
void Camera::linkView(View* view)
42
{
Pierre Kraemer's avatar
Pierre Kraemer committed
43
44
	if(view && !l_views.contains(view))
		l_views.push_back(view);
45
46
}

Pierre Kraemer's avatar
Pierre Kraemer committed
47
void Camera::unlinkView(View* view)
48
{
Pierre Kraemer's avatar
Pierre Kraemer committed
49
	l_views.removeOne(view);
50
51
}

Pierre Kraemer's avatar
Pierre Kraemer committed
52
bool Camera::isLinkedWithView(View* view)
53
{
Pierre Kraemer's avatar
Pierre Kraemer committed
54
55
56
57
58
59
	return l_views.contains(view);
}

void Camera::fitParamWith(View* view)
{
	setScreenWidthAndHeight(view->width(), view->height());
60
61
62
63
64
}

void Camera::saveSnapshot(QString snapPathName)
{
	foreach(View* view, l_views)
Pierre Kraemer's avatar
Pierre Kraemer committed
65
		view->saveSnapshot(snapPathName + view->getName() + '_' + QString::number(m_snapCount) + ".jpg", true);
66
67
	++m_snapCount;
}
68
69
70
71
72

void Camera::cb_viewRemoved(View* view)
{
	unlinkView(view);
}