Ejemplo n.º 1
0
void PatchInspector::setPatch(const PatchNodePtr& newPatch)
{
	// Detach if we had a previous patch
	PatchNodePtr patch = _patch.lock();

	if (patch != NULL)
	{
		patch->getPatch().detachObserver(this);
	}

	// Clear vertex chooser while _patchRows/_patchCols are still set
	clearVertexChooser();

	_patch = newPatch;

	if (newPatch != NULL)
	{
		newPatch->getPatch().attachObserver(this);

		_patchRows = newPatch->getPatch().getHeight();
		_patchCols = newPatch->getPatch().getWidth();

		// Now that rows/cols are known, build lists
		repopulateVertexChooser();
	}
	else
	{
		_patchRows = 0;
		_patchCols = 0;
	}
}
Ejemplo n.º 2
0
void PatchInspector::update()
{
	_updateActive = true;

	PatchNodePtr patch = _patch.lock();

	if (patch != NULL)
	{
		// Check if the matrix size has changed
		if (patch->getPatch().getWidth() != _patchCols ||
			patch->getPatch().getHeight() != _patchRows)
		{
			// Patch matrix got changed
			clearVertexChooser();
			repopulateVertexChooser();
		}

		// Load the data from the currently selected vertex
		loadControlVertex();
	}

	_updateActive = false;
}
Ejemplo n.º 3
0
void PatchInspector::loadControlVertex()
{
	PatchNodePtr patch = _patch.lock();

	if (patch != NULL)
	{
		int row = _rowCombo->GetSelection();
		int col = _colCombo->GetSelection();

		// Retrieve the controlvertex
		const PatchControl& ctrl = patch->getPatch().ctrlAt(row, col);

		_updateActive = true;

		_coords["x"].value->SetValue(string::to_string(ctrl.vertex[0]));
		_coords["y"].value->SetValue(string::to_string(ctrl.vertex[1]));
		_coords["z"].value->SetValue(string::to_string(ctrl.vertex[2]));
		_coords["s"].value->SetValue(string::to_string(ctrl.texcoord[0]));
		_coords["t"].value->SetValue(string::to_string(ctrl.texcoord[1]));

		_updateActive = false;
	}
}