当前位置: 首页>>代码示例>>C++>>正文


C++ KstSharedPtr::data方法代码示例

本文整理汇总了C++中KstSharedPtr::data方法的典型用法代码示例。如果您正苦于以下问题:C++ KstSharedPtr::data方法的具体用法?C++ KstSharedPtr::data怎么用?C++ KstSharedPtr::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KstSharedPtr的用法示例。


在下文中一共展示了KstSharedPtr::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:98,代码来源:kstplugindialog_i.cpp

示例2: 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);
            }
        }
    }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:96,代码来源:kstplugindialog_i.cpp

示例3: setPlugin

bool KstCPlugin::setPlugin(KstSharedPtr<Plugin> plugin) {
  // Assumes that this is called with a write lock in place on this object
  Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);

  if (plugin == _plugin) {
    return true;
  }

  freeParameters();

  if (_localData) {
    if (!_plugin || !_plugin->freeLocalData(&_localData)) {
      free(_localData);
    }
    _localData = 0L;
  }

  if (!plugin) {
    _inputVectors.clear();
    _inputScalars.clear();
    _inputStrings.clear();
    _outputVectors.clear();
    _outputScalars.clear();
    _outputStrings.clear();
    _plugin = 0L;
    return true;
  }

  Plugin::countScalarsVectorsAndStrings(plugin->data()._inputs, _inScalarCnt, _inArrayCnt, _inStringCnt, _inPid);

  if (_inputVectors.count() != _inArrayCnt ||
      _inputScalars.count() != _inScalarCnt - _inPid ||
      _inputStrings.count() != _inStringCnt) {
    _plugin = 0L;
    return false;
  }

  _outScalarCnt = 0;
  _outArrayCnt = 0;
  _outStringCnt = 0;
  _outputVectors.clear();
  _outputScalars.clear();
  _outputStrings.clear();

  const QValueList<Plugin::Data::IOValue>& otable = plugin->data()._outputs;
  for (QValueList<Plugin::Data::IOValue>::ConstIterator it = otable.begin();
                                                         it != otable.end();
                                                                        ++it) {
    if ((*it)._type == Plugin::Data::IOValue::TableType) {
      KstWriteLocker blockVectorUpdates(&KST::vectorList.lock());
      KstVectorPtr v;

      if ((*it)._subType == Plugin::Data::IOValue::FloatNonVectorSubType) {
        v = new KstVector(KstObjectTag((*it)._name, tag()), 0, this, true);
      } else {
        v = new KstVector(KstObjectTag((*it)._name, tag()), 0, this, false);
      }
      _outputVectors.insert((*it)._name, v);
      ++_outArrayCnt;
    } else if ((*it)._type == Plugin::Data::IOValue::FloatType) {
      KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
      KstScalarPtr s = new KstScalar(KstObjectTag((*it)._name, tag()), this);
      _outputScalars.insert((*it)._name, s);
      ++_outScalarCnt;
    } else if ((*it)._type == Plugin::Data::IOValue::StringType) {
      KstWriteLocker blockStringUpdates(&KST::stringList.lock());
      KstStringPtr s = new KstString(KstObjectTag((*it)._name, tag()), this);
      _outputStrings.insert((*it)._name, s);
      ++_outStringCnt;
    }
  }

  allocateParameters();
  _plugin = plugin;

  return true;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:77,代码来源:kstcplugin.cpp


注:本文中的KstSharedPtr::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。