[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Mon Oct 1 22:12:54 CEST 2007
SVN commit 719743 by treat:
* We can now create curves entirely from the GUI
as well as plot the curves.
* I've tested with gyrodata.dat and it works. We
have real plots now :)
M +103 -2 curvedialog.cpp
M +18 -0 curvedialog.h
M +17 -27 plotitem.cpp
M +5 -0 plotitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.cpp #719742:719743
@@ -13,6 +13,16 @@
#include "dialogpage.h"
+#include "kstvcurve.h"
+
+#include "view.h"
+#include "plotitem.h"
+#include "tabwidget.h"
+#include "mainwindow.h"
+#include "application.h"
+#include "vectorcurverenderitem.h"
+
+#include "kstdefaultnames.h"
#include "kstdatacollection.h"
#include "kstdataobjectcollection.h"
@@ -30,6 +40,66 @@
}
+KstVectorPtr CurveTab::xVector() const {
+ return _xVector->selectedVector();
+}
+
+
+void CurveTab::setXVector(KstVectorPtr vector) {
+ _xVector->setSelectedVector(vector);
+}
+
+
+KstVectorPtr CurveTab::yVector() const {
+ return _yVector->selectedVector();
+}
+
+
+void CurveTab::setYVector(KstVectorPtr vector) {
+ _yVector->setSelectedVector(vector);
+}
+
+
+KstVectorPtr CurveTab::xError() const {
+ return _xError->selectedVector();
+}
+
+
+void CurveTab::setXError(KstVectorPtr vector) {
+ _xError->setSelectedVector(vector);
+}
+
+
+KstVectorPtr CurveTab::yError() const {
+ return _yError->selectedVector();
+}
+
+
+void CurveTab::setYError(KstVectorPtr vector) {
+ _yError->setSelectedVector(vector);
+}
+
+
+KstVectorPtr CurveTab::xMinusError() const {
+ return _xMinusError->selectedVector();
+}
+
+
+void CurveTab::setXMinusError(KstVectorPtr vector) {
+ _xMinusError->setSelectedVector(vector);
+}
+
+
+KstVectorPtr CurveTab::yMinusError() const {
+ return _yMinusError->selectedVector();
+}
+
+
+void CurveTab::setYMinusError(KstVectorPtr vector) {
+ _yMinusError->setSelectedVector(vector);
+}
+
+
CurveDialog::CurveDialog(KstObjectPtr dataObject, QWidget *parent)
: DataDialog(dataObject, parent) {
@@ -55,8 +125,39 @@
KstObjectPtr CurveDialog::createNewDataObject() const {
- qDebug() << "createNewDataObject" << endl;
- return 0;
+ //FIXME Eli, how should I construct this tag??
+ KstVCurvePtr curve = new KstVCurve(tagName(),
+ _curveTab->xVector(),
+ _curveTab->yVector(),
+ _curveTab->xError(),
+ _curveTab->yError(),
+ _curveTab->xMinusError(),
+ _curveTab->yMinusError(),
+ QColor(Qt::red));
+
+ curve->writeLock();
+ curve->update(0);
+ curve->unlock();
+
+ //FIXME assume new plot for now...
+ //FIXME this should be a command...
+ //FIXME need some smart placement...
+ //FIXME need to hook up appearance and placement...
+ PlotItem *plotItem = new PlotItem(kstApp->mainWindow()->tabWidget()->currentView());
+ plotItem->setPos(0, 0);
+ plotItem->setViewRect(0.0, 0.0, 100.0, 100.0);
+ plotItem->parentView()->scene()->addItem(plotItem);
+ plotItem->setZValue(1);
+
+ KstRelationList relationList;
+ relationList.append(kst_cast<KstRelation>(curve));
+
+ VectorCurveRenderItem *test = new VectorCurveRenderItem("cartesiantest", plotItem);
+ test->setRelationList(relationList);
+
+ plotItem->addRenderItem(test);
+
+ return KstObjectPtr(curve.data());
}
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.h #719742:719743
@@ -29,6 +29,24 @@
CurveTab(QWidget *parent = 0);
virtual ~CurveTab();
+ KstVectorPtr xVector() const;
+ void setXVector(KstVectorPtr vector);
+
+ KstVectorPtr yVector() const;
+ void setYVector(KstVectorPtr vector);
+
+ KstVectorPtr xError() const;
+ void setXError(KstVectorPtr vector);
+
+ KstVectorPtr yError() const;
+ void setYError(KstVectorPtr vector);
+
+ KstVectorPtr xMinusError() const;
+ void setXMinusError(KstVectorPtr vector);
+
+ KstVectorPtr yMinusError() const;
+ void setYMinusError(KstVectorPtr vector);
+
private Q_SLOTS:
private:
};
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #719742:719743
@@ -35,43 +35,33 @@
setName("PlotItem");
setBrush(Qt::white);
+}
- // FIXME fake data for testing rendering
- KstVectorPtr xTest = new KstSVector(0.0, 100.0, 10000, KstObjectTag::fromString("X vector"));
- xTest->setLabel("a nice x label");
- KstVectorPtr yTest = new KstSVector(0.0, 100.0, 10000, KstObjectTag::fromString("Y vector"));
- yTest->setLabel("a nice y label");
- KstVectorPtr yTest2 = new KstSVector(-100.0, 100.0, 10000, KstObjectTag::fromString("Y vector 2"));
- if (COUNT % 2) {
- yTest2->setLabel("another nice y label");
- } else {
- yTest2->setLabel("another much much longer nice y label");
- }
- COUNT = COUNT + 1;
+PlotItem::~PlotItem() {
+}
- KstVCurvePtr renderTest = new KstVCurve(QString("rendertest"), xTest, yTest, 0, 0, 0, 0, QColor(Qt::red));
- renderTest->writeLock();
- renderTest->update(0);
- renderTest->unlock();
- KstVCurvePtr renderTest2 = new KstVCurve(QString("rendertest2"), xTest, yTest2, 0, 0, 0, 0, QColor(Qt::blue));
- renderTest2->writeLock();
- renderTest2->update(0);
- renderTest2->unlock();
+QList<PlotRenderItem*> PlotItem::renderItems() const {
+ return _renderers;
+}
- KstRelationList relationList;
- relationList.append(kst_cast<KstRelation>(renderTest));
- relationList.append(kst_cast<KstRelation>(renderTest2));
- VectorCurveRenderItem *test = new VectorCurveRenderItem("cartesiantest", this);
- test->setRelationList(relationList);
+void PlotItem::addRenderItem(PlotRenderItem *renderItem) {
+ _renderers.append(renderItem);
+ update();
+}
- _renderers.append(test);
+
+void PlotItem::removeRenderItem(PlotRenderItem *renderItem) {
+ _renderers.removeAll(renderItem);
+ update();
}
-PlotItem::~PlotItem() {
+void PlotItem::clearRenderItems() {
+ _renderers.clear();
+ update();
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #719742:719743
@@ -31,6 +31,11 @@
PlotItem(View *parent);
virtual ~PlotItem();
+ QList<PlotRenderItem*> renderItems() const;
+ void addRenderItem(PlotRenderItem *renderItem);
+ void removeRenderItem(PlotRenderItem *renderItem);
+ void clearRenderItems();
+
virtual void paint(QPainter *painter);
qreal marginWidth() const;
More information about the Kst
mailing list