本文整理汇总了C++中KstCPluginPtr::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ KstCPluginPtr::unlock方法的具体用法?C++ KstCPluginPtr::unlock怎么用?C++ KstCPluginPtr::unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstCPluginPtr
的用法示例。
在下文中一共展示了KstCPluginPtr::unlock方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: editObject
bool KstPluginDialogI::editObject() {
KstCPluginPtr pp = kst_cast<KstCPlugin>(_dp);
if (!pp) { // something is dreadfully wrong - this should never happen
return false;
}
pp->writeLock();
if (_tagName->text() != pp->tagName() && KstData::self()->dataTagNameNotUnique(_tagName->text())) {
_tagName->setFocus();
pp->unlock();
return false;
}
pp->setTagName(_tagName->text());
int pitem = _w->PluginCombo->currentItem();
KstSharedPtr<Plugin> pPtr = PluginCollection::self()->plugin(_pluginList[pitem]);
// Must unlock before clear()
for (KstVectorMap::Iterator i = pp->inputVectors().begin(); i != pp->inputVectors().end(); ++i) {
(*i)->unlock();
}
for (KstScalarMap::Iterator i = pp->inputScalars().begin(); i != pp->inputScalars().end(); ++i) {
(*i)->unlock();
}
for (KstStringMap::Iterator i = pp->inputStrings().begin(); i != pp->inputStrings().end(); ++i) {
(*i)->unlock();
}
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 plugin you entered."));
pp->unlock();
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 plugin you entered."));
pp->unlock();
return false;
}
if (!pp->isValid()) {
KMessageBox::sorry(this, i18n("There is an error in the plugin you entered."));
pp->unlock();
return false;
}
pp->setDirty();
pp->unlock();
emit modified();
return true;
}
示例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: 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());
}
}
示例5: 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);
}
}
}
}
示例6: 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 {
//.........这里部分代码省略.........
示例7: 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;
}
}
}
示例8: 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();
}