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

#include "surface_radiance.h"
#include "schnapps.h"
#include "mapHandler.h"

namespace CGoGN
{

namespace SCHNApps
{

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

	connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int)));
	connect(combo_normalVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(normalVBOChanged(int)));
22
	connect(checkbox_fragInterp, SIGNAL(stateChanged(int)), this, SLOT(fragmentInterpolationChanged(int)));
23
	connect(button_decimate, SIGNAL(clicked()), this, SLOT(decimateClicked()));
24 25 26 27 28 29 30 31 32 33 34 35 36 37
}





void Surface_Radiance_DockTab::positionVBOChanged(int index)
{
	if(!b_updatingUI)
	{
		MapHandlerGen* map = m_schnapps->getSelectedMap();
		if(map)
		{
			m_plugin->h_mapParameterSet[map].positionVBO = map->getVBO(combo_positionVBO->currentText());
38 39
			foreach (View* v, map->getLinkedViews())
				v->updateGL();
40 41 42 43 44 45 46 47 48 49 50 51
		}
	}
}

void Surface_Radiance_DockTab::normalVBOChanged(int index)
{
	if(!b_updatingUI)
	{
		MapHandlerGen* map = m_schnapps->getSelectedMap();
		if(map)
		{
			m_plugin->h_mapParameterSet[map].normalVBO = map->getVBO(combo_normalVBO->currentText());
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
			foreach (View* v, map->getLinkedViews())
				v->updateGL();
		}
	}
}

void Surface_Radiance_DockTab::fragmentInterpolationChanged(int state)
{
	if(!b_updatingUI)
	{
		MapHandlerGen* map = m_schnapps->getSelectedMap();
		if(map)
		{
			m_plugin->h_mapParameterSet[map].radiancePerVertexShader->setFragInterp(state == Qt::Checked);
			foreach (View* v, map->getLinkedViews())
				v->updateGL();
68 69 70 71
		}
	}
}

72 73
void Surface_Radiance_DockTab::decimateClicked()
{
74 75 76 77 78 79 80
	m_plugin->decimate(
		m_schnapps->getSelectedMap()->getName(),
		combo_positionVBO->currentText(),
		combo_normalVBO->currentText(),
		slider_decimationGoal->value() / 100.0f,
		checkbox_halfCollapse->checkState() == Qt::Checked
	);
81 82
}

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151




void Surface_Radiance_DockTab::addPositionVBO(QString name)
{
	b_updatingUI = true;
	combo_positionVBO->addItem(name);
	b_updatingUI = false;
}

void Surface_Radiance_DockTab::removePositionVBO(QString name)
{
	b_updatingUI = true;
	int curIndex = combo_positionVBO->currentIndex();
	int index = combo_positionVBO->findText(name, Qt::MatchExactly);
	if(curIndex == index)
		combo_positionVBO->setCurrentIndex(0);
	combo_positionVBO->removeItem(index);
	b_updatingUI = false;
}

void Surface_Radiance_DockTab::addNormalVBO(QString name)
{
	b_updatingUI = true;
	combo_normalVBO->addItem(name);
	b_updatingUI = false;
}

void Surface_Radiance_DockTab::removeNormalVBO(QString name)
{
	b_updatingUI = true;
	int curIndex = combo_normalVBO->currentIndex();
	int index = combo_normalVBO->findText(name, Qt::MatchExactly);
	if(curIndex == index)
		combo_normalVBO->setCurrentIndex(0);
	combo_normalVBO->removeItem(index);
	b_updatingUI = false;
}

void Surface_Radiance_DockTab::updateMapParameters()
{
	b_updatingUI = true;

	combo_positionVBO->clear();
	combo_positionVBO->addItem("- select VBO -");
	combo_normalVBO->clear();
	combo_normalVBO->addItem("- select VBO -");

	MapHandlerGen* map = m_schnapps->getSelectedMap();
	if(map)
	{
		const MapParameters& p = m_plugin->h_mapParameterSet[map];

		unsigned int i = 1;
		foreach(Utils::VBO* vbo, map->getVBOSet().values())
		{
			unsigned int dataSize = vbo->dataSize();
			if(dataSize == 3)
			{
				combo_positionVBO->addItem(QString::fromStdString(vbo->name()));
				if(vbo == p.positionVBO)
					combo_positionVBO->setCurrentIndex(i);
				combo_normalVBO->addItem(QString::fromStdString(vbo->name()));
				if(vbo == p.normalVBO)
					combo_normalVBO->setCurrentIndex(i);
				++i;
			}
		}
152 153

		checkbox_fragInterp->setChecked(p.radiancePerVertexShader->getFragInterp());
154 155 156 157 158 159 160 161
	}

	b_updatingUI = false;
}

} // namespace SCHNApps

} // namespace CGoGN