本文整理汇总了C++中KstCPluginPtr类的典型用法代码示例。如果您正苦于以下问题:C++ KstCPluginPtr类的具体用法?C++ KstCPluginPtr怎么用?C++ KstCPluginPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KstCPluginPtr类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeDuplicate
KstDataObjectPtr KstCPlugin::makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap) {
KstCPluginPtr plugin = new KstCPlugin;
// use same inputs
for (KstVectorMap::ConstIterator iter = _inputVectors.begin(); iter != _inputVectors.end(); ++iter) {
plugin->inputVectors().insert(iter.key(), iter.data());
}
for (KstScalarMap::ConstIterator iter = _inputScalars.begin(); iter != _inputScalars.end(); ++iter) {
plugin->inputScalars().insert(iter.key(), iter.data());
}
for (KstStringMap::ConstIterator iter = _inputStrings.begin(); iter != _inputStrings.end(); ++iter) {
plugin->inputStrings().insert(iter.key(), iter.data());
}
// create new outputs
for (KstVectorMap::ConstIterator iter = outputVectors().begin(); iter != outputVectors().end(); ++iter) {
KstWriteLocker blockVectorUpdates(&KST::vectorList.lock());
KstVectorPtr v = new KstVector(KstObjectTag(iter.data()->tag().tag() + "'", iter.data()->tag().context()), 0, plugin.data()); // FIXME: unique tag generation
plugin->outputVectors().insert(iter.key(), v);
}
for (KstScalarMap::ConstIterator iter = outputScalars().begin(); iter != outputScalars().end(); ++iter) {
KstScalarPtr s = new KstScalar(KstObjectTag(iter.data()->tag().tag() + "'", iter.data()->tag().context()), plugin.data()); // FIXME: unique tag generation
plugin->outputScalars().insert(iter.key(), s);
}
for (KstStringMap::ConstIterator iter = outputStrings().begin(); iter != outputStrings().end(); ++iter) {
KstStringPtr s = new KstString(KstObjectTag(iter.data()->tag().tag() + "'", iter.data()->tag().context()), plugin.data()); // FIXME: unique tag generation
plugin->outputStrings().insert(iter.key(), s);
}
// set the same plugin
plugin->setPlugin(_plugin);
plugin->setTagName(KstObjectTag(tag().tag() + "'", tag().context())); // FIXME: unique tag generation method
duplicatedMap.insert(this, KstDataObjectPtr(plugin));
return KstDataObjectPtr(plugin);
}
示例2: fillFieldsForEdit
void KstPluginDialogI::fillFieldsForEdit() {
KstCPluginPtr pp = kst_cast<KstCPlugin>(_dp);
if (!pp) {
return;
}
pp->readLock();
if (!pp->plugin()) { // plugin() can be null if the kst file is invalid
pp->unlock();
return;
}
const QString pluginName(pp->tagName());
const QString pluginObjectName(pp->plugin()->data()._name);
const int usage = pp->getUsage();
KstSharedPtr<Plugin> plug = pp->plugin();
pp->unlock();
_tagName->setText(pluginName);
updatePluginList();
int i = _pluginList.findIndex(pluginObjectName);
_w->PluginCombo->setCurrentItem(i);
pluginChanged(_w->PluginCombo->currentItem());
fillVectorScalarCombos(plug);
_w->PluginCombo->setEnabled(usage < 3);
fixupLayout();
}
示例3: newObject
bool KstPluginDialogI::newObject() {
QString tagName = _tagName->text();
if (tagName != plugin_defaultTag && KstData::self()->dataTagNameNotUnique(tagName, true, this)) {
_tagName->setFocus();
return false;
}
KstCPluginPtr plugin;
int pitem = _w->PluginCombo->currentItem();
if (pitem >= 0 && _w->PluginCombo->count() > 0) {
KstSharedPtr<Plugin> pPtr = PluginCollection::self()->plugin(_pluginList[pitem]);
if (pPtr) {
plugin = new KstCPlugin;
plugin->writeLock();
if (!saveInputs(plugin, pPtr)) {
KMessageBox::sorry(this, i18n("One or more of the inputs was undefined."));
plugin->unlock();
plugin = 0L;
return false;
}
plugin->setPlugin(pPtr);
if (tagName == plugin_defaultTag) {
tagName = KST::suggestPluginName(_pluginList[pitem]);
}
plugin->setTagName(tagName);
if (!saveOutputs(plugin, pPtr)) {
KMessageBox::sorry(this, i18n("One or more of the outputs was undefined."));
plugin->unlock();
plugin = 0L;
return false;
}
plugin->unlock();
}
}
if (!plugin || !plugin->isValid()) {
KMessageBox::sorry(this, i18n("There is an error in the plugin you entered."));
return false;
}
plugin->setDirty();
KST::dataObjectList.lock().writeLock();
KST::dataObjectList.append(plugin.data());
KST::dataObjectList.lock().unlock();
plugin = 0L;
emit modified();
return true;
}
示例4: saveInputs
bool KstPluginDialogI::saveInputs(KstCPluginPtr plugin, KstSharedPtr<Plugin> p) {
bool rc = true;
const QValueList<Plugin::Data::IOValue>& itable = p->data()._inputs;
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = itable.begin(); it != itable.end(); ++it) {
if ((*it)._type == Plugin::Data::IOValue::TableType) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "VectorSelector");
assert(field);
VectorSelector *vs = static_cast<VectorSelector*>(field);
KstReadLocker vl(&KST::vectorList.lock());
KstVectorPtr v = *KST::vectorList.findTag(vs->selectedVector());
if (v) {
plugin->inputVectors().insert((*it)._name, v);
} else if (plugin->inputVectors().contains((*it)._name)) {
plugin->inputVectors().erase((*it)._name);
rc = false;
}
} else if ((*it)._type == Plugin::Data::IOValue::StringType) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "StringSelector");
assert(field);
StringSelector *ss = static_cast<StringSelector*>(field);
KstWriteLocker sl(&KST::stringList.lock());
KstStringPtr s = *KST::stringList.findTag(ss->selectedString());
if (s == *KST::stringList.end()) {
QString val = ss->_string->currentText();
KstStringPtr newString = new KstString(KstObjectTag::fromString(ss->_string->currentText()), 0L, val, true);
if (!newString) {
rc = false;
}
plugin->inputStrings().insert((*it)._name, newString);
} else {
plugin->inputStrings().insert((*it)._name, s);
}
} else if ((*it)._type == Plugin::Data::IOValue::PidType) {
// Nothing
} else if ((*it)._type == Plugin::Data::IOValue::FloatType) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "ScalarSelector");
assert(field);
ScalarSelector *ss = static_cast<ScalarSelector*>(field);
KstWriteLocker sl(&KST::scalarList.lock());
KstScalarPtr s = *KST::scalarList.findTag(ss->selectedScalar());
if (s == *KST::scalarList.end()) {
bool ok;
double val = ss->_scalar->currentText().toDouble(&ok);
if (ok) {
KstScalarPtr newScalar = new KstScalar(KstObjectTag::fromString(ss->_scalar->currentText()), 0L, val, true, false);
plugin->inputScalars().insert((*it)._name, newScalar);
} else {
rc = false;
}
} else {
plugin->inputScalars().insert((*it)._name, s);
}
} else {
}
}
return rc;
}
示例5: fillComboBox
void KstViewFitsDialog::fillComboBox(const QString& str) {
KstCPluginList::iterator it;
KstCPluginList fits;
QString fitName = str;
bool changed = false;
uint i;
_comboBoxFits->clear();
fits = kstObjectSubList<KstDataObject,KstCPlugin>(KST::dataObjectList);
for (it = fits.begin(); it != fits.end(); ++it) {
KstCPluginPtr fit;
fit = *it;
fit->readLock();
if (fit->plugin()->data()._isFit) {
_comboBoxFits->insertItem(0, fit->tagName());
if (fitName == fit->tagName() || fitName.isEmpty()) {
_comboBoxFits->setCurrentIndex(_comboBoxFits->count() - 1);
if (fitName.isEmpty()) {
fitName = fit->tagName();
}
changed = true;
fitChanged(fitName);
}
}
fit->unlock();
}
if (!changed) {
fitChanged(_comboBoxFits->currentText());
}
}
示例6: editObject
bool KstPluginDialogI::editObject() {
KstCPluginPtr pp = kst_cast<KstCPlugin>(_dp);
if (!pp) { // something is dreadfully wrong - this should never happen
return false;
}
KstWriteLocker pl(pp);
if (_tagName->text() != pp->tagName() && KstData::self()->dataTagNameNotUnique(_tagName->text())) {
_tagName->setFocus();
return false;
}
pp->setTagName(KstObjectTag(_tagName->text(), KstObjectTag::globalTagContext)); // FIXME: tag context always global?
int pitem = _w->PluginCombo->currentIndex();
KstSharedPtr<Plugin> pPtr = PluginCollection::self()->plugin(_pluginList[pitem]);
pp->inputVectors().clear();
pp->inputScalars().clear();
pp->inputStrings().clear();
// Save the vectors and scalars
if (!saveInputs(pp, pPtr)) {
KMessageBox::sorry(this, i18n("There is an error in the inputs you entered."));
return false;
}
if (pitem >= 0 && _w->PluginCombo->count() > 0) {
pp->setPlugin(pPtr);
}
if (!saveOutputs(pp, pPtr)) {
KMessageBox::sorry(this, i18n("There is an error in the outputs you entered."));
return false;
}
if (!pp->isValid()) {
KMessageBox::sorry(this, i18n("There is an error in the plugin you entered."));
return false;
}
pp->setDirty();
emit modified();
return true;
}
示例7: createCurve
bool KstFilterDialogI::createCurve(KstCPluginPtr plugin) {
KstVectorPtr xVector;
KstVectorPtr yVector;
KST::vectorList.lock().readLock();
KstVectorList::Iterator it = KST::vectorList.findTag(_xvector);
if (it != KST::vectorList.end()) {
xVector = *it;
}
KST::vectorList.lock().unlock();
if (plugin->outputVectors().contains(plugin->plugin()->data()._filterOutputVector)) {
yVector = plugin->outputVectors()[plugin->plugin()->data()._filterOutputVector];
}
if (!xVector || !yVector) {
return false;
}
plugin->setDirty();
QString c_name = KST::suggestCurveName(plugin->tag(), true);
QColor color = KstApp::inst()->chooseColorDlg()->getColorForCurve(KstVectorPtr(xVector), KstVectorPtr(yVector));
if (!color.isValid()) {
color = _w->_curveAppearance->color();
}
KstVCurvePtr fit = new KstVCurve(c_name, KstVectorPtr(xVector), KstVectorPtr(yVector), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), color);
fit->setHasPoints(_w->_curveAppearance->showPoints());
fit->setHasLines(_w->_curveAppearance->showLines());
fit->setHasBars(_w->_curveAppearance->showBars());
fit->setLineWidth(_w->_curveAppearance->lineWidth());
fit->setLineStyle(_w->_curveAppearance->lineStyle());
fit->setPointStyle(_w->_curveAppearance->pointType());
fit->setBarStyle(_w->_curveAppearance->barStyle());
fit->setPointDensity(_w->_curveAppearance->pointDensity());
KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_window));
if (w && w->view()->findChild(_plotName)) {
Kst2DPlotPtr plot = kst_cast<Kst2DPlot>(w->view()->findChild(_plotName));
if (plot) {
plot->addCurve(fit.data());
}
}
KST::dataObjectList.lock().writeLock();
KST::dataObjectList.append(fit.data());
KST::dataObjectList.lock().unlock();
return true;
}
示例8: saveOutputs
bool KstPluginDialogI::saveOutputs(KstCPluginPtr plugin, KstSharedPtr<Plugin> p) {
const QValueList<Plugin::Data::IOValue>& otable = p->data()._outputs;
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = otable.begin(); it != otable.end(); ++it) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "QLineEdit");
if (!field) {
continue; // Some are unsupported
}
QLineEdit *li = static_cast<QLineEdit*>(field);
if (li->text().isEmpty()) {
li->setText((*it)._name);
}
QString nt = li->text();
if ((*it)._type == Plugin::Data::IOValue::TableType) {
if (!KstData::self()->vectorTagNameNotUnique(nt, false)) {
// Implicitly creates it if it doesn't exist
KstVectorPtr v = plugin->outputVectors()[(*it)._name];
if (!v) {
KstWriteLocker blockVectorUpdates(&KST::vectorList.lock());
v = new KstVector(KstObjectTag(nt, plugin->tag()), 0, plugin.data());
plugin->outputVectors().insert((*it)._name, v);
}
v->setTagName(KstObjectTag(nt, plugin->tag()));
} else if (plugin->outputVectors()[(*it)._name]->tagName() != nt) {
while (KstData::self()->vectorTagNameNotUnique(nt, false)) {
nt += "'";
}
KstVectorPtr v;
if (plugin->outputVectors().contains((*it)._name)) {
v = plugin->outputVectors()[(*it)._name];
} else {
KstWriteLocker blockVectorUpdates(&KST::vectorList.lock());
v = new KstVector(KstObjectTag(nt, plugin->tag()), 0, plugin.data());
plugin->outputVectors().insert((*it)._name, v);
}
v->setTagName(KstObjectTag(nt, plugin->tag()));
}
} else if ((*it)._type == Plugin::Data::IOValue::StringType) {
if (!KstData::self()->vectorTagNameNotUnique(nt, false)) {
KstStringPtr s;
if (plugin->outputStrings().contains((*it)._name)) {
s = plugin->outputStrings()[(*it)._name];
} else {
KstWriteLocker blockStringUpdates(&KST::stringList.lock());
s = new KstString(KstObjectTag(nt, plugin->tag()), plugin.data());
plugin->outputStrings().insert((*it)._name, s);
}
s->setTagName(KstObjectTag(nt, plugin->tag()));
} else if (plugin->outputStrings()[(*it)._name]->tagName() != nt) {
while (KstData::self()->vectorTagNameNotUnique(nt, false)) {
nt += "'";
}
KstStringPtr s;
if (plugin->outputStrings().contains((*it)._name)) {
s = plugin->outputStrings()[(*it)._name];
} else {
KstWriteLocker blockStringUpdates(&KST::stringList.lock());
s = new KstString(KstObjectTag(nt, plugin->tag()), plugin.data());
plugin->outputStrings().insert((*it)._name, s);
}
s->setTagName(KstObjectTag(nt, plugin->tag()));
}
} else if ((*it)._type == Plugin::Data::IOValue::PidType) {
// Nothing
} else if ((*it)._type == Plugin::Data::IOValue::FloatType) {
if (!KstData::self()->vectorTagNameNotUnique(nt, false)) {
KstScalarPtr s;
if (plugin->outputScalars().contains((*it)._name)) {
s = plugin->outputScalars()[(*it)._name];
} else {
KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
s = new KstScalar(KstObjectTag(nt, plugin->tag()), plugin.data());
plugin->outputScalars().insert((*it)._name, s);
}
s->setTagName(KstObjectTag(nt, plugin->tag()));
} else if (plugin->outputScalars()[(*it)._name]->tagName() != nt) {
while (KstData::self()->vectorTagNameNotUnique(nt, false)) {
nt += "'";
}
KstScalarPtr s;
if (plugin->outputScalars().contains((*it)._name)) {
s = plugin->outputScalars()[(*it)._name];
} else {
KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
s = new KstScalar(KstObjectTag(nt, plugin->tag()), plugin.data());
plugin->outputScalars().insert((*it)._name, s);
}
s->setTagName(KstObjectTag(nt, plugin->tag()));
}
}
}
return true;
}
示例9: fillVectorScalarCombos
void KstPluginDialogI::fillVectorScalarCombos(KstSharedPtr<Plugin> plugin) {
bool DPvalid = false;
KstCPluginPtr pp = kst_cast<KstCPlugin>(_dp);
if (pp) {
pp->readLock();
DPvalid = pp->isValid();
pp->unlock();
}
if (plugin) {
if (DPvalid) {
pp->readLock();
}
// Update input vector and scalar combos
const QValueList<Plugin::Data::IOValue>& itable = plugin->data()._inputs;
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = itable.begin();
it != itable.end(); ++it) {
if ((*it)._type == Plugin::Data::IOValue::TableType) { // vector
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "VectorSelector");
assert(field);
if (field) {
VectorSelector *vs = static_cast<VectorSelector*>(field);
QString selectedVector = vs->selectedVector();
vs->update();
if (DPvalid) {
vs->setSelection(pp->inputVectors()[(*it)._name]->tag().displayString());
} else {
vs->setSelection(selectedVector);
}
}
} else if ((*it)._type == Plugin::Data::IOValue::StringType) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "StringSelector");
assert(field);
if (field) {
StringSelector *ss = static_cast<StringSelector*>(field);
QString selectedString = ss->selectedString();
ss->update();
if (DPvalid) {
ss->setSelection(pp->inputStrings()[(*it)._name]->tag().displayString());
} else {
ss->setSelection(selectedString);
}
}
} else if ((*it)._type == Plugin::Data::IOValue::PidType) {
// Nothing
} else {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "ScalarSelector");
assert(field);
if (field) {
ScalarSelector *ss = static_cast<ScalarSelector*>(field);
QString selectedScalar = ss->selectedScalar();
ss->update();
if (DPvalid) {
ss->setSelection(pp->inputScalars()[(*it)._name]->tag().displayString());
} else {
ss->setSelection(selectedScalar);
}
}
}
}
// Update output vector and scalar lineedits
if (DPvalid) {
const QValueList<Plugin::Data::IOValue>& otable = plugin->data()._outputs;
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = otable.begin(); it != otable.end(); ++it) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "QLineEdit");
assert(field);
if (field) {
QLineEdit *li = static_cast<QLineEdit*>(field);
QString ts;
if ((*it)._type == Plugin::Data::IOValue::TableType) { // vector
ts = pp->outputVectors()[(*it)._name]->tagName();
} else if ((*it)._type == Plugin::Data::IOValue::PidType) {
} else if ((*it)._type == Plugin::Data::IOValue::StringType) {
ts = pp->outputStrings()[(*it)._name]->tagName();
} else { // scalar
ts = pp->outputScalars()[(*it)._name]->tagName();
}
li->setText(ts);
}
}
pp->unlock();
}
} else { // invalid plugin
PluginCollection *pc = PluginCollection::self();
QString cur = _pluginList[_w->PluginCombo->currentItem()];
Plugin::Data pdata = pc->pluginList()[pc->pluginNameList()[cur]];
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = pdata._outputs.begin(); it != pdata._outputs.end(); ++it) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "QLineEdit");
if (field) {
static_cast<QLineEdit*>(field)->setText(QString::null);
}
}
}
}
示例10: saveInputs
bool KstFilterDialogI::saveInputs(KstCPluginPtr plugin, KstSharedPtr<Plugin> p) {
KST::vectorList.lock().readLock();
KST::scalarList.lock().writeLock();
KST::stringList.lock().writeLock();
const QValueList<Plugin::Data::IOValue>& itable = p->data()._inputs;
for (QValueList<Plugin::Data::IOValue>::ConstIterator it = itable.begin(); it != itable.end(); ++it) {
if ((*it)._type == Plugin::Data::IOValue::TableType) {
if ((*it)._name == p->data()._filterInputVector) {
KstVectorPtr v = *KST::vectorList.findTag(_yvector);
plugin->inputVectors().insert((*it)._name, v);
} else {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "VectorSelector");
if (field) {
VectorSelector *vs = static_cast<VectorSelector*>(field);
KstVectorPtr v = *KST::vectorList.findTag(vs->selectedVector());
plugin->inputVectors().insert((*it)._name, v);
}
}
} else if ((*it)._type == Plugin::Data::IOValue::StringType) {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "StringSelector");
if (field) {
StringSelector *ss = static_cast<StringSelector*>(field);
KstStringPtr s = *KST::stringList.findTag(ss->selectedString());
if (s == *KST::stringList.end()) {
QString val = ss->_string->currentText();
// create orphan string
KstStringPtr newString = new KstString(KstObjectTag(ss->_string->currentText(), KstObjectTag::orphanTagContext), 0L, val, true);
plugin->inputStrings().insert((*it)._name, newString);
} else {
plugin->inputStrings().insert((*it)._name, s);
}
}
} else if ((*it)._type == Plugin::Data::IOValue::PidType) {
// Nothing
} else {
QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "ScalarSelector");
if (field) {
ScalarSelector *ss = static_cast<ScalarSelector*>(field);
KstScalarPtr s = *KST::scalarList.findTag(ss->selectedScalar());
if (s == *KST::scalarList.end()) {
bool ok;
double val = ss->_scalar->currentText().toDouble(&ok);
if (ok) {
// create orphan scalar
KstScalarPtr newScalar = new KstScalar(KstObjectTag(ss->_scalar->currentText(), KstObjectTag::orphanTagContext), 0L, val, true, false);
plugin->inputScalars().insert((*it)._name, newScalar);
} else {
plugin->inputScalars().insert((*it)._name, s);
}
} else {
plugin->inputScalars().insert((*it)._name, s);
}
}
}
}
KST::stringList.lock().unlock();
KST::scalarList.lock().unlock();
KST::vectorList.lock().unlock();
return true;
}
示例11: renderLabel
void renderLabel(RenderContext& rc, Label::Chunk *fi) {
// FIXME: RTL support
int oldSize = rc.size;
int oldY = rc.y;
int oldX = rc.x;
while (fi) {
if (fi->vOffset != Label::Chunk::None) {
if (fi->vOffset == Label::Chunk::Up) {
rc.y -= int(0.4 * rc.fontHeight());
} else { // Down
rc.y += int(0.4 * rc.fontHeight());
}
if (rc.size > 5) {
rc.size = (rc.size*2)/3;
}
}
QFont f = rc.font();
if (rc.fontSize() != rc.size) {
f.setPointSize(rc.size);
}
f.setBold(fi->attributes.bold);
f.setItalic(fi->attributes.italic);
f.setUnderline(fi->attributes.underline);
if (rc.p && fi->attributes.color.isValid()) {
rc.p->setPen(fi->attributes.color);
} else if (rc.p) {
rc.p->setPen(rc.pen);
}
rc.setFont(f);
if (fi->linebreak) {
rc.x = oldX;
rc.y += rc.fontAscent() + rc.fontDescent() + 1;
fi = fi->next;
continue;
}
if (!rc.substitute && (fi->scalar || fi->vector)) {
QString txt = QString("[") + fi->text + "]";
if (rc.p) {
rc.p->drawText(rc.x, rc.y, txt);
}
rc.x += rc.fontWidth(txt);
} else if (fi->scalar) {
// do scalar/string/fit substitution
QString txt;
if (!fi->text.isEmpty() && fi->text[0] == '=') {
// Parse and evaluate as an equation
bool ok = false;
const QString s = fi->text.mid(1);
const double eqResult(Equation::interpret(s.toLatin1(), &ok, s.length()));
txt = QString::number(eqResult, 'g', rc.precision);
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRExpression, fi->text, QString::null, 0.0, QVariant(eqResult)));
}
} else {
KST::scalarList.lock().readLock();
KstScalarPtr scp = KST::scalarList.retrieveObject(KstObjectTag::fromString(fi->text));
KST::scalarList.lock().unlock();
if (scp) {
scp->readLock();
txt = QString::number(scp->value(), 'g', rc.precision);
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRScalar, fi->text, QString::null, 0.0, QVariant(scp->value())));
}
scp->unlock();
} else {
KST::stringList.lock().readLock();
KstStringPtr stp = KST::stringList.retrieveObject(KstObjectTag::fromString(fi->text));
KST::stringList.lock().unlock();
if (stp) {
stp->readLock();
txt = stp->value();
if (rc._cache) {
rc._cache->append(DataRef(DataRef::DRString, fi->text, QString::null, 0.0, QVariant(stp->value())));
}
stp->unlock();
} else {
KST::dataObjectList.lock().readLock();
KstDataObjectList::Iterator oi = KST::dataObjectList.findTag(fi->text);
KST::dataObjectList.lock().unlock();
if (oi != KST::dataObjectList.end()) {
KstCPluginPtr fit = kst_cast<KstCPlugin>(*oi);
if (fit) {
fit->readLock();
const QString txtAll = fit->label(rc.precision);
fit->unlock();
const Q3ValueList<QString> strList = txtAll.split('\n');
Q3ValueListConstIterator<QString> last = --(strList.end());
for (Q3ValueListConstIterator<QString> iter = strList.begin(); iter != strList.end(); ++iter) {
txt = (*iter);
if (iter != last) {
if (rc.p) {
rc.p->drawText(rc.x, rc.y, txt);
} else {
//.........这里部分代码省略.........
示例12: switch
void KstViewLabel::DataCache::update() {
for (QValueVector<DataRef>::ConstIterator i = data.begin(); valid && i != data.end(); ++i) {
switch ((*i).type) {
case DataRef::DataRef::DRScalar:
{
KST::scalarList.lock().readLock();
KstScalarPtr p = *KST::scalarList.findTag((*i).name);
KST::scalarList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value()) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DRString:
{
KST::stringList.lock().readLock();
KstStringPtr p = *KST::stringList.findTag((*i).name);
KST::stringList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value()) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DRExpression:
{
bool ok = false;
const double val = Equation::interpret((*i).name.latin1(), &ok, (*i).name.length());
if (QVariant(val) != (*i).value) {
valid = false;
}
}
break;
case DataRef::DRVector:
{
bool ok = false;
const double idx = Equation::interpret((*i).index.latin1(), &ok, (*i).index.length());
if (idx != (*i).indexValue) {
valid = false;
break;
}
KST::vectorList.lock().readLock();
KstVectorPtr p = *KST::vectorList.findTag((*i).name);
KST::vectorList.lock().unlock();
if (p) {
p->readLock();
if (QVariant(p->value(int((*i).indexValue))) != (*i).value) {
valid = false;
}
p->unlock();
}
}
break;
case DataRef::DataRef::DRFit:
{
KST::dataObjectList.lock().readLock();
KstDataObjectList::Iterator oi = KST::dataObjectList.findTag((*i).name);
KST::dataObjectList.lock().unlock();
if (oi != KST::dataObjectList.end()) {
KstCPluginPtr fit = kst_cast<KstCPlugin>(*oi);
if (fit) {
fit->readLock();
if (fit->label((int)((*i).indexValue)) != (*i).index) {
valid = false;
}
fit->unlock();
}
}
}
break;
}
}
}
示例13: makeDuplicate
KstDataObjectPtr KstCPlugin::makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap) {
KstCPluginPtr plugin = new KstCPlugin;
// use same inputs
for (KstVectorMap::ConstIterator iter = _inputVectors.begin(); iter != _inputVectors.end(); ++iter) {
plugin->inputVectors().insert(iter.key(), iter.data());
}
for (KstScalarMap::ConstIterator iter = _inputScalars.begin(); iter != _inputScalars.end(); ++iter) {
plugin->inputScalars().insert(iter.key(), iter.data());
}
for (KstStringMap::ConstIterator iter = _inputStrings.begin(); iter != _inputStrings.end(); ++iter) {
plugin->inputStrings().insert(iter.key(), iter.data());
}
// create new outputs
for (KstVectorMap::ConstIterator iter = outputVectors().begin(); iter != outputVectors().end(); ++iter) {
KstVectorPtr v = new KstVector(iter.data()->tagName() + "'", 0, plugin.data());
plugin->outputVectors().insert(iter.key(), v);
KST::addVectorToList(v);
}
for (KstScalarMap::ConstIterator iter = outputScalars().begin(); iter != outputScalars().end(); ++iter) {
KstScalarPtr s = new KstScalar(iter.data()->tagName() + "'", plugin.data());
plugin->outputScalars().insert(iter.key(), s);
}
for (KstStringMap::ConstIterator iter = outputStrings().begin(); iter != outputStrings().end(); ++iter) {
KstStringPtr s = new KstString(iter.data()->tagName() + "'", plugin.data());
plugin->outputStrings().insert(iter.key(), s);
}
// set the same plugin
plugin->setPlugin(_plugin);
plugin->setTagName(tagName() + "'");
duplicatedMap.insert(this, KstDataObjectPtr(plugin));
return KstDataObjectPtr(plugin);
}
示例14: fitChanged
void KstViewFitsDialog::fitChanged(const QString& strFit) {
KstCPluginList fits;
KstCPluginPtr plugin;
double* params = 0L;
double* covars = 0L;
double chi2Nu = 0.0;
int numParams = 0;
int numCovars = 0;
int i;
fits = kstObjectSubList<KstDataObject,KstCPlugin>(KST::dataObjectList);
plugin = *(fits.findTag(strFit));
if (plugin) {
KstScalarPtr scalarChi2Nu;
KstVectorPtr vectorParam;
plugin->readLock();
const KstScalarMap& scalars = plugin->outputScalars();
scalarChi2Nu = scalars["chi^2/nu"];
if (scalarChi2Nu) {
scalarChi2Nu->readLock();
chi2Nu = scalarChi2Nu->value();
scalarChi2Nu->unlock();
}
const KstVectorMap& vectors = plugin->outputVectors();
vectorParam = vectors["Parameters"];
if (vectorParam) {
KstVectorPtr vectorCovar;
vectorParam->readLock();
vectorCovar = vectors["Covariance"];
if (vectorCovar) {
vectorCovar->readLock();
numParams = vectorParam->length();
numCovars = vectorCovar->length();
if (numParams > 0 && numCovars > 0) {
params = new double[numParams];
covars = new double[numCovars];
for (i = 0; i < numParams; i++) {
params[i] = vectorParam->value(i);
}
for (i = 0; i < numCovars; i++) {
covars[i] = vectorCovar->value(i);
}
}
vectorCovar->unlock();
}
vectorParam->unlock();
}
plugin->unlock();
}
_tableFits->setParameters(params, numParams, covars, numCovars, chi2Nu);
if (numParams > 0) {
_tableFits->horizontalHeaderItem(0)->setText(QObject::tr("Value"));
_tableFits->horizontalHeaderItem(1)->setText(QObject::tr("Covariance:"));
_tableFits->verticalHeaderItem(numParams+0)->setText("---");
_tableFits->verticalHeaderItem(numParams+1)->setText(QObject::tr("Chi^2/Nu"));
if (plugin) {
QExplicitlySharedDataPointer<Plugin> pluginBase;
plugin->readLock();
pluginBase = plugin->plugin();
if (pluginBase) {
textLabelFit->setText(pluginBase->data()._readableName);
for (i = 0; i < numParams; i++) {
QString parameterName = pluginBase->parameterName(i);
_tableFits->horizontalHeaderItem(i+2)->setText(parameterName);
_tableFits->verticalHeaderItem(i)->setText(parameterName);
}
}
plugin->unlock();
}
}
_tableFits->update();
}