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; }
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; }