Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

renderDockTab.cpp 4.89 KB
Newer Older
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
#include "renderDockTab.h"

#include "render.h"
#include "window.h"
#include "mapHandler.h"

namespace CGoGN
{

namespace SCHNApps
{

RenderDockTab::RenderDockTab(Window* w, RenderPlugin* p) :
	m_window(w),
	m_plugin(p),
	b_refreshingUI(false)
{
	setupUi(this);

	connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
	connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int)));
	connect(combo_normalVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(normalVBOChanged(int)));
	connect(check_renderVertices, SIGNAL(toggled(bool)), this, SLOT(renderVerticesChanged(bool)));
	connect(slider_verticesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(verticesScaleFactorChanged(int)));
	connect(check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(renderEdgesChanged(bool)));
	connect(check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool)));
	connect(group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(faceStyleChanged(QAbstractButton*)));
}

void RenderDockTab::refreshUI(ParameterSet* params)
{
	m_currentParams = params;

	b_refreshingUI = true;

	mapList->clear();
	combo_positionVBO->clear();
	combo_normalVBO->clear();

	MapHandlerGen* map = params->selectedMap;

42
	QHash<QString, PerMapParameterSet*>::const_iterator i = params->perMap.constBegin();
43
44
45
46
47
48
49
50
	while (i != params->perMap.constEnd())
	{
		mapList->addItem(i.key());
		if(map != NULL && i.key() == map->getName())
		{
			QList<QListWidgetItem*> item = mapList->findItems(map->getName(), Qt::MatchExactly);
			item[0]->setSelected(true);

51
			PerMapParameterSet* p = params->perMap[map->getName()];
52
53
54
55
56
57
58
59

			QList<Utils::VBO*> vbos = map->getVBOList();
			unsigned int j = 0;
			for(int i = 0; i < vbos.count(); ++i)
			{
				if(vbos[i]->dataSize() == 3)
				{
					combo_positionVBO->addItem(QString::fromStdString(vbos[i]->name()));
60
					if(vbos[i] == p->positionVBO)
61
62
63
						combo_positionVBO->setCurrentIndex(j);

					combo_normalVBO->addItem(QString::fromStdString(vbos[i]->name()));
64
					if(vbos[i] == p->normalVBO)
65
66
67
68
69
70
						combo_normalVBO->setCurrentIndex(j);

					++j;
				}
			}

71
72
73
74
75
76
			check_renderVertices->setChecked(p->renderVertices);
			slider_verticesScaleFactor->setSliderPosition(p->verticesScaleFactor * 50.0);
			check_renderEdges->setChecked(p->renderEdges);
			check_renderFaces->setChecked(p->renderFaces);
			radio_flatShading->setChecked(p->faceStyle == FLAT);
			radio_phongShading->setChecked(p->faceStyle == PHONG);
77
78
79
80
81
82
83
84
85
86
87
88
89
		}
		++i;
	}

	b_refreshingUI = false;
}

void RenderDockTab::selectedMapChanged()
{
	if(!b_refreshingUI)
	{
		QList<QListWidgetItem*> currentItems = mapList->selectedItems();
		if(!currentItems.empty())
90
			m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
91
92
93
94
95
96
97
98
99
	}
}

void RenderDockTab::positionVBOChanged(int index)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
100
101
		if(map)
			m_plugin->changePositionVBO(view, map, map->getVBO(combo_positionVBO->currentText()), true);
102
103
104
105
106
107
108
109
110
	}
}

void RenderDockTab::normalVBOChanged(int index)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
111
112
		if(map)
			m_plugin->changeNormalVBO(view, map, map->getVBO(combo_normalVBO->currentText()), true);
113
114
115
116
117
118
119
120
121
	}
}

void RenderDockTab::renderVerticesChanged(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
122
123
		if(map)
			m_plugin->changeRenderVertices(view, map, b, true);
124
125
126
127
128
129
130
131
132
	}
}

void RenderDockTab::verticesScaleFactorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
133
134
		if(map)
			m_plugin->changeVerticesScaleFactor(view, map, i / 50.0, true);
135
136
137
138
139
140
141
142
143
	}
}

void RenderDockTab::renderEdgesChanged(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
144
145
		if(map)
			m_plugin->changeRenderEdges(view, map, b, true);
146
147
148
149
150
151
152
153
154
	}
}

void RenderDockTab::renderFacesChanged(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
155
156
		if(map)
			m_plugin->changeRenderFaces(view, map, b, true);
157
158
159
160
161
162
163
164
165
	}
}

void RenderDockTab::faceStyleChanged(QAbstractButton* b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
166
167
168
169
170
171
172
		if(map)
		{
			if(radio_flatShading->isChecked())
				m_plugin->changeFacesStyle(view, map, FLAT, true);
			else if(radio_phongShading->isChecked())
				m_plugin->changeFacesStyle(view, map, PHONG, true);
		}
173
174
175
	}
}

176
177
178
179
180
181
182
183
184
185
void RenderDockTab::addVBOToList(Utils::VBO* vbo)
{
	if(vbo->dataSize() == 3)
	{
		QString name = QString::fromStdString(vbo->name());
		combo_positionVBO->addItem(name);
		combo_normalVBO->addItem(name);
	}
}

186
187
188
} // namespace SCHNApps

} // namespace CGoGN