renderTopoSurfaceDockTab.cpp 5.67 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		}
		++i;
	}

	b_refreshingUI = false;
}

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

void RenderTopoSurfaceDockTab::positionAttributeChanged(int index)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
		m_plugin->changePositionAttribute(view, map, map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText()), true);
	}
}

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

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

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

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

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

Pierre Kraemer's avatar
Pierre Kraemer committed
155
156
157
158
159
160
161
162
163
164
void RenderTopoSurfaceDockTab::phi2ColorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
		m_plugin->changePhi2Color(view, map, combo_phi2Color->color(), true);
	}
}

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

void RenderTopoSurfaceDockTab::edgesScaleFactorChanged(int i)
{
	if(!b_refreshingUI)
	{
		View* view = m_window->getCurrentView();
		MapHandlerGen* map = m_currentParams->selectedMap;
		m_plugin->changeFacesScaleFactor(view, map, i, true);
	}
}

185
186
187
188
189
190
191
192
193
194
195
196
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
197
198
199
} // namespace SCHNApps

} // namespace CGoGN