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

#include "surface_selection.h"
#include "mapHandler.h"

namespace CGoGN
{

namespace SCHNApps
{

Surface_Selection_DockTab::Surface_Selection_DockTab(SCHNApps* s, Surface_Selection_Plugin* p) :
	m_schnapps(s),
	m_plugin(p),
	b_updatingUI(false)
{
	setupUi(this);

	connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
20
	connect(combo_selectionMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(selectionMethodChanged(int)));
21 22 23 24 25 26 27 28 29 30 31
}





void Surface_Selection_DockTab::positionAttributeChanged(int index)
{
	if(!b_updatingUI)
	{
		MapHandlerGen* map = m_schnapps->getSelectedMap();
32 33 34 35 36 37 38 39 40 41 42 43
		if(map)
			m_plugin->h_parameterSet[map].positionAttribute = map->getAttribute<PFP2::VEC3, VERTEX>(combo_positionAttribute->currentText());
	}
}

void Surface_Selection_DockTab::selectionMethodChanged(int index)
{
	if(!b_updatingUI)
	{
		MapHandlerGen* map = m_schnapps->getSelectedMap();
		if(map)
			m_plugin->h_parameterSet[map].selectionMethod = SelectionMethod(index);
44 45 46 47 48 49 50
	}
}





51 52 53 54 55 56 57 58 59 60
void Surface_Selection_DockTab::addVertexAttribute(const QString& nameAttr)
{
	b_updatingUI = true;
	QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
	const QString& typeAttr = m_schnapps->getSelectedMap()->getAttributeTypeName(VERTEX, nameAttr);
	if(typeAttr == vec3TypeName)
		combo_positionAttribute->addItem(nameAttr);
	b_updatingUI = false;
}

61 62 63 64 65 66 67 68 69
void Surface_Selection_DockTab::updateMapParameters()
{
	b_updatingUI = true;

	combo_positionAttribute->clear();
	combo_positionAttribute->addItem("- select attribute -");

	MapHandlerGen* map = m_schnapps->getSelectedMap();

70
	if(map)
71
	{
72
		const MapParameters& p = m_plugin->h_parameterSet[map];
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

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

		unsigned int i = 1;
		const AttributeSet& attribs = map->getAttributeSet(VERTEX);
		for(AttributeSet::const_iterator it = attribs.constBegin(); it != attribs.constEnd(); ++it)
		{
			if(it.value() == vec3TypeName)
			{
				combo_positionAttribute->addItem(it.key());
				if(p.positionAttribute.isValid() && it.key() == QString::fromStdString(p.positionAttribute.name()))
					combo_positionAttribute->setCurrentIndex(i);

				++i;
			}
		}
89 90

		combo_selectionMethod->setCurrentIndex(p.selectionMethod);
91 92 93 94 95 96 97 98
	}

	b_updatingUI = false;
}

} // namespace SCHNApps

} // namespace CGoGN