computeNormalDialog.cpp 1.8 KB
Newer Older
1
#include "computeNormalDialog.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
2 3 4 5 6 7 8 9 10 11 12

#include "differentialProperties.h"
#include "window.h"
#include "mapHandler.h"

namespace CGoGN
{

namespace SCHNApps
{

13
ComputeNormalDialog::ComputeNormalDialog(Window* w) : m_window(w)
Pierre Kraemer's avatar
Pierre Kraemer committed
14 15 16 17 18
{
	setupUi(this);
	connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
}

19
void ComputeNormalDialog::init()
Pierre Kraemer's avatar
Pierre Kraemer committed
20 21 22
{
	mapList->clear();
	combo_positionAttribute->clear();
23
	combo_normalAttribute->clear();
24
	normalAttributeName->setText("normal");
Pierre Kraemer's avatar
Pierre Kraemer committed
25 26 27 28 29
	const QList<MapHandlerGen*>& maps = m_window->getMapsList();
	foreach(MapHandlerGen* map, maps)
		mapList->addItem(map->getName());
}

30
void ComputeNormalDialog::cb_selectedMapChanged()
Pierre Kraemer's avatar
Pierre Kraemer committed
31 32 33 34 35
{
	QList<QListWidgetItem*> currentItems = mapList->selectedItems();
	if(!currentItems.empty())
	{
		combo_positionAttribute->clear();
36
		combo_normalAttribute->clear();
Pierre Kraemer's avatar
Pierre Kraemer committed
37 38 39 40 41 42 43 44 45
		const QString& mapname = currentItems[0]->text();
		MapHandlerGen* mh = m_window->getMap(mapname);
		GenericMap* map = mh->getGenericMap();
		AttributeContainer& cont = map->getAttributeContainer<VERTEX>();

		std::vector<std::string> names;
		std::vector<std::string> types;
		cont.getAttributesNames(names);
		cont.getAttributesTypes(types);
Pierre Kraemer's avatar
Pierre Kraemer committed
46
		std::string vec3TypeName = nameOfType(PFP2::VEC3());
47
		unsigned int j = 0;
Pierre Kraemer's avatar
Pierre Kraemer committed
48 49 50
		for(unsigned int i = 0; i < names.size(); ++i)
		{
			if(types[i] == vec3TypeName)
51
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
52
				combo_positionAttribute->addItem(QString::fromStdString(names[i]));
53
				if(names[i] == "position") // try to select a position attribute named "position"
54
					combo_positionAttribute->setCurrentIndex(j);
55 56 57 58 59

				combo_normalAttribute->addItem(QString::fromStdString(names[i]));
				if(names[i] == "normal") // try to select a normal attribute named "normal"
					combo_normalAttribute->setCurrentIndex(j);

60 61
				++j;
			}
Pierre Kraemer's avatar
Pierre Kraemer committed
62 63 64 65 66 67 68
		}
	}
}

} // namespace SCHNApps

} // namespace CGoGN