[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Fri Sep 19 20:39:42 CEST 2008
SVN commit 862748 by fenton:
Add Content Menu support for Fit/Filter from DataManager and PlotItems.
Add CurveAppearance Settings / curve creation to FitFilterDialog, including interface extensions to support.
M +40 -1 libkstapp/datamanager.cpp
M +2 -0 libkstapp/datamanager.h
M +12 -1 libkstapp/dialoglaunchergui.cpp
M +1 -1 libkstapp/dialoglaunchergui.h
M +96 -3 libkstapp/filterfitdialog.cpp
M +16 -0 libkstapp/filterfitdialog.h
M +80 -1 libkstapp/plotitem.cpp
M +10 -0 libkstapp/plotitem.h
M +10 -0 libkstmath/dataobject.cpp
M +3 -0 libkstmath/dataobject.h
M +4 -1 libkstmath/dialoglauncher.cpp
M +2 -1 libkstmath/dialoglauncher.h
M +9 -0 plugins/filters/despike/filterdespike.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #862747:862748
@@ -178,6 +178,17 @@
connect(action, SIGNAL(triggered()), this, SLOT(showHistogramDialog()));
actions.append(action);
+ if (!DataObject::fitsPluginList().empty()) {
+ action = new QAction(tr("Apply Fit"), this);
+ connect(action, SIGNAL(triggered()), this, SLOT(showFitDialog()));
+ actions.append(action);
+ }
+
+ if (!DataObject::filterPluginList().empty()) {
+ action = new QAction(tr("Apply Filter"), this);
+ connect(action, SIGNAL(triggered()), this, SLOT(showFilterDialog()));
+ actions.append(action);
+ }
} else if (MatrixPtr m = kst_cast<Matrix>(_currentObject)) {
action = new QAction(tr("Make Image"), this);
connect(action, SIGNAL(triggered()), this, SLOT(showImageDialog()));
@@ -218,6 +229,18 @@
action->setMenu(removeMenu);
actions.append(action);
+
+ if (!DataObject::fitsPluginList().empty()) {
+ action = new QAction(tr("Apply Fit"), this);
+ connect(action, SIGNAL(triggered()), this, SLOT(showFitDialog()));
+ actions.append(action);
+ }
+
+ if (!DataObject::filterPluginList().empty()) {
+ action = new QAction(tr("Apply Filter"), this);
+ connect(action, SIGNAL(triggered()), this, SLOT(showFilterDialog()));
+ actions.append(action);
+ }
}
action = new QAction(tr("Delete"), this);
@@ -385,12 +408,28 @@
void DataManager::showPluginDialog(QString &pluginName) {
- DialogLauncher::self()->showBasicPluginDialog(pluginName);
+ if (VectorPtr vector = kst_cast<Vector>(_currentObject)) {
+ DialogLauncher::self()->showBasicPluginDialog(pluginName, 0, vector);
+ } else if (CurvePtr curve = kst_cast<Curve>(_currentObject)) {
+ DialogLauncher::self()->showBasicPluginDialog(pluginName, 0, curve->xVector(), curve->yVector());
+ } else {
+ DialogLauncher::self()->showBasicPluginDialog(pluginName);
+}
_doc->session()->triggerReset();
}
+void DataManager::showFilterDialog() {
+ showPluginDialog(DataObject::filterPluginList().first());
+}
+
+
+void DataManager::showFitDialog() {
+ showPluginDialog(DataObject::fitsPluginList().first());
+}
+
+
void DataManager::deleteObject() {
if (RelationPtr relation = kst_cast<Relation>(_currentObject)) {
Data::self()->removeCurveFromPlots(relation);
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.h #862747:862748
@@ -49,6 +49,8 @@
void showEventMonitorDialog();
void showEquationDialog();
void showPluginDialog(QString &pluginName);
+ void showFitDialog();
+ void showFilterDialog();
void addToPlot(QAction* action);
void removeFromPlot(QAction* action);
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.cpp #862747:862748
@@ -117,12 +117,23 @@
}
-void DialogLauncherGui::showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr) {
+void DialogLauncherGui::showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr, VectorPtr vectorX, VectorPtr vectorY, PlotItemInterface *plotItem) {
if (DataObject::pluginType(pluginName) == DataObjectPluginInterface::Generic) {
BasicPluginDialog dialog(pluginName, objectPtr, kstApp->mainWindow());
dialog.exec();
} else {
FilterFitDialog dialog(pluginName, objectPtr, kstApp->mainWindow());
+ if (!objectPtr) {
+ if (vectorX) {
+ dialog.setVectorX(vectorX);
+ }
+ if (vectorY) {
+ dialog.setVectorY(vectorY);
+ }
+ if (plotItem) {
+ dialog.setPlotMode((PlotItem*)plotItem);
+ }
+ }
dialog.exec();
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.h #862747:862748
@@ -49,7 +49,7 @@
virtual void showEventMonitorDialog(ObjectPtr objectPtr = 0);
//plugins
- virtual void showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr = 0);
+ virtual void showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr = 0, VectorPtr vectorX = 0, VectorPtr vectorY = 0, PlotItemInterface *plotItem = 0 );
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/filterfitdialog.cpp #862747:862748
@@ -16,11 +16,13 @@
#include "datacollection.h"
#include "document.h"
#include "basicplugin.h"
+#include "objectstore.h"
+#include "curve.h"
namespace Kst {
FilterFitTab::FilterFitTab(QString& pluginName, QWidget *parent)
- : DataTab(parent), _configWidget(0), _layout(0), _store(0) {
+ : DataTab(parent), _configWidget(0), _layout(0), _store(0), _vectorX(0), _vectorY(0) {
setupUi(this);
setTabTitle(tr("Plugin"));
@@ -49,6 +51,32 @@
}
+void FilterFitTab::setVectorX(VectorPtr vector) {
+ _vectorX = vector;
+ if (_configWidget) {
+ _configWidget->setVectorX(vector);
+ }
+}
+
+
+void FilterFitTab::setVectorY(VectorPtr vector) {
+ _vectorY = vector;
+ if (_configWidget) {
+ _configWidget->setVectorY(vector);
+ }
+}
+
+
+void FilterFitTab::setPlotMode() {
+ _curveAppearance->setVisible(true);
+}
+
+
+CurveAppearance* FilterFitTab::curveAppearance() const {
+ return _curveAppearance;
+}
+
+
void FilterFitTab::pluginChanged(const QString &plugin) {
if (plugin != _pluginCombo->currentText()) {
_pluginCombo->setCurrentIndex(_pluginCombo->findText(plugin));
@@ -69,13 +97,19 @@
if (_store) {
_configWidget->setObjectStore(_store);
}
+ if (_vectorX) {
+ _configWidget->setVectorX(_vectorX);
+ }
+ if (_vectorY) {
+ _configWidget->setVectorY(_vectorY);
+ }
_layout->addWidget(_configWidget, 0, 0);
_layout->activate();
}
FilterFitDialog::FilterFitDialog(QString& pluginName, ObjectPtr dataObject, QWidget *parent)
- : DataDialog(dataObject, parent), _pluginName(pluginName) {
+ : DataDialog(dataObject, parent), _pluginName(pluginName), _plotItem(0), _vectorX(0), _vectorY(0) {
if (editMode() == Edit)
setWindowTitle(tr("Edit Plugin"));
@@ -89,6 +123,7 @@
_filterFitTab->configWidget()->setupFromObject(dataObject);
} else {
_filterFitTab->configWidget()->load();
+ configureTab();
}
}
@@ -97,14 +132,72 @@
}
+void FilterFitDialog::configureTab() {
+ _filterFitTab->curveAppearance()->loadWidgetDefaults();
+}
+
+
QString FilterFitDialog::tagString() const {
return DataDialog::tagString();
}
+void FilterFitDialog::setVectorX(VectorPtr vector) {
+ _vectorX = vector;
+ _filterFitTab->setVectorX(vector);
+}
+
+
+void FilterFitDialog::setVectorY(VectorPtr vector) {
+ _vectorY = vector;
+ _filterFitTab->setVectorY(vector);
+}
+
+
+void FilterFitDialog::setPlotMode(PlotItem* plot) {
+ _plotItem = plot;
+ _filterFitTab->setPlotMode();
+}
+
+
ObjectPtr FilterFitDialog::createNewDataObject() {
- DataObjectPtr dataObject = DataObject::createPlugin(_pluginName, _document->objectStore(), _filterFitTab->configWidget());
_filterFitTab->configWidget()->save();
+
+ BasicPluginPtr dataObject = kst_cast<BasicPlugin>(DataObject::createPlugin(_pluginName, _document->objectStore(), _filterFitTab->configWidget()));
+ Q_ASSERT(dataObject);
+
+ if (_plotItem) {
+ CurvePtr curve = _document->objectStore()->createObject<Curve>();
+
+ Q_ASSERT(curve);
+
+ curve->setXVector(_vectorX);
+
+ VectorPtr yVector = dataObject->outputVectors().value(dataObject->outputVectorList().first());
+ Q_ASSERT(yVector);
+ curve->setYVector(yVector);
+
+ curve->setColor(_filterFitTab->curveAppearance()->color());
+ curve->setHasPoints(_filterFitTab->curveAppearance()->showPoints());
+ curve->setHasLines(_filterFitTab->curveAppearance()->showLines());
+ curve->setHasBars(_filterFitTab->curveAppearance()->showBars());
+ curve->setLineWidth(_filterFitTab->curveAppearance()->lineWidth());
+ curve->setLineStyle(_filterFitTab->curveAppearance()->lineStyle());
+ curve->setPointType(_filterFitTab->curveAppearance()->pointType());
+ curve->setPointDensity(_filterFitTab->curveAppearance()->pointDensity());
+ curve->setBarStyle(_filterFitTab->curveAppearance()->barStyle());
+
+ curve->writeLock();
+ curve->update();
+ curve->unlock();
+
+ _filterFitTab->curveAppearance()->setWidgetDefaults();
+
+ PlotRenderItem *renderItem = _plotItem->renderItem(PlotRenderItem::Cartesian);
+ renderItem->addRelation(kst_cast<Relation>(curve));
+ _plotItem->update();
+ }
+
return dataObject;
}
--- branches/work/kst/portto4/kst/src/libkstapp/filterfitdialog.h #862747:862748
@@ -15,6 +15,7 @@
#include "datadialog.h"
#include "datatab.h"
#include "dataobjectplugin.h"
+#include "plotitem.h"
#include "kst_export.h"
@@ -29,12 +30,18 @@
virtual ~FilterFitTab();
void setObjectStore(ObjectStore *store);
+ void setVectorX(VectorPtr vector);
+ void setVectorY(VectorPtr vector);
+ CurveAppearance* curveAppearance() const;
+
DataObjectConfigWidget* configWidget() { return _configWidget; }
void loadSettings();
void saveSettings();
+ void setPlotMode();
+
public Q_SLOTS:
void pluginChanged(const QString&);
@@ -43,6 +50,7 @@
QGridLayout* _layout;
DataObjectPluginInterface::PluginTypeID _type;
ObjectStore *_store;
+ VectorPtr _vectorX, _vectorY;
};
@@ -52,14 +60,22 @@
FilterFitDialog(QString& pluginName, ObjectPtr dataObject, QWidget *parent = 0);
virtual ~FilterFitDialog();
+ void setVectorX(VectorPtr vector);
+ void setVectorY(VectorPtr vector);
+ void setPlotMode(PlotItem* plot);
+
protected:
virtual QString tagString() const;
virtual ObjectPtr createNewDataObject();
virtual ObjectPtr editExistingDataObject() const;
private:
+ void configureTab();
FilterFitTab *_filterFitTab;
QString _pluginName;
+ PlotItem* _plotItem;
+ VectorPtr _vectorX;
+ VectorPtr _vectorY;
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #862747:862748
@@ -28,6 +28,7 @@
#include "cartesianrenderitem.h"
#include "plotitemdialog.h"
+#include "dialoglauncher.h"
#include "math_kst.h"
@@ -72,7 +73,9 @@
_rightLabelFontScale(0.0),
_showLegend(false),
_legend(0),
- _zoomMenu(0)
+ _zoomMenu(0),
+ _filterMenu(0),
+ _fitMenu(0)
{
setName("Plot");
@@ -295,14 +298,90 @@
_zoomMenu->addAction(_zoomLogY);
}
+void PlotItem::createFilterMenu() {
+ if (_filterMenu) {
+ delete _filterMenu;
+ }
+ _filterMenu = new QMenu;
+ _filterMenu->setTitle(tr("Filter"));
+
+ QAction *action;
+ foreach (PlotRenderItem *renderer, renderItems()) {
+ foreach (RelationPtr relation, renderer->relationList()) {
+ if (CurvePtr curve = kst_cast<Curve>(relation)) {
+ action = new QAction(relation->Name(), this);
+ _filterMenu->addAction(action);
+ }
+ }
+ }
+ connect(_filterMenu, SIGNAL(triggered(QAction*)), this, SLOT(showFilterDialog(QAction*)));
+}
+
+
+void PlotItem::createFitMenu() {
+ if (_fitMenu) {
+ delete _fitMenu;
+ }
+
+ _fitMenu = new QMenu;
+ _fitMenu->setTitle(tr("Fit"));
+
+ QAction *action;
+ foreach (PlotRenderItem *renderer, renderItems()) {
+ foreach (RelationPtr relation, renderer->relationList()) {
+ if (CurvePtr curve = kst_cast<Curve>(relation)) {
+ action = new QAction(relation->Name(), this);
+ _fitMenu->addAction(action);
+ }
+ }
+ }
+ connect(_fitMenu, SIGNAL(triggered(QAction*)), this, SLOT(showFitDialog(QAction*)));
+}
+
+
void PlotItem::addToMenuForContextEvent(QMenu &menu) {
_zoomLogX->setChecked(xAxis()->axisLog());
_zoomLogY->setChecked(yAxis()->axisLog());
menu.addMenu(_zoomMenu);
+ if (!DataObject::filterPluginList().empty()) {
+ createFilterMenu();
+ menu.addMenu(_filterMenu);
+ }
+
+ if (!DataObject::fitsPluginList().empty()) {
+ createFitMenu();
+ menu.addMenu(_fitMenu);
+ }
}
+void PlotItem::showFilterDialog(QAction* action) {
+ foreach (PlotRenderItem *renderer, renderItems()) {
+ foreach (RelationPtr relation, renderer->relationList()) {
+ if (relation->Name() == action->text()) {
+ if (CurvePtr curve = kst_cast<Curve>(relation)) {
+ DialogLauncher::self()->showBasicPluginDialog(DataObject::filterPluginList().first(), 0, curve->xVector(), curve->yVector(), this);
+ }
+ }
+ }
+ }
+}
+
+
+void PlotItem::showFitDialog(QAction* action) {
+ foreach (PlotRenderItem *renderer, renderItems()) {
+ foreach (RelationPtr relation, renderer->relationList()) {
+ if (relation->Name() == action->text()) {
+ if (CurvePtr curve = kst_cast<Curve>(relation)) {
+ DialogLauncher::self()->showBasicPluginDialog(DataObject::fitsPluginList().first(), 0, curve->xVector(), curve->yVector(), this);
+ }
+ }
+ }
+ }
+}
+
+
void PlotItem::updateObject() {
#if DEBUG_UPDATE_CYCLE > 1
qDebug() << "UP - Updating Plot";
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #862747:862748
@@ -211,9 +211,14 @@
virtual void edit();
void marginsUpdated();
+ void showFilterDialog(QAction*);
+ void showFitDialog(QAction*);
+
private:
void createActions();
void createZoomMenu();
+ void createFilterMenu();
+ void createFitMenu();
void resetSelectionRect();
@@ -349,6 +354,11 @@
QAction *_zoomNormalizeYtoX;
QAction *_zoomLogY;
+ QMenu *_filterMenu;
+ QAction *_filterAction;
+ QMenu *_fitMenu;
+ QAction *_fitAction;
+
QUndoStack *_undoStack;
friend class ZoomCommand;
--- branches/work/kst/portto4/kst/src/libkstmath/dataobject.cpp #862747:862748
@@ -912,6 +912,16 @@
}
+void DataObjectConfigWidget::setVectorX(VectorPtr vector) {
+ Q_UNUSED(vector);
+}
+
+
+void DataObjectConfigWidget::setVectorY(VectorPtr vector) {
+ Q_UNUSED(vector);
+}
+
+
void DataObjectConfigWidget::setupSlots(QWidget* dialog) {
Q_UNUSED(dialog);
}
--- branches/work/kst/portto4/kst/src/libkstmath/dataobject.h #862747:862748
@@ -198,6 +198,9 @@
virtual void setupFromObject(Object* dataObject);
virtual void setupSlots(QWidget* dialog);
+ virtual void setVectorX(VectorPtr vector);
+ virtual void setVectorY(VectorPtr vector);
+
virtual bool configurePropertiesFromXml(ObjectStore *store, QXmlStreamAttributes& attrs);
KST_EXPORT void setInstance(DataObjectPtr inst);
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.cpp #862747:862748
@@ -115,9 +115,12 @@
}
-void DialogLauncher::showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr) {
+void DialogLauncher::showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr, VectorPtr vectorX, VectorPtr vectorY, PlotItemInterface *plotItem) {
Q_UNUSED(pluginName);
Q_UNUSED(objectPtr);
+ Q_UNUSED(vectorX);
+ Q_UNUSED(vectorY);
+ Q_UNUSED(plotItem);
}
}
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.h #862747:862748
@@ -23,6 +23,7 @@
#include "object.h"
#include "vector.h"
#include "matrix.h"
+#include "plotiteminterface.h"
#include "kst_export.h"
@@ -67,7 +68,7 @@
virtual void showEventMonitorDialog(ObjectPtr objectPtr = 0);
//plugins
- virtual void showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr = 0);
+ virtual void showBasicPluginDialog(QString pluginName, ObjectPtr objectPtr = 0, VectorPtr vectorX = 0, VectorPtr vectorY = 0, PlotItemInterface *plotItem = 0);
};
}
--- branches/work/kst/portto4/kst/src/plugins/filters/despike/filterdespike.cpp #862747:862748
@@ -42,6 +42,15 @@
}
}
+ void setVectorX(Kst::VectorPtr vector) {
+ setSelectedVector(vector);
+ }
+
+ void setVectorY(Kst::VectorPtr vector) {
+ Q_UNUSED(vector);
+ }
+
+
Kst::VectorPtr selectedVector() { return _vector->selectedVector(); };
void setSelectedVector(Kst::VectorPtr vector) { return _vector->setSelectedVector(vector); };
More information about the Kst
mailing list