예제 #1
0
void AtenWindow::on_SelectIntelligentRemoveButton_clicked(bool checked)
{
	// Which selection are we going to try to perform?
	AtenWindow::SelectTargetType selectType = (AtenWindow::SelectTargetType) ui.SelectIntelligentTypeCombo->currentIndex();
	if (selectType == AtenWindow::AutoSelectType) selectType = lastSelectionType_;

	ReturnValue rv;

	switch (selectType)
	{
		case (AtenWindow::RangeSelectType):
			CommandNode::run(Commands::DeSelect, "c", qPrintable(ui.SelectIntelligentTargetCombo->currentText()));
			break;
		case (AtenWindow::NETASelectType):
			// Get element
			if (!ui.SelectIntelligentElementButton->callPopupMethod("currentElement", rv)) return;
			if (rv.asInteger() == 0) Messenger::print("Invalid element.'");
			else CommandNode::run(Commands::DeSelectType, "ic", rv.asInteger(), qPrintable(ui.SelectIntelligentTargetCombo->currentText()));
			break;
		case (AtenWindow::LoopSelectType):
			CommandNode::run(Commands::DeSelectCode, "c", qPrintable(ui.SelectIntelligentTargetCombo->currentText()));
			break;
    default:
      break;
	}

	updateWidgets(AtenWindow::AtomsTableTarget);
}
예제 #2
0
파일: matrix.cpp 프로젝트: alinelena/aten
// Initialise array
bool MatrixArrayVariable::initialise()
{
	// We define our own initialise() function to take over from the inherited default from Variable
	// Get size of array to create
	ReturnValue newsize;
	if (!arraySizeExpression_->execute(newsize))
	{
		Messenger::print("Failed to find size for matrix array '%s'.", qPrintable(name_));
		return false;
	}
	// If the array is already allocated, free it only if the size is different
	if ((arraySize_ != newsize.asInteger()) && (matrixArrayData_ != NULL)) { delete[] matrixArrayData_; matrixArrayData_ = NULL; }
	// Store new array size
	arraySize_ = newsize.asInteger();
	if ((arraySize_ > 0) && (matrixArrayData_ == NULL)) matrixArrayData_ = new Matrix[arraySize_];
	if (initialValue_ == NULL) reset();
	else
	{
		ReturnValue rv;
		if (initialValue_->execute(rv))
		{
			if (!set(rv)) return false;
		}
		else return false;
	}
	return true;
}
예제 #3
0
// Call named method associated to popup
bool ElementTablePopup::callMethod(QString methodName, ReturnValue& rv)
{
	bool result = true;
	if (methodName == "TEST") return true;
	else if (methodName == "currentElement")
	{
		rv = currentElement_;
		return true;
	}
	else if (methodName == "setCurrentElement")
	{
		currentElement_ = rv.asInteger();

		// Set icon on parent button
		parentMenuButton()->setIcon(ElementMap::icon(currentElement_));

		return true;
	}
	else if (methodName == "hideEvent")
	{
		return true;
	}
	else
	{
		printf("No method called '%s' is available in this popup.\n", qPrintable(methodName));
		result = false;
	}
	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
// 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;
}