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

renderTopoSurfaceDockTab.cpp 5.76 KB
Newer Older
untereiner's avatar
untereiner committed
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "renderTopoSurfaceDockTab.h"

#include "renderTopoSurface.h"
#include "window.h"
#include "mapHandler.h"

namespace CGoGN
{

namespace SCHNApps
{

RenderTopoSurfaceDockTab::RenderTopoSurfaceDockTab(Window* w, RenderTopoSurfacePlugin* p) :
14
15
16
	m_window(w),
	m_plugin(p),
	b_refreshingUI(false)
untereiner's avatar
untereiner committed
17
18
19
20
21
{
	setupUi(this);

	connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
	connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
22
	connect(check_drawDarts, SIGNAL(toggled(bool)), this, SLOT(drawDartsChanged(bool)));
Pierre Kraemer's avatar
Pierre Kraemer committed
23
	connect(combo_dartsColor, SIGNAL(currentIndexChanged(int)), this, SLOT(dartsColorChanged(int)));
24
	connect(check_drawPhi1, SIGNAL(toggled(bool)), this, SLOT(drawPhi1Changed(bool)));
Pierre Kraemer's avatar
Pierre Kraemer committed
25
	connect(combo_phi1Color, SIGNAL(currentIndexChanged(int)), this, SLOT(phi1ColorChanged(int)));
26
	connect(check_drawPhi2, SIGNAL(toggled(bool)), this, SLOT(drawPhi2Changed(bool)));
Pierre Kraemer's avatar
Pierre Kraemer committed
27
	connect(combo_phi2Color, SIGNAL(currentIndexChanged(int)), this, SLOT(phi2ColorChanged(int)));
untereiner's avatar
untereiner committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
	connect(slider_edgesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(edgesScaleFactorChanged(int)));
	connect(slider_facesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(facesScaleFactorChanged(int)));
}

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

	b_refreshingUI = true;

	mapList->clear();
	combo_positionAttribute->clear();

	MapHandlerGen* mh = params->selectedMap;

	QHash<QString, PerMapParameterSet*>::const_iterator i = params->perMap.constBegin();
	while (i != params->perMap.constEnd())
	{
		mapList->addItem(i.key());
		if(mh != NULL && i.key() == mh->getName())
		{
			QList<QListWidgetItem*> item = mapList->findItems(mh->getName(), Qt::MatchExactly);
			item[0]->setSelected(true);

			PerMapParameterSet* p = params->perMap[mh->getName()];

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

			unsigned int j = 0;
			const AttributeHash& attribs = mh->getAttributesList(VERTEX);
			for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
			{
				if(i.value() == vec3TypeName)
				{
					combo_positionAttribute->addItem(i.key());
					if(i.key() == QString::fromStdString(p->positionAttribute.name()))
						combo_positionAttribute->setCurrentIndex(j);

					++j;
				}
			}

70
			check_drawDarts->setChecked(p->drawDarts);
Pierre Kraemer's avatar
Pierre Kraemer committed
71
			combo_dartsColor->setColor(p->dartsColor);
72
			check_drawPhi1->setChecked(p->drawPhi1);
Pierre Kraemer's avatar
Pierre Kraemer committed
73
			combo_phi1Color->setColor(p->phi1Color);
74
			check_drawPhi2->setChecked(p->drawPhi2);
Pierre Kraemer's avatar
Pierre Kraemer committed
75
			combo_phi2Color->setColor(p->phi2Color);
76
77
			slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 100.0);
			slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 100.0);
untereiner's avatar
untereiner committed
78
79
80
81
82
83
84
85
86
87
88
89
90
		}
		++i;
	}

	b_refreshingUI = false;
}

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

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

106
107
108
109
110
111
void RenderTopoSurfaceDockTab::drawDartsChanged(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
112
113
		if(map)
			m_plugin->changeDrawDarts(view, map, b, true);
114
115
116
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
117
118
119
120
121
122
void RenderTopoSurfaceDockTab::dartsColorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
123
124
		if(map)
			m_plugin->changeDartsColor(view, map, combo_dartsColor->color(), true);
Pierre Kraemer's avatar
Pierre Kraemer committed
125
126
127
	}
}

128
129
130
131
132
133
void RenderTopoSurfaceDockTab::drawPhi1Changed(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
134
135
		if(map)
			m_plugin->changeDrawPhi1(view, map, b, true);
136
137
138
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
139
140
141
142
143
144
void RenderTopoSurfaceDockTab::phi1ColorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
145
146
		if(map)
			m_plugin->changePhi1Color(view, map, combo_phi1Color->color(), true);
Pierre Kraemer's avatar
Pierre Kraemer committed
147
148
149
	}
}

150
151
152
153
154
155
void RenderTopoSurfaceDockTab::drawPhi2Changed(bool b)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
156
157
		if(map)
			m_plugin->changeDrawPhi2(view, map, b, true);
158
159
160
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
161
162
163
164
165
166
void RenderTopoSurfaceDockTab::phi2ColorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
167
168
		if(map)
			m_plugin->changePhi2Color(view, map, combo_phi2Color->color(), true);
Pierre Kraemer's avatar
Pierre Kraemer committed
169
170
171
	}
}

untereiner's avatar
untereiner committed
172
173
174
175
176
177
void RenderTopoSurfaceDockTab::facesScaleFactorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
178
179
		if(map)
			m_plugin->changeEdgesScaleFactor(view, map, i, true);
untereiner's avatar
untereiner committed
180
181
182
183
184
185
186
187
188
	}
}

void RenderTopoSurfaceDockTab::edgesScaleFactorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
189
190
		if(map)
			m_plugin->changeFacesScaleFactor(view, map, i, true);
untereiner's avatar
untereiner committed
191
192
193
	}
}

194
195
196
197
198
199
200
201
202
203
204
205
void RenderTopoSurfaceDockTab::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);
	}
}

untereiner's avatar
untereiner committed
206
207
208
} // namespace SCHNApps

} // namespace CGoGN