Пример #1
0
bool BioXASBeamlineComponent::canStop() const
{
	bool result = false;

	// This control can stop if all controls are valid and
	// all children that can move can also be stopped.

	if (isConnected()) {

		QList<AMControl*> children = childControls();

		if (children.count() > 0) {

			bool childrenValid = true;
			bool childrenStoppable = true;

			for (int i = 0, count = children.count(); i < count && childrenValid && childrenStoppable; i++) { // We want to stop if we come across either a null child or a child that can move but can't be stopped.
				bool childValid = false;
				bool childStoppable = false;

				AMControl *child = childControlAt(i);

				if (child) {
					childValid = true;

					if (!child->canMove())
						childStoppable = true;
					else if (child->canMove() && child->canStop())
						childStoppable = true;
					else
						childStoppable = false;
				}

				childrenValid &= childValid;
				childrenStoppable &= childStoppable;
			}

			result = childrenValid && childrenStoppable;
		}
	}

	return result;
}
Пример #2
0
/// Loops through the children of the control, makes an AMControlStatus for each, and appends it to the list.
/// If the child has children, then an AMControlState is made for the child, added to the index paired list.
/// By creating the AMControlState, the searchChildren is effectively called recursively.
bool AMControlState::searchChildren(AMControl *ctrl)
{
	QString tmpName = "";
	int tmpCan = 0;
	int tmpShould = 0;
	double tmpValue = -1;
	double tmpTolerance = 0;
	AMControl *tmpCtrl = NULL;
	AMControlStatus *tmpStatus = NULL;
	for(int x = 0; x < ctrl->childControlCount(); x++){
		tmpCtrl = ctrl->childControlAt(x);
		tmpName = tmpCtrl->objectName();
		tmpValue = tmpCtrl->value();
		tmpTolerance = tmpCtrl->tolerance();
		tmpCan = (tmpCtrl->canMeasure() & 1) | (tmpCtrl->canMove() & 2);	// TODO TODO TODO
//        tmpShould = tmpCtrl->shouldMeasure() ? (tmpCtrl->shouldMove() ? 2 : 1) : 0;
		tmpShould = tmpCtrl->shouldMeasure() ? 1 : 0;
		tmpShould |= tmpCtrl->shouldMove() ? 2 : 0;
		tmpStatus = new AMControlStatus(tmpName, tmpCan, tmpShould, tmpValue, tmpTolerance, this);
		state_.append( tmpStatus );
		if(tmpCtrl->childControlCount() > 0 ){
			AMControlState *ctrlSt = new AMControlState(tmpCtrl, this);
			subState_.append( QPair<int, AMControlState*>(x, ctrlSt));
		}
	}
/*
	QString tmpStr = "";
	for(int x = 0; x < ctrl->numChildren(); x++){
		tmpStr.setNum(ctrl->child(x)->value());
		state_.append(QPair<QString, QString>(ctrl->child(x)->objectName(), tmpStr));
		if(ctrl->child(x)->numChildren() > 0 ){
			AMControlState *ctrlSt = new AMControlState(ctrl->child(x), this);
			subState_.append( QPair<int, AMControlState*>(x, ctrlSt));
		}
	}
*/
	if(ctrl->childControlCount() > 0)
		return TRUE;
	return FALSE;
}