コード例 #1
0
//-----------------------------------------------------------------------
void MaterialTab::OnEmissive(wxCommandEvent& event)
{
	Ogre::Pass* pass = getFirstPass();
	if (pass)
	{
		Ogre::ColourValue colour = pass->getSelfIllumination();
		wxColour wxCol(colour.r * 255, colour.g * 255, colour.b * 255, colour.a * 255);
		wxColourData colourData;
		colourData.SetColour(wxCol); // Set the current pass colour
		wxColourDialog colourDialog(this, &colourData);
		if (event.GetEventObject() && event.GetEventObject()->IsKindOf(CLASSINFO(wxButton)))
		{
			colourDialog.SetPosition(((wxButton*)event.GetEventObject())->GetPosition());
		}
		if (colourDialog.ShowModal() == wxID_OK)
		{
			// Set colour in pass
			colourData = colourDialog.GetColourData();
			wxCol = colourData.GetColour();
			colour = Ogre::ColourValue(((ParticleUniverse::Real)wxCol.Red())/255.0f, 
			((ParticleUniverse::Real)wxCol.Green())/255.0f, 
			((ParticleUniverse::Real)wxCol.Blue())/255.0f, 
			((ParticleUniverse::Real)wxCol.Alpha())/255.0f);
		}
		pass->setSelfIllumination(colour);
	}
}
コード例 #2
0
void TColourScaleEditor::mouseDoubleClickEvent(QMouseEvent* event)
{
	// Store mouse position
	lastPos_ = event->pos();

	// Check mouse position
	if (gradientBarRegion_.contains(lastPos_))
	{
		// Gradient bar was double-clicked, so add a new point at this position
		double clickedValue = gradientBarValue(lastPos_);
		QColor clickedColour = colourScale_.colourAsQColor(clickedValue);
		colourScale_.addPoint(clickedValue, clickedColour);

		updateGradient();
		repaint();

		emit(colourScaleChanged());
	}
	else if (handleRegion_.contains(lastPos_))
	{
		currentColourScalePoint_ = handleUnderMouse(lastPos_);
		
		if (currentColourScalePoint_)
		{
			ColourDialog colourDialog(this);
			if (colourDialog.execute(currentColourScalePoint_->colourAsQColor()))
			{
				colourScale_.setColour(currentColourScalePoint_, colourDialog.selectedColour());

				updateGradient();
				repaint();

				emit(colourScaleChanged());
			}
		}
	}
	else if (labelRegion_.contains(lastPos_))
	{
		currentColourScalePoint_ = labelUnderMouse(lastPos_);

		if (currentColourScalePoint_)
		{
			bool ok;
			double newValue = QInputDialog::getDouble(this, "Set point value", "New value: ", currentColourScalePoint_->value(), -1.0e7, 1.0e7, 6, &ok);
			if (ok)
			{
				colourScale_.setValue(currentColourScalePoint_, newValue);

				updateGradient();
				repaint();

				emit(colourScaleChanged());
			}
		}
	}

	currentColourScalePoint_ = NULL;
}