surface_renderTopo.cpp 7.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#include "surface_renderTopo.h"

#include "mapHandler.h"

namespace CGoGN
{

namespace SCHNApps
{

bool Surface_RenderTopo_Plugin::enable()
{
13
	//	magic line that init static variables of GenericMap in the plugins
14
	GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
15

16
17
18
19
20
21
22
23
	m_dockTab = new Surface_RenderTopo_DockTab(m_schnapps, this);
	m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_RenderTopo");

	connect(m_schnapps, SIGNAL(selectedViewChanged(View*, View*)), this, SLOT(selectedViewChanged(View*, View*)));
	connect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)));
	connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
	connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));

24
25
26
	m_shaderTopo1 = new CGoGN::Utils::ShaderSimpleColor();
	registerShader(m_shaderTopo1);

27
	foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
28
	{
29
		mapAdded(map);
30
	}
31
32
33
34
35
36
37
38

	m_dockTab->updateMapParameters();

	return true;
}

void Surface_RenderTopo_Plugin::disable()
{
39
40
41
42
43
	disconnect(m_schnapps, SIGNAL(selectedViewChanged(View*, View*)), this, SLOT(selectedViewChanged(View*, View*)));
	disconnect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)));
	disconnect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
	disconnect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));

44
45
46
47
48
49
	foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
		mapRemoved(map);
}

void Surface_RenderTopo_Plugin::drawMap(View* view, MapHandlerGen* map)
{
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
	ViewMapParam& p = h_viewParameterSet[view][map];

	map->getTopoRender()->setInitialDartsColor(p.dartsColor.redF(),p.dartsColor.greenF(),p.dartsColor.blueF());
	map->getTopoRender()->setColorPhi1(Geom::Vec4f(p.phi1Color.redF(),p.phi1Color.greenF(),p.phi1Color.blueF(),0.0f));
	map->getTopoRender()->setColorPhi2(Geom::Vec4f(p.phi2Color.redF(),p.phi2Color.greenF(),p.phi2Color.blueF(),0.0f));

	MapParam& pm = h_parameterSet[map];

	if (pm.needUpdate)
	{
		map->getTopoRender()->setExplodeEdge(pm.edgesScaleFactor);
		map->getTopoRender()->setExplodeFace(pm.facesScaleFactor);
		QString pos = m_dockTab->combo_positionAttribute->currentText();
		map->updateTopoRender(pos);
		pm.needUpdate = false;
	}

	int code=0;
	if(p.drawDarts)
		code |= 1;
	if(p.drawPhi1)
		code |= 2;
	if(p.drawPhi2)
		code |= 4;
	map->drawTopoRender(code);
75
76
77
78
79
80
81
82
83
84
85
86
87
88
}





void Surface_RenderTopo_Plugin::selectedViewChanged(View *prev, View *cur)
{
	m_dockTab->updateMapParameters();
}

void Surface_RenderTopo_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandlerGen *cur)
{
	m_dockTab->updateMapParameters();
89
90
91
92
93

	if (cur==NULL)
		m_dockTab->setDisabled(true);
	else
		m_dockTab->setDisabled(false);
94
95
96
97
98
}

void Surface_RenderTopo_Plugin::mapAdded(MapHandlerGen* map)
{
	connect(map, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(attributeAdded(unsigned int, const QString&)));
99
	map->createTopoRender(m_shaderTopo1);
100
101
102
103
104
105
106
107
108
109
110
}

void Surface_RenderTopo_Plugin::mapRemoved(MapHandlerGen* map)
{
	disconnect(map, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(attributeAdded(unsigned int, const QString&)));
}





111
void Surface_RenderTopo_Plugin::attributeAdded(unsigned int orbit, const QString& name)
112
113
{
	MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
114
	if(orbit == VERTEX && map == m_schnapps->getSelectedMap())
115
	{
116
		m_dockTab->addVertexAttribute(name);
117
	}
118
119
120
121
122
123
}





124
//void Surface_RenderTopo_Plugin::changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP2::VEC3, PFP2::MAP> attribute, bool fromUI)
125
//{
126
127
////	map->updateTopoRender

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
//	ParameterSet* params = h_viewParams[view];
//	PerMapParameterSet* perMap = params->perMap[map->getName()];
//	perMap->positionAttribute = attribute;
//	perMap->updateRender();

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changeDrawDarts(View* view, MapHandlerGen* map, bool b, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	params->perMap[map->getName()]->drawDarts = b;

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changeDartsColor(View* view, MapHandlerGen* map, QColor c, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	PerMapParameterSet* perMap = params->perMap[map->getName()];
//	perMap->dartsColor = c;
//	perMap->m_renderTopo->setInitialDartsColor(c.redF(), c.greenF(), c.blueF());
//	perMap->m_renderTopo->setAllDartsColor(c.redF(), c.greenF(), c.blueF());

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changeDrawPhi1(View* view, MapHandlerGen* map, bool b, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	params->perMap[map->getName()]->drawPhi1 = b;

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changePhi1Color(View* view, MapHandlerGen* map, QColor c, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	params->perMap[map->getName()]->phi1Color = c;

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changeDrawPhi2(View* view, MapHandlerGen* map, bool b, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	params->perMap[map->getName()]->drawPhi2 = b;

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changePhi2Color(View* view, MapHandlerGen* map, QColor c, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	params->perMap[map->getName()]->phi2Color = c;

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changeEdgesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	PerMapParameterSet* perMap = params->perMap[map->getName()];
//	perMap->edgesScaleFactor = i / 100.0;
//	perMap->updateRender();

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

//void Surface_RenderTopo_Plugin::changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
//{
//	ParameterSet* params = h_viewParams[view];
//	PerMapParameterSet* perMap = params->perMap[map->getName()];
//	perMap->facesScaleFactor = i / 100.0;
//	perMap->updateRender();

//	if(view->isCurrentView())
//	{
//		if(!fromUI)
//			m_dockTab->refreshUI(params);
//		view->updateGL();
//	}
//}

Q_EXPORT_PLUGIN2(Surface_RenderTopo_Plugin, Surface_RenderTopo_Plugin)

} // namespace SCHNApps

} // namespace CGoGN