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

renderExplodDockTab.cpp 4.84 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "renderExplodDockTab.h"

#include "renderExplod.h"
#include "window.h"
#include "mapHandler.h"

namespace CGoGN
{

namespace SCHNApps
{

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

	connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
untereiner's avatar
untereiner committed
21
22
23
24

	connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
	connect(combo_colorAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(colorAttributeChanged(int)));

25
26
	connect(check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(renderEdgesChanged(bool)));
	connect(check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(renderFacesChanged(bool)));
untereiner's avatar
untereiner committed
27

28
29
30
31
32
33
34
35
36
37
38
	connect(slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(facesScaleFactorChanged(int)));
	connect(slider_volumesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(volumesScaleFactorChanged(int)));
}

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

	b_refreshingUI = true;

	mapList->clear();
untereiner's avatar
untereiner committed
39
40
	combo_positionAttribute->clear();
	combo_colorAttribute->clear();
41

untereiner's avatar
untereiner committed
42
	MapHandlerGen* mh = params->selectedMap;
43

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

untereiner's avatar
untereiner committed
53
54
55
			PerMapParameterSet* p = params->perMap[mh->getName()];

			QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
56
57

			unsigned int j = 0;
untereiner's avatar
untereiner committed
58
59
			const AttributeHash& attribs = mh->getAttributesList(VERTEX);
			for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
60
			{
untereiner's avatar
untereiner committed
61
				if(i.value() == vec3TypeName)
62
				{
untereiner's avatar
untereiner committed
63
64
65
					combo_positionAttribute->addItem(i.key());
					if(i.key() == QString::fromStdString(p->positionAttribute.name()))
						combo_positionAttribute->setCurrentIndex(j);
66

untereiner's avatar
untereiner committed
67
68
69
//					combo_colorAttribute->addItem(i.key());
//					if(i.key() == QString::fromStdString(p.colorAttribute.name()))
//						combo_colorAttribute->setCurrentIndex(j);
70
71
72
73
74

					++j;
				}
			}

untereiner's avatar
untereiner committed
75
76
77
78
			check_renderEdges->setChecked(p->renderEdges);
			check_renderFaces->setChecked(p->renderFaces);
			slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 50.0);
			slider_volumesScaleFactor->setSliderPosition(p->volumesScaleFactor * 50.0);
79
80
81
82
83
84
85
86
87
88
89
90
91
		}
		++i;
	}

	b_refreshingUI = false;
}

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

untereiner's avatar
untereiner committed
96
void RenderExplodDockTab::positionAttributeChanged(int index)
97
98
99
100
101
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
102
103
		if(map)
			m_plugin->changePositionAttribute(view, map, map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText()), true);
104
105
106
	}
}

untereiner's avatar
untereiner committed
107
void RenderExplodDockTab::colorAttributeChanged(int index)
108
109
110
111
112
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
113
114
		if(map)
			m_plugin->changeColorAttribute(view, map, map->getAttribute<PFP2::VEC3, VERTEX>(combo_colorAttribute->currentText()), true);
115
116
117
118
119
120
121
122
123
	}
}

void RenderExplodDockTab::renderEdgesChanged(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
124
125
		if(map)
			m_plugin->changeRenderEdges(view, map, b, true);
126
127
128
129
130
131
132
133
134
	}
}

void RenderExplodDockTab::renderFacesChanged(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
135
136
		if(map)
			m_plugin->changeRenderFaces(view, map, b, true);
137
138
139
140
141
142
143
144
145
	}
}

void RenderExplodDockTab::facesScaleFactorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
146
147
		if(map)
			m_plugin->changeFacesScaleFactor(view, map, i, true);
148
149
150
151
152
153
154
155
156
	}
}

void RenderExplodDockTab::volumesScaleFactorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
157
158
		if(map)
			m_plugin->changeVolumesScaleFactor(view, map, i, true);
159
160
161
	}
}

162
163
164
165
166
167
168
169
170
171
172
173
174
void RenderExplodDockTab::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{
	QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));

	const QString& typeAttr = m_currentParams->selectedMap->getAttributeTypeName(orbit, nameAttr);

	if(typeAttr == vec3TypeName)
	{
		combo_positionAttribute->addItem(nameAttr);
		combo_colorAttribute->addItem(nameAttr);
	}
}

175
176
177
} // namespace SCHNApps

} // namespace CGoGN