예제 #1
0
void AtenPrefs::on_ElementList_currentRowChanged(int row)
{
	// Update the info for the current element
	ui.ElementNameLabel->setText(ElementMap::name(row));
	ui.ElementSymbolLabel->setText(ElementMap::symbol(row));
	ui.ElementMassLabel->setText(QString::number(ElementMap::atomicMass(row)));
	ui.ElementRadiusSpin->setValue(ElementMap::atomicRadius(row));

	ReturnValue rv;
	rv.setArray(VTypes::DoubleData, ElementMap::colour(row), 4);
	ui.ElementColourButton->callPopupMethod("setCurrentColour", rv);
}
예제 #2
0
// Call named method associated to popup
bool GridColourPopup::callMethod(QString methodName, ReturnValue& rv)
{
	bool result = true;
	if (methodName == "TEST") return true;
	else if (methodName == "currentColour")
	{
		QColor newColor = ui.ColourWidget->currentColour();
		double colour[4];
		colour[0] = newColor.redF();
		colour[1] = newColor.greenF();
		colour[2] = newColor.blueF();
		colour[3] = newColor.alphaF();
		rv.setArray(VTypes::DoubleData, colour, 4);
		return true;
	}
	else if (methodName == "setCurrentColour")
	{
		bool success;
		QColor newColour;
		newColour.setRedF(rv.asDouble(0, success));
		if (success) newColour.setGreenF(rv.asDouble(1, success));
		if (success) newColour.setBlueF(rv.asDouble(2, success));
		if (success) newColour.setAlphaF(rv.asDouble(3, success));
		if (!success)
		{
			printf("Failed to get colour information from supplied ReturnValue.\n");
			return false;
		}
		setCurrentColour(newColour);

		updateParentButtonIcon(newColour);

		return true;
	}
	else if (methodName == "hideEvent")
	{
		updateParentButtonIcon(ui.ColourWidget->currentColour());
		return true;
	}
	else
	{
		printf("No method called '%s' is available in this popup.\n", qPrintable(methodName));
		result = false;
	}
	return result;
}
예제 #3
0
// Retrieve desired value
bool ForcefieldBoundVariable::retrieveAccessor(int i, ReturnValue& rv, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("ForcefieldBoundVariable::retrieveAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for ForcefieldBound type.\n", i);
		Messenger::exit("ForcefieldBoundVariable::retrieveAccessor");
		return false;
	}
	Accessors acc = (Accessors) i;
	// Check for correct lack/presence of array index given
	if ((accessorData[i].arraySize == 0) && hasArrayIndex)
	{
		Messenger::print("Error: Unnecessary array index provided for member '%s'.", qPrintable(accessorData[i].name));
		Messenger::exit("ForcefieldBoundVariable::retrieveAccessor");
		return false;
	}
	else if ((accessorData[i].arraySize > 0) && (hasArrayIndex))
	{
		if ((arrayIndex < 1) || (arrayIndex > accessorData[i].arraySize))
		{
			Messenger::print("Error: Array index out of bounds for member '%s' (%i, range is 1-%i).", qPrintable(accessorData[i].name), arrayIndex, accessorData[i].arraySize);
			Messenger::exit("ForcefieldBoundVariable::retrieveAccessor");
			return false;
		}
	}
	// Get current data from ReturnValue
	bool result = true;
	int n;
	ForcefieldBound* ptr = (ForcefieldBound*) rv.asPointer(VTypes::ForcefieldBoundData, result);
	if ((!result) || (ptr == NULL))
	{
		Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::ForcefieldBoundData));
		result = false;
	}
	if (result) switch (acc)
	{
		case (ForcefieldBoundVariable::Data):
			if (hasArrayIndex) rv.set(ptr->parameter(arrayIndex-1));
			else rv.setArray(VTypes::DoubleData, ptr->parameters(), MAXFFPARAMDATA);
			break;
		case (ForcefieldBoundVariable::DataKeyword):
			// Must have an array index here...
			if (!hasArrayIndex)
			{
				Messenger::print("Accessor 'datakeyword' must have an array index.");
				result = false;
			}
			else switch (ptr->type())
			{
				case (ForcefieldBound::BondInteraction):
				case (ForcefieldBound::UreyBradleyInteraction):
					rv.set(BondFunctions::functionData[ptr->bondForm()].parameterKeywords[arrayIndex-1]);
					break;
				case (ForcefieldBound::AngleInteraction):
					rv.set(AngleFunctions::functionData[ptr->angleForm()].parameterKeywords[arrayIndex-1]);
					break;
				case (ForcefieldBound::TorsionInteraction):
				case (ForcefieldBound::ImproperInteraction):
					rv.set(TorsionFunctions::functionData[ptr->torsionForm()].parameterKeywords[arrayIndex-1]);
					break;
				default:
					break;
			}
			break;
		case (ForcefieldBoundVariable::DataName):
			// Must have an array index here...
			if (!hasArrayIndex)
			{
				Messenger::print("Accessor 'dataname' must have an array index.");
				result = false;
			}
			else switch (ptr->type())
			{
				case (ForcefieldBound::BondInteraction):
				case (ForcefieldBound::UreyBradleyInteraction):
					rv.set(BondFunctions::functionData[ptr->bondForm()].parameters[arrayIndex-1]);
					break;
				case (ForcefieldBound::AngleInteraction):
					rv.set(AngleFunctions::functionData[ptr->angleForm()].parameters[arrayIndex-1]);
					break;
				case (ForcefieldBound::TorsionInteraction):
				case (ForcefieldBound::ImproperInteraction):
					rv.set(TorsionFunctions::functionData[ptr->torsionForm()].parameters[arrayIndex-1]);
					break;
				default:
					break;
			}
			break;
		case (ForcefieldBoundVariable::EScale):
			if (ptr->type() != ForcefieldBound::TorsionInteraction)
			{
				Messenger::print("Tried to retrieve the 1-4 coulombic scale factor for a non-torsion bound interaction.");
				result = false;
			}
			else rv.set(ptr->elecScale());
			break;
		case (ForcefieldBoundVariable::Form):
			rv.set(ptr->formText());
			break;
		case (ForcefieldBoundVariable::NAtoms):
			rv.set(ForcefieldBound::boundTypeNAtoms(ptr->type()));
			break;
		case (ForcefieldBoundVariable::NParams):
			switch (ptr->type())
			{
				case (ForcefieldBound::BondInteraction):
				case (ForcefieldBound::UreyBradleyInteraction):
					rv.set(BondFunctions::functionData[ptr->bondForm()].nParameters);
					break;
				case (ForcefieldBound::AngleInteraction):
					rv.set(AngleFunctions::functionData[ptr->angleForm()].nParameters);
					break;
				case (ForcefieldBound::TorsionInteraction):
				case (ForcefieldBound::ImproperInteraction):
					rv.set(TorsionFunctions::functionData[ptr->torsionForm()].nParameters);
					break;
        default:
          break;  
			}
			break;
		case (ForcefieldBoundVariable::Type):
			rv.set(ForcefieldBound::boundType(ptr->type()));
			break;
		case (ForcefieldBoundVariable::TypeNames):
			if (hasArrayIndex) rv.set(ptr->typeName(arrayIndex-1));
			else rv.setArray(VTypes::StringData, ptr->typeNames(), MAXFFPARAMDATA);
			break;
		case (ForcefieldBoundVariable::VScale):
			if (ptr->type() != ForcefieldBound::TorsionInteraction)
			{
				Messenger::print("Tried to retrieve the 1-4 VDW scale factor for a non-torsion bound interaction.");
				result = false;
			}
			else rv.set(ptr->vdwScale());
			break;
		default:
			printf("Internal Error: Access to member '%s' has not been defined in ForcefieldBoundVariable.\n", qPrintable(accessorData[i].name));
			result = false;
			break;
	}
	Messenger::exit("ForcefieldBoundVariable::retrieveAccessor");
	return result;
}
예제 #4
0
// Constructor
AtenPrefs::AtenPrefs(AtenWindow& parent) : QDialog(&parent), parent_(parent)
{
	ui.setupUi(this);

	// Add colour popups to buttons
	ui.ElementColourButton->setPopupWidget(new ColourPopup(parent_, ui.ElementColourButton), true);
	connect(ui.ElementColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(elementColourChanged()));
	ui.SpotlightAmbientColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightAmbientColourButton, TColourWidget::NoAlphaOption), true);
	connect(ui.SpotlightAmbientColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightAmbientChanged()));
	ui.SpotlightDiffuseColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightDiffuseColourButton, TColourWidget::NoAlphaOption), true);
	connect(ui.SpotlightDiffuseColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightDiffuseChanged()));
	ui.SpotlightSpecularColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightSpecularColourButton, TColourWidget::NoAlphaOption), true);
	connect(ui.SpotlightSpecularColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightSpecularChanged()));

	refreshing_ = false;

	// Add elements to element list and select first item
	QListWidgetItem* item;
	for (int i=0; i<ElementMap::nElements(); ++i)
	{
		item = new QListWidgetItem(ui.ElementList);
		item->setText(ElementMap::name(i));
	}

	refreshing_ = true;

	// Select the first element in the elements list
	ui.ElementList->setCurrentRow(0);

	// Set Controls
	// View Page - Style Tab
	ui.StickRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::LineStyle));
	ui.TubeRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::TubeStyle));
	ui.SphereRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::SphereStyle));
	ui.ScaledRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::ScaledStyle));
	ui.StickBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::LineStyle));
	ui.TubeBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::TubeStyle));
	ui.SphereBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::SphereStyle));
	ui.ScaledBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::ScaledStyle));
	ui.SelectionScaleSpin->setValue(prefs.selectionScale());
	ui.AngleLabelFormatEdit->setText(prefs.angleLabelFormat());
	ui.DistanceLabelFormatEdit->setText(prefs.distanceLabelFormat());
	ui.ChargeLabelFormatEdit->setText(prefs.chargeLabelFormat());
	ui.LabelSizeSpin->setValue(prefs.labelSize());
	ui.RenderDashedAromaticsCheck->setChecked(prefs.renderDashedAromatics());
	ui.DrawHydrogenBondsCheck->setChecked(prefs.drawHydrogenBonds());
	ui.HydrogenBondDotRadiusSpin->setValue(prefs.hydrogenBondDotRadius());
	ui.StickLineNormalWidthSpin->setValue(prefs.stickLineNormalWidth());
	ui.StickLineSelectedWidthSpin->setValue(prefs.stickLineSelectedWidth());
	
	// View Page - Colours Tab
	ui.ColoursTable->setRowCount(Prefs::nObjectColours);
	QColor qcol;
	for (int n = 0; n < Prefs::nObjectColours; ++n)
	{
		QTableWidgetItem *item = new QTableWidgetItem(Prefs::objectColourName( (Prefs::ObjectColour) n ));
		ui.ColoursTable->setItem(n, 0, item);
		item = new QTableWidgetItem();
		double* colour = prefs.colour( (Prefs::ObjectColour) n );
		qcol.setRgbF( colour[0], colour[1], colour[2], colour[3] );
		item->setBackgroundColor(qcol);
		ui.ColoursTable->setItem(n, 1, item);
	}

	// View Page - Rendering / Quality tab
	ReturnValue rv;
	rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::AmbientComponent), 4);
	ui.SpotlightAmbientColourButton->callPopupMethod("setCurrentColour", rv);
	rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::DiffuseComponent), 4);
	ui.SpotlightDiffuseColourButton->callPopupMethod("setCurrentColour", rv);
	rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::SpecularComponent), 4);
	ui.SpotlightSpecularColourButton->callPopupMethod("setCurrentColour", rv);
	double* pos = prefs.spotlightPosition();
	ui.SpotlightPositionXSpin->setValue(pos[0]);
	ui.SpotlightPositionYSpin->setValue(pos[1]);
	ui.SpotlightPositionZSpin->setValue(pos[2]);
	ui.ShininessSpin->setValue(prefs.shininess());
	ui.PrimitiveQualitySpin->setValue(prefs.primitiveQuality());
	ui.ImagePrimitiveQualitySpin->setValue(prefs.imagePrimitiveQuality());
	ui.ImagePrimitivesGroup->setChecked(!prefs.reusePrimitiveQuality());
	ui.LineAliasingCheck->setChecked(prefs.lineAliasing());
	ui.PolygonAliasingCheck->setChecked(prefs.polygonAliasing());
	ui.MultiSamplingCheck->setChecked(prefs.multiSampling());
	ui.NearClipSpin->setValue(prefs.clipNear());
	ui.FarClipSpin->setValue(prefs.clipFar());
	ui.NearDepthSpin->setValue(prefs.depthNear());
	ui.FarDepthSpin->setValue(prefs.depthFar());

	// View Page - Fonts tab
	ui.ViewerFontEdit->setText(prefs.viewerFontFileName());
	ui.MessagesSizeSpin->setValue(prefs.messagesFont().pixelSize());

	// Set controls in interaction page
	ui.LeftMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::LeftButton));
	ui.MiddleMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::MiddleButton));
	ui.RightMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::RightButton));
	ui.WheelMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::WheelButton));
	ui.ShiftButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::ShiftKey));
	ui.CtrlButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::CtrlKey));
	ui.AltButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::AltKey));
	ui.ViewLockCombo->setCurrentIndex(prefs.viewLock());
	ui.ZoomThrottleSpin->setValue(prefs.zoomThrottle());
	ui.MouseMoveFilterSpin->setValue(prefs.mouseMoveFilter());

	// Set controls in Program page
	ui.DensityUnitCombo->setCurrentIndex(prefs.densityUnit());
	ui.EnergyUnitCombo->setCurrentIndex(prefs.energyUnit());
	ui.HAddDistanceSpin->setValue(prefs.hydrogenDistance());
	ui.MaxCuboidsSpin->setValue(prefs.maxCuboids());
	ui.MaxRingsSpin->setValue(prefs.maxRings());
	ui.MaxRingSizeSpin->setValue(prefs.maxRingSize());
	ui.MaxUndoLevelsSpin->setValue(prefs.maxUndoLevels());

	// Set pen colours and colourscale names and checks
	for (int n=0; n<10; n++)
	{
		QListWidgetItem* item = new QListWidgetItem(QString::number(n+1) + ". " + prefs.colourScale[n].name());
		item->setCheckState( prefs.colourScale[n].visible() ? Qt::Checked : Qt::Unchecked);
		ui.ScaleList->addItem(item);
	}
	ui.ScaleList->setCurrentRow(0);
	ui.ScaleEditor->setColourScale(prefs.colourScale[0]);
	connect(ui.ScaleEditor, SIGNAL(colourScaleChanged()), this, SLOT(colourScaleChanged()));

	// Set controls in Energy/FF page
	ui.CalculateIntraCheck->setChecked(prefs.calculateIntra());
	ui.CalculateVdwCheck->setChecked(prefs.calculateVdw());
	ui.ElectrostaticMethodCombo->setCurrentIndex(prefs.electrostaticsMethod());
	ui.VdwCutoffSpin->setValue(prefs.vdwCutoff());
	ui.ElecCutoffSpin->setValue(prefs.elecCutoff());
	ui.EwaldPrecisionMantissaSpin->setValue(prefs.ewaldPrecision().mantissa());
	ui.EwaldPrecisionExponentSpin->setValue(prefs.ewaldPrecision().exponent());
	ui.EwaldManualAlphaSpin->setValue(prefs.ewaldAlpha());
	ui.EwaldManualKXSpin->setValue(prefs.ewaldKMax().x);
	ui.EwaldManualKYSpin->setValue(prefs.ewaldKMax().y);
	ui.EwaldManualKZSpin->setValue(prefs.ewaldKMax().z);
	ui.FunctionalFormList->clear();
	QListWidgetItem* listitem;
	for (int n=0; n<VdwFunctions::nVdwFunctions; ++n)
	{
		listitem = new QListWidgetItem(ui.FunctionalFormList);
		listitem->setText(VdwFunctions::functionData[n].name);
	}
	ui.FunctionalFormList->setCurrentRow(0);

	// External Programs
	ui.TemporaryDirEdit->setText(prefs.tempDir().path());
	ui.MopacExecutableEdit->setText(prefs.mopacExe());

	// Store current values in the Prefs structure...
	prefsBackup_ = prefs;
	ElementMap::backupData();

	refreshing_ = false;
}