ObjectPtr ScalarDialog::createNewGeneratedScalar(){ bool ok = false; Q_ASSERT(_document && _document->objectStore()); double value = _scalarTab->value().toDouble(&ok); if (!ok) { value = Equations::interpret(_document->objectStore(), _scalarTab->value().toLatin1(), &ok); } if (!ok) { return 0; //invalid } ScalarPtr scalar = _document->objectStore()->createObject<Scalar>(); scalar->setValue(value); scalar->setOrphan(true); scalar->setEditable(true); if (DataDialog::tagStringAuto()) { scalar->setDescriptiveName(QString()); } else { scalar->setDescriptiveName(DataDialog::tagString()); } scalar->writeLock(); scalar->registerChange(); scalar->unlock(); _dataObjectName = scalar->Name(); return static_cast<ObjectPtr>(scalar); }
// If a plugin provides a Parameters Vector, then scalars will be created, as well as a label. void BasicPlugin::createScalars() { // Assumes that this is called with a write lock in place on this object Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED); if (hasParameterVector()) { VectorPtr vectorParam = _outputVectors["Parameters Vector"]; if (vectorParam) { QString paramName; int i = 0; int length = vectorParam->length(); Q_ASSERT(store()); for (paramName = parameterName(i); !paramName.isEmpty() && i < length; paramName = parameterName(++i)) { double scalarValue = vectorParam->value(i); if (!_outputScalars.contains(paramName)) { ScalarPtr s = store()->createObject<Scalar>(); s->setProvider(this); s->setSlaveName(paramName); s->setValue(scalarValue); s->writeLock(); _outputScalars.insert(paramName, s); } else { _outputScalars[paramName]->setValue(scalarValue); } } } } }
void BasicPlugin::setOutputScalar(const QString &type, const QString &name) { QString txt = !name.isEmpty() ? name : type; Q_ASSERT(store()); ScalarPtr s = store()->createObject<Scalar>(); s->setProvider(this); s->setSlaveName(txt); _outputScalars.insert(type, s); }
QString DataObjectSI::outputScalar(QString& command) { QString key = getArg(command); ScalarPtr xout = _dataObject->outputScalar(key); if (xout) { return xout->shortName(); } else { return "Invalid"; } }
void Vector::CreateScalars(ObjectStore *store) { if (!_isScalarList) { _min = _max = _mean = _minPos = 0.0; Q_ASSERT(store); ScalarPtr sp; _scalars.insert("max", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Max"); _scalars.insert("min", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Min"); _scalars.insert("last", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Last"); _scalars.insert("first", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("First"); _scalars.insert("mean", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Mean"); _scalars.insert("sigma", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Sigma"); _scalars.insert("rms", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Rms"); _scalars.insert("ns", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("NS"); _scalars.insert("sum", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Sum"); _scalars.insert("sumsquared", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("SumSquared"); _scalars.insert("minpos", sp = store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("MinPos"); } }
foreach (ScalarPtr s, objectStore()->getObjects<Scalar>()) { s->save(xml); }
foreach (ScalarPtr P, _inputScalars) { minSerial = qMin(minSerial, P->serial()); }
void Matrix::createScalars(ObjectStore *store) { Q_ASSERT(store); ScalarPtr sp; VectorPtr vp; _scalars.insert("max", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Max"); _scalars.insert("min", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Min"); _scalars.insert("mean", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Mean"); _scalars.insert("sigma", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Sigma"); _scalars.insert("rms", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Rms"); _scalars.insert("ns", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("NS"); _scalars.insert("sum", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("Sum"); _scalars.insert("sumsquared", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("SumSquared"); _scalars.insert("minpos", sp=store->createObject<Scalar>()); sp->setProvider(this); sp->setSlaveName("MinPos"); _vectors.insert("z", vp = store->createObject<Vector>()); vp->setProvider(this); vp->setSlaveName("Z"); }
foreach (const ScalarPtr &P, ScalarsUsed) { minSerial = qMin(minSerial, P->serial()); }