示例#1
0
// Perform desired function
bool BasisShellVariable::performFunction(int i, ReturnValue& rv, TreeNode* node)
{
	Messenger::enter("BasisShellVariable::performFunction");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nFunctions))
	{
		printf("Internal Error: FunctionAccessor id %i is out of range for BasisShell type.\n", i);
		Messenger::exit("BasisShellVariable::performFunction");
		return false;
	}
	// Get current data from ReturnValue
	bool result = true;
	BasisShell* ptr = (BasisShell*) rv.asPointer(VTypes::BasisShellData, result);
	BasisPrimitive* prim;
	int n;
	if (result) switch (i)
	{
		case (BasisShellVariable::AddPrimitive):
			prim = ptr->addPrimitive();
			prim->setExponent( node->argd(0) );
			for (n=1; n<node->nArgs(); ++n) prim->addCoefficient(node->argd(n));
			rv.set(VTypes::BasisPrimitiveData, prim);
			break;
		default:
			printf("Internal Error: Access to function '%s' has not been defined in BasisShellVariable.\n", qPrintable(functionData[i].name));
			result = false;
			break;
	}
	Messenger::exit("BasisShellVariable::performFunction");
	return result;
}
示例#2
0
文件: bond.cpp 项目: alinelena/aten
// Perform desired function
bool BondVariable::performFunction(int i, ReturnValue& rv, TreeNode* node)
{
	Messenger::enter("BondVariable::performFunction");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nFunctions))
	{
		printf("Internal Error: FunctionAccessor id %i is out of range for Bond type.\n", i);
		Messenger::exit("BondVariable::performFunction");
		return false;
	}
	// Get current data from ReturnValue
	bool result = true;
	Bond* ptr = (Bond*) rv.asPointer(VTypes::BondData, result);
	if (result) switch (i)
	{
		case (BondVariable::Partner):
			rv.set(VTypes::AtomData, ptr->partner( (Atom*) node->argp(0, VTypes::AtomData)));
			break;
		default:
			printf("Internal Error: Access to function '%s' has not been defined in BondVariable.\n", qPrintable(functionData[i].name));
			result = false;
			break;
	}
	Messenger::exit("BondVariable::performFunction");
	return result;
}
示例#3
0
// Retrieve desired value
bool BasisShellVariable::retrieveAccessor(int i, ReturnValue& rv, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("BasisShellVariable::retrieveAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for BasisShell type.\n", i);
		Messenger::exit("BasisShellVariable::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("BasisShellVariable::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("BasisShellVariable::retrieveAccessor");
			return false;
		}
	}
	// Get current data from ReturnValue
	bool result = true;
	BasisShell* ptr = (BasisShell*) rv.asPointer(VTypes::BasisShellData, result);
	if ((!result) || (ptr == NULL))
	{
		Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::BasisShellData));
		result = false;
	}
	if (result) switch (acc)
	{
		case (BasisShellVariable::AtomId):
			rv.set(ptr->atomId()+1);
			break;
		case (BasisShellVariable::Primitives):
			if ((arrayIndex < 1) || (arrayIndex > ptr->nPrimitives()))
			{
				Messenger::print("Array index [%i] is out of range for 'primitives' member.", arrayIndex);
				result = false;
			}
			else rv.set(VTypes::BasisPrimitiveData, ptr->primitive(arrayIndex-1));
			break;
		case (BasisShellVariable::Type):
			rv.set(BasisShell::basisShellType(ptr->type()));
			break;
		default:
			printf("Internal Error: Access to member '%s' has not been defined in BasisShellVariable.\n", qPrintable(accessorData[i].name));
			result = false;
			break;
	}
	Messenger::exit("BasisShellVariable::retrieveAccessor");
	return result;
}
示例#4
0
文件: glyph.cpp 项目: alinelena/aten
// Set desired value
bool GlyphVariable::setAccessor(int i, ReturnValue& sourcerv, ReturnValue& newValue, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("GlyphVariable::setAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for Glyph type.\n", i);
		Messenger::exit("GlyphVariable::setAccessor");
		return false;
	}
	Accessors acc = (Accessors) i;

	// Check for correct lack/presence of array index given to original accessor, and nature of new value
	bool result = checkAccessorArrays(accessorData[acc], newValue, hasArrayIndex, arrayIndex);
	if (!result)
	{
		Messenger::exit("GlyphVariable::setAccessor");
		return false;
	}

	// Get current data from ReturnValue
	Glyph* ptr = (Glyph*) sourcerv.asPointer(VTypes::GlyphData, result);
	if ((!result) || (ptr == NULL))
	{
		Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::GlyphData));
		result = false;
	}
	if (result) switch (acc)
	{
		case (GlyphVariable::Rotated):
			if (newValue.asInteger() == 0) ptr->resetRotation();
			break;
		case (GlyphVariable::Rotation):
			ptr->setRotationElement( ((arrayIndex-1)/3)*4 + (arrayIndex-1)%3, newValue.asDouble());
			break;
		case (GlyphVariable::Selected):
			ptr->setSelected(newValue.asBool());
			break;
		case (GlyphVariable::Solid):
			ptr->setSolid(newValue.asBool());
			break;
		case (GlyphVariable::Text):
			ptr->setText(newValue.asString());
			break;
		case (GlyphVariable::Visible):
			ptr->setVisible(newValue.asBool());
			break;
		default:
			printf("GlyphVariable::setAccessor doesn't know how to use member '%s'.\n", qPrintable(accessorData[acc].name));
			result = false;
			break;
	}
	Messenger::exit("GlyphVariable::setAccessor");
	return result;
}
示例#5
0
文件: widget.cpp 项目: alinelena/aten
// Retrieve desired value
bool WidgetVariable::retrieveAccessor(int i, ReturnValue& rv, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("WidgetVariable::retrieveAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for Aten type.\n", i);
		Messenger::exit("WidgetVariable::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("WidgetVariable::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("WidgetVariable::retrieveAccessor");
			return false;
		}
	}
	// Variables used in retrieval
	bool result = true;
	TreeGuiWidget* ptr = (TreeGuiWidget*) rv.asPointer(VTypes::WidgetData, result);
	if ((!result) || (ptr == NULL))
	{
	        Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::WidgetData));
	        result = false;
	}
	if (result) switch (acc)
	{
		case (WidgetVariable::Enabled):
			rv.set(ptr->enabled());
			break;
		case (WidgetVariable::VerticalFill):
			rv.set(ptr->qtWidgetObject() == NULL ? false : ptr->qtWidgetObject()->autoFillVertical());
			break;
		case (WidgetVariable::Visible):
			rv.set(ptr->visible());
			break;
		default:
			printf("Internal Error: Access to member '%s' has not been defined in WidgetVariable.\n", qPrintable(accessorData[i].name));
			result = false;
			break;
	}
	Messenger::exit("WidgetVariable::retrieveAccessor");
	return result;
}
示例#6
0
// Perform desired function
bool ForcefieldBoundVariable::performFunction(int i, ReturnValue& rv, TreeNode* node)
{
	Messenger::enter("ForcefieldBoundVariable::performFunction");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nFunctions))
	{
		printf("Internal Error: FunctionAccessor id %i is out of range for ForcefieldBound type.\n", i);
		Messenger::exit("ForcefieldBoundVariable::performFunction");
		return false;
	}

	// Get current data from ReturnValue
	bool result = true;
	ForcefieldBound* ptr = (ForcefieldBound*) rv.asPointer(VTypes::ForcefieldBoundData, result);
	int id;
	if (result) switch (i)
	{
		case (ForcefieldBoundVariable::Parameter):
			switch (ptr->type())
			{
				case (ForcefieldBound::BondInteraction):
				case (ForcefieldBound::UreyBradleyInteraction):
					id = BondFunctions::bondParameter(ptr->bondForm(), node->argc(0), true);
					if (id == BondFunctions::functionData[ptr->bondForm()].nParameters) result = false;
					else rv.set(ptr->parameter(id));
					break;
				case (ForcefieldBound::AngleInteraction):
					id = AngleFunctions::angleParameter(ptr->angleForm(), node->argc(0), true);
					if (id == AngleFunctions::functionData[ptr->angleForm()].nParameters) result = false;
					else rv.set(ptr->parameter(id));
					break;
				case (ForcefieldBound::TorsionInteraction):
				case (ForcefieldBound::ImproperInteraction):
					id = TorsionFunctions::torsionParameter(ptr->torsionForm(), node->argc(0), true);
					if (id == TorsionFunctions::functionData[ptr->torsionForm()].nParameters) result = false;
					else rv.set(ptr->parameter(id));
					break;
        default:
          break;  
			}
			break;
		default:
			printf("Internal Error: Access to function '%s' has not been defined in ForcefieldBoundVariable.\n", qPrintable(functionData[i].name));
			result = false;
			break;
	}
	Messenger::exit("ForcefieldBoundVariable::performFunction");
	return result;
}
示例#7
0
文件: widget.cpp 项目: alinelena/aten
// Set desired value
bool WidgetVariable::setAccessor(int i, ReturnValue& sourcerv, ReturnValue& newValue, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("WidgetVariable::setAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for Aten type.\n", i);
		Messenger::exit("WidgetVariable::setAccessor");
		return false;
	}
	Accessors acc = (Accessors) i;

	// Check for correct lack/presence of array index given to original accessor, and nature of new value
	bool result = checkAccessorArrays(accessorData[acc], newValue, hasArrayIndex, arrayIndex);
	if (!result)
	{
		Messenger::exit("WidgetVariable::setAccessor");
		return false;
	}

	// Get current data from ReturnValue
	TreeGuiWidget* ptr = (TreeGuiWidget*) sourcerv.asPointer(VTypes::WidgetData, result);
	if ((!result) || (ptr == NULL))
	{
	        Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::WidgetData));
	        result = false;
	}
	switch (acc)
	{
		case (WidgetVariable::Enabled):
			ptr->setEnabled(newValue.asBool());
			if (ptr->qtWidgetObject()) ptr->qtWidgetObject()->updateQt();;
			break;
		case (WidgetVariable::VerticalFill):
			if (ptr->qtWidgetObject()) ptr->qtWidgetObject()->setAutoFillVertical(newValue.asBool());
			break;
		case (WidgetVariable::Visible):
			ptr->setVisible(newValue.asBool());
			if (ptr->qtWidgetObject()) ptr->qtWidgetObject()->updateQt();;
			break;
		default:
			printf("WidgetVariable::setAccessor doesn't know how to use member '%s'.\n", qPrintable(accessorData[acc].name));
			result = false;
			break;
	}
	Messenger::exit("WidgetVariable::setAccessor");
	return result;
}
示例#8
0
文件: glyph.cpp 项目: alinelena/aten
// Perform desired function
bool GlyphVariable::performFunction(int i, ReturnValue& rv, TreeNode* node)
{
	Messenger::enter("GlyphVariable::performFunction");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nFunctions))
	{
		printf("Internal Error: FunctionAccessor id %i is out of range for Glyph type.\n", i);
		Messenger::exit("GlyphVariable::performFunction");
		return false;
	}

	// Get current data from ReturnValue
	bool result = true;
	Glyph* ptr = (Glyph*) rv.asPointer(VTypes::GlyphData, result);
	if (result) switch (i)
	{
		case (GlyphVariable::Recolour):
			ptr->setColour(node->argd(0), node->argd(1), node->argd(2), node->hasArg(3) ? node->argd(3) : 1.0);
			break;
		case (GlyphVariable::ResetRotation):
			ptr->resetRotation();
			rv.reset();
			break;
		case (GlyphVariable::Rotate):
			ptr->rotate(node->argd(0), node->argd(1), node->argd(2), node->argd(3));
			rv.reset();
			break;
		case (GlyphVariable::RotateX):
			ptr->rotateX(node->argd(0));
			rv.reset();
			break;
		case (GlyphVariable::RotateY):
			ptr->rotateY(node->argd(0));
			rv.reset();
			break;
		case (GlyphVariable::RotateZ):
			ptr->rotateZ(node->argd(0));
			rv.reset();
			break;
		default:
			printf("Internal Error: Access to function '%s' has not been defined in GlyphVariable.\n", qPrintable(functionData[i].name));
			result = false;
			break;
	}
	Messenger::exit("GlyphVariable::performFunction");
	return result;
}
示例#9
0
// Set desired value
bool BasisShellVariable::setAccessor(int i, ReturnValue& sourcerv, ReturnValue& newValue, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("BasisShellVariable::setAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for BasisShell type.\n", i);
		Messenger::exit("BasisShellVariable::setAccessor");
		return false;
	}
	Accessors acc = (Accessors) i;

	// Check for correct lack/presence of array index given to original accessor, and nature of new value
	bool result = checkAccessorArrays(accessorData[acc], newValue, hasArrayIndex, arrayIndex);
	if (!result)
	{
		Messenger::exit("BasisShellVariable::setAccessor");
		return false;
	}
	
	// Get current data from ReturnValue
	BasisShell* ptr = (BasisShell*) sourcerv.asPointer(VTypes::BasisShellData, result);
	if ((!result) || (ptr == NULL))
	{
		Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::BasisShellData));
		result = false;
	}
	BasisShell::BasisShellType bft;
	if (result) switch (acc)
	{
		case (BasisShellVariable::AtomId):
			ptr->setAtomId( newValue.asInteger() - 1);
			break;
		case (BasisShellVariable::Type):
			bft = BasisShell::basisShellType( newValue.asString() );
			if (bft == BasisShell::nBasisShellTypes) result = false;
			else ptr->setType(bft);
			break;
		default:
			printf("BasisShellVariable::setAccessor doesn't know how to use member '%s'.\n", qPrintable(accessorData[acc].name));
			result = false;
			break;
	}
	Messenger::exit("BasisShellVariable::setAccessor");
	return result;
}
示例#10
0
文件: bond.cpp 项目: alinelena/aten
// Set desired value
bool BondVariable::setAccessor(int i, ReturnValue& sourcerv, ReturnValue& newValue, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("BondVariable::setAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for Bond type.\n", i);
		Messenger::exit("BondVariable::setAccessor");
		return false;
	}
	Accessors acc = (Accessors) i;

	// Check for correct lack/presence of array index given to original accessor, and nature of new value
	bool result = checkAccessorArrays(accessorData[acc], newValue, hasArrayIndex, arrayIndex);
	if (!result)
	{
		Messenger::exit("BondVariable::setAccessor");
		return false;
	}

	// Get current data from ReturnValue
	Bond* ptr = (Bond*) sourcerv.asPointer(VTypes::BondData, result);
	Bond::BondType bt;
	if ((!result) || (ptr == NULL))
	{
		Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::BondData));
		result = false;
	}
	Model* ptrParent = ptr->atomI()->parent();
	if (result) switch (acc)
	{
		case (BondVariable::Type):
			bt = Bond::bondType(newValue.asString(), true);
			if (bt == Bond::nBondTypes) break;
			ptrParent->changeBond(ptr, bt);
			break;
		default:
			printf("BondVariable::setAccessor doesn't know how to use member '%s'.\n", qPrintable(accessorData[acc].name));
			result = false;
			break;
	}
	Messenger::exit("BondVariable::setAccessor");
	return result;
}
示例#11
0
// Set desired value
bool ForcefieldBoundVariable::setAccessor(int i, ReturnValue& sourcerv, ReturnValue& newValue, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("ForcefieldBoundVariable::setAccessor");
	// 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::setAccessor");
		return false;
	}
	Accessors acc = (Accessors) i;

	// Check for correct lack/presence of array index given to original accessor, and nature of new value
	bool result = checkAccessorArrays(accessorData[acc], newValue, hasArrayIndex, arrayIndex);
	if (!result)
	{
		Messenger::exit("ForcefieldBoundVariable::setAccessor");
		return false;
	}

	// Get current data from ReturnValue
	ForcefieldBound* ptr = (ForcefieldBound*) sourcerv.asPointer(VTypes::ForcefieldBoundData, result);
	if ((!result) || (ptr == NULL))
	{
		Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::ForcefieldBoundData));
		result = false;
	}
	int n;
	if (result) switch (acc)
	{
		case (ForcefieldBoundVariable::Data):
			if ((newValue.arraySize() != -1) && (newValue.arraySize() <= MAXFFPARAMDATA)) for (n=0; n<newValue.arraySize(); ++n) ptr->setParameter(n, newValue.asDouble(n, result));
			else if (hasArrayIndex) ptr->setParameter(arrayIndex-1, newValue.asDouble());
			else for (n=0; n<MAXFFPARAMDATA; ++n) ptr->setParameter(n, newValue.asDouble());
			break;
		case (ForcefieldBoundVariable::EScale):
			if (ptr->type() != ForcefieldBound::TorsionInteraction)
			{
				Messenger::print("Tried to set the 1-4 coulombic scale factor for a non-torsion bound interaction.");
				result = false;
			}
			else ptr->setElecScale( newValue.asDouble() );
			break;
		case (ForcefieldBoundVariable::Form):
			result = ptr->setForm(newValue.asString());
			break;
		case (ForcefieldBoundVariable::TypeNames):
			if ((newValue.arraySize() != -1) && (newValue.arraySize() <= MAXFFBOUNDTYPES)) for (n=0; n<newValue.arraySize(); ++n) ptr->setTypeName(n, newValue.asString(n, result));
			else if (hasArrayIndex) ptr->setTypeName(arrayIndex-1, newValue.asString());
			else for (n=0; n<MAXFFBOUNDTYPES; ++n) ptr->setTypeName(n, newValue.asString());
			break;
		case (ForcefieldBoundVariable::VScale):
			if (ptr->type() != ForcefieldBound::TorsionInteraction)
			{
				Messenger::print("Tried to set the 1-4 coulombic scale factor for a non-torsion bound interaction.");
				result = false;
			}
			else ptr->setVdwScale( newValue.asDouble() );
			break;
		default:
			printf("ForcefieldBoundVariable::setAccessor doesn't know how to use member '%s'.\n", qPrintable(accessorData[acc].name));
			result = false;
			break;
	}
	Messenger::exit("ForcefieldBoundVariable::setAccessor");
	return result;
}
示例#12
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;
}
示例#13
0
文件: glyph.cpp 项目: alinelena/aten
// Retrieve desired value
bool GlyphVariable::retrieveAccessor(int i, ReturnValue& rv, bool hasArrayIndex, int arrayIndex)
{
	Messenger::enter("GlyphVariable::retrieveAccessor");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nAccessors))
	{
		printf("Internal Error: Accessor id %i is out of range for Glyph type.\n", i);
		Messenger::exit("GlyphVariable::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("GlyphVariable::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("GlyphVariable::retrieveAccessor");
			return false;
		}
	}
	// Get current data from ReturnValue
	bool result = true;
	Glyph* ptr = (Glyph*) rv.asPointer(VTypes::GlyphData, result);
	if ((!result) || (ptr == NULL))
	{
		Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::GlyphData));
		result = false;
	}
	if (result) switch (acc)
	{
		case (GlyphVariable::Data):
			if (hasArrayIndex) rv.set( VTypes::GlyphDataData, ptr->data(arrayIndex-1) );
			else rv.set( VTypes::GlyphDataData, ptr->data(0) );
			break;
		case (GlyphVariable::NData):
			rv.set( Glyph::nGlyphData(ptr->type()) );
			break;
		case (GlyphVariable::Rotated):
			rv.set( ptr->isRotated() );
			break;
		case (GlyphVariable::Rotation):
			if ((arrayIndex < 1) || (arrayIndex > 9))
			{
				Messenger::print("Array index [%i] is out of range for 'rotation' member.", arrayIndex);
				result = false;
			}
			else rv.set(ptr->getRotationElement(((arrayIndex-1)/3)*4 + (arrayIndex-1)%3));
			break;
		case (GlyphVariable::Selected):
			rv.set( ptr->isSelected() );
			break;
		case (GlyphVariable::Solid):
			rv.set( ptr->isSolid() );
			break;
		case (GlyphVariable::Text):
			rv.set( qPrintable(ptr->text()) );
			break;
		case (GlyphVariable::Type):
			rv.set( Glyph::glyphType(ptr->type()) );
			break;
		case (GlyphVariable::Visible):
			rv.set( ptr->isVisible() );
			break;
		default:
			printf("Internal Error: Access to member '%s' has not been defined in GlyphVariable.\n", qPrintable(accessorData[i].name));
			result = false;
			break;
	}
	Messenger::exit("GlyphVariable::retrieveAccessor");
	return result;
}
示例#14
0
文件: widget.cpp 项目: alinelena/aten
// Perform desired function
bool WidgetVariable::performFunction(int i, ReturnValue& rv, TreeNode* node)
{
	Messenger::enter("WidgetVariable::performFunction");
	// Cast 'i' into Accessors enum value
	if ((i < 0) || (i >= nFunctions))
	{
		printf("Internal Error: FunctionAccessor id %i is out of range for Aten type.\n", i);
		Messenger::exit("WidgetVariable::performFunction");
		return false;
	}

	// Get current data from ReturnValue
	int xw, xh, l, t;
	TreeGuiWidgetEvent* event;
	TreeGuiWidgetEvent::EventProperty eventProperty;
	TreeGuiWidgetEvent::EventType eventType;
	TreeGuiWidget* targetWidget;
	ReturnValue value;
	bool result = true;
	TreeGuiWidget* ptr = (TreeGuiWidget*) rv.asPointer(VTypes::WidgetData, result);
	if ((!result) || (ptr == NULL))
	{
	        Messenger::print("Invalid (NULL) %s reference encountered.", VTypes::dataType(VTypes::WidgetData));
	        result = false;
	}
	if (result) switch (i)
	{
		case (WidgetVariable::AddButton):
			l = node->hasArg(2) ? node->argi(2) : -1;
			t = node->hasArg(3) ? node->argi(3) : -1;
			xw = node->hasArg(4) ? node->argi(4) : 0;
			xh = node->hasArg(5) ? node->argi(5) : 0;
			rv.set(VTypes::WidgetData, ptr->addCheck(node->argc(0), node->argc(1), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddCheck):
			l = node->hasArg(3) ? node->argi(3) : -1;
			t = node->hasArg(4) ? node->argi(4) : -1;
			xw = node->hasArg(5) ? node->argi(5) : 0;
			xh = node->hasArg(6) ? node->argi(6) : 0;
			rv.set(VTypes::WidgetData, ptr->addCheck(node->argc(0), node->argc(1), node->argi(2), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddCombo):
			l = node->hasArg(4) ? node->argi(4) : -1;
			t = node->hasArg(5) ? node->argi(5) : -1;
			xw = node->hasArg(6) ? node->argi(6) : 0;
			xh = node->hasArg(7) ? node->argi(7) : 0;
			rv.set(VTypes::WidgetData, ptr->addCombo(node->argc(0), node->argc(1), node->argc(2), node->argi(3), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddDoubleSpin):
			l = node->hasArg(6) ? node->argi(6) : -1;
			t = node->hasArg(7) ? node->argi(7) : -1;
			xw = node->hasArg(8) ? node->argi(8) : 0;
			xh = node->hasArg(9) ? node->argi(9) : 0;
			rv.set(VTypes::WidgetData, ptr->addDoubleSpin(node->argc(0), node->argc(1), node->argd(2), node->argd(3), node->argd(4), node->argd(5), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddEdit):
			l = node->hasArg(3) ? node->argi(3) : -1;
			t = node->hasArg(4) ? node->argi(4) : -1;
			xw = node->hasArg(5) ? node->argi(5) : 0;
			xh = node->hasArg(6) ? node->argi(6) : 0;
			rv.set(VTypes::WidgetData, ptr->addEdit(node->argc(0), node->argc(1), node->argc(2), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddFrame):
			l = node->hasArg(1) ? node->argi(1) : -1;
			t = node->hasArg(2) ? node->argi(2) : -1;
			xw = node->hasArg(3) ? node->argi(3) : 0;
			xh = node->hasArg(4) ? node->argi(4) : 0;
			rv.set(VTypes::WidgetData, ptr->addFrame(node->argc(0), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddGroup):
			l = node->hasArg(2) ? node->argi(2) : -1;
			t = node->hasArg(3) ? node->argi(3) : -1;
			xw = node->hasArg(4) ? node->argi(4) : 0;
			xh = node->hasArg(5) ? node->argi(5) : 0;
			rv.set(VTypes::WidgetData, ptr->addGroup(node->argc(0), node->argc(1), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddIntegerSpin):
			l = node->hasArg(6) ? node->argi(6) : -1;
			t = node->hasArg(7) ? node->argi(7) : -1;
			xw = node->hasArg(8) ? node->argi(8) : 0;
			xh = node->hasArg(9) ? node->argi(9) : 0;
			rv.set(VTypes::WidgetData, ptr->addIntegerSpin(node->argc(0), node->argc(1), node->argi(2), node->argi(3), node->argi(4), node->argi(5), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddLabel):
			l = node->hasArg(2) ? node->argi(2) : -1;
			t = node->hasArg(3) ? node->argi(3) : -1;
			xw = node->hasArg(4) ? node->argi(4) : 0;
			xh = node->hasArg(5) ? node->argi(5) : 0;
			rv.set(VTypes::WidgetData, ptr->addLabel(node->argc(0), node->argc(1), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddPage):
			rv.set(VTypes::WidgetData, ptr->addPage(node->argc(0), node->argc(1)));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddRadioButton):
			l = node->hasArg(4) ? node->argi(4) : -1;
			t = node->hasArg(5) ? node->argi(5) : -1;
			xw = node->hasArg(6) ? node->argi(6) : 0;
			xh = node->hasArg(7) ? node->argi(7) : 0;
			rv.set(VTypes::WidgetData, ptr->addRadioButton(node->argc(0), node->argc(1), node->argc(2), node->argi(3), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddRadioGroup):
			rv.set(VTypes::WidgetData, ptr->addRadioGroup(node->argc(0)));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddSpacer):
			l = node->hasArg(2) ? node->argi(2) : -1;
			t = node->hasArg(3) ? node->argi(3) : -1;
			xw = node->hasArg(4) ? node->argi(4) : 0;
			xh = node->hasArg(5) ? node->argi(5) : 0;
			if (!ptr->addSpacer(node->argb(0), node->argb(1), l, t, xw, xh))  result = false;
			rv.reset();
			break;
		case (WidgetVariable::AddStack):
			l = node->hasArg(1) ? node->argi(1) : -1;
			t = node->hasArg(2) ? node->argi(2) : -1;
			xw = node->hasArg(3) ? node->argi(3) : 0;
			xh = node->hasArg(4) ? node->argi(4) : 0;
			rv.set(VTypes::WidgetData, ptr->addStack(node->argc(0), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::AddTabs):
			l = node->hasArg(1) ? node->argi(1) : -1;
			t = node->hasArg(2) ? node->argi(2) : -1;
			xw = node->hasArg(3) ? node->argi(3) : 0;
			xh = node->hasArg(4) ? node->argi(4) : 0;
			rv.set(VTypes::WidgetData, ptr->addTabs(node->argc(0), l, t, xw, xh));
			if (rv.asPointer(VTypes::WidgetData) == NULL) result = false;
			break;
		case (WidgetVariable::OnDouble):
		case (WidgetVariable::OnInteger):
			rv.reset();
			// Check supplied parameters
			result = false;
			eventType = TreeGuiWidgetEvent::eventType(node->argc(2), true);
			if (eventType == TreeGuiWidgetEvent::nEventTypes) break;
			targetWidget = ptr->parent()->findWidget(node->argc(3));
			if (targetWidget == NULL)
			{
				Messenger::print("Error: No widget named '%s' is defined in the current dialog.", qPrintable(node->argc(3)));
				break;
			}
			eventProperty = TreeGuiWidgetEvent::eventProperty(node->argc(4), true);
			if (eventProperty == TreeGuiWidgetEvent::nEventProperties) break;
			event = ptr->addEvent(eventType, targetWidget, eventProperty);
			// Set qualifying value or range
			if (i == WidgetVariable::OnDouble) event->setQualifiers(node->argd(0), node->argd(1));
			else event->setQualifiers(node->argi(0), node->argi(1));
			// If a specific value(s) were supplied, store it. Otherwise the widget's current value will be sent
			if (node->hasArg(5))
			{
				// Can't set more than one value for an onDouble event
				if (i == WidgetVariable::OnDouble)
				{
					if (node->hasArg(6))
					{
						Messenger::print("Error: Can't set more than one send value for an 'onDouble' event.");
						result = false;
					}
					else
					{
						ReturnValue *sendValue = event->addSendValue();
						node->arg(5, *sendValue);
					}
				}
				else
				{
					// Values corresponding to each valid integer in the range may have been supplied
					int range = node->argi(1) - node->argi(0) + 1;
					for (int n = 0; n<range; ++n)
					{
						if (!node->hasArg(5+n)) break;
						ReturnValue *sendValue = event->addSendValue();
						node->arg(5+n, *sendValue);
					}
					// Check number of sendvalues supplied
					if ((event->nSendValues() != 1) && (event->nSendValues() != range))
					{
						Messenger::print("Error: %s values (%i) supplied to 'onRange' function, based on integer range provided (expected (%i).", (event->nSendValues() < range ? "Not enough" : "Too many"), event->nSendValues(), range);
						result = false;
						break;
					}
				}
			
			}
			result = true;
			break;
		case (WidgetVariable::OnString):
			rv.reset();
			// Check supplied parameters
			result = false;
			eventType = TreeGuiWidgetEvent::eventType(node->argc(1), true);
			if (eventType == TreeGuiWidgetEvent::nEventTypes) break;
			targetWidget = ptr->parent()->findWidget(node->argc(2));
			if (targetWidget == NULL)
			{
				Messenger::print("Error: No widget named '%s' is defined in the current dialog.", qPrintable(node->argc(2)));
				break;
			}
			eventProperty = TreeGuiWidgetEvent::eventProperty(node->argc(3), true);
			if (eventProperty == TreeGuiWidgetEvent::nEventProperties) break;
			event = ptr->addEvent(eventType, targetWidget, eventProperty);
			// Set qualifying value
			event->setQualifiers(node->argc(0));
			// If a specific value was supplied, store it. Otherwise the widget's current value will be sent
			if (node->hasArg(4))
			{
				ReturnValue *sendValue = event->addSendValue();
				node->arg(4, *sendValue);
			}
			result = true;
			break;
		case (WidgetVariable::SetProperty):
			eventProperty = TreeGuiWidgetEvent::eventProperty(node->argc(0), true);
			if (eventProperty == TreeGuiWidgetEvent::nEventProperties) break;
			if (node->argType(1) == VTypes::IntegerData) value.set(node->argi(1));
			else if (node->argType(1) == VTypes::DoubleData) value.set(node->argd(1));
			else value.set(node->argc(1));
			result = ptr->setProperty(eventProperty, value);
			break;
		default:
			printf("Internal Error: Access to function '%s' has not been defined in WidgetVariable.\n", qPrintable(functionData[i].name));
			result = false;
			break;
	}
	Messenger::exit("WidgetVariable::performFunction");
	return result;
}