[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Wed Nov 14 21:57:34 CET 2007
SVN commit 736789 by fenton:
Add Curve Editing to Dialog.
Update Curve pointType to be private with accessor function.
Update DataManager to display CurveDialog on Edit.
M +63 -2 libkstapp/curvedialog.cpp
M +3 -0 libkstapp/curvedialog.h
M +31 -16 libkstapp/datamanager.cpp
M +5 -0 libkstapp/datamanager.h
M +2 -2 libkstapp/datawizard.cpp
M +1 -1 libkstapp/equationdialog.cpp
M +1 -1 libkstapp/histogramdialog.cpp
M +1 -1 libkstapp/powerspectrumdialog.cpp
M +1 -1 libkstapp/sessionmodel.h
M +6 -6 libkstmath/curve.cpp
M +4 -4 libkstmath/curve.h
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.cpp #736788:736789
@@ -129,6 +129,13 @@
}
+void CurveTab::hidePlacementOptions() {
+ _curvePlacement->setVisible(false);
+ setMaximumHeight(400);
+}
+
+
+
CurveAppearance* CurveTab::curveAppearance() const {
return _curveAppearance;
}
@@ -150,6 +157,10 @@
_curveTab = new CurveTab(this);
addDataTab(_curveTab);
+ if (editMode() == Edit) {
+ configureTab(dataObject);
+ }
+
connect(_curveTab, SIGNAL(vectorsChanged()), this, SLOT(updateButtons()));
updateButtons();
}
@@ -164,6 +175,36 @@
}
+void CurveDialog::configureTab(ObjectPtr object) {
+ if (CurvePtr curve = kst_cast<Curve>(object)) {
+ _curveTab->setXVector(curve->xVector());
+ _curveTab->setYVector(curve->yVector());
+ if (curve->hasXError()) {
+ _curveTab->setXError(curve->xErrorVector());
+ }
+ if (curve->hasYError()) {
+ _curveTab->setYError(curve->yErrorVector());
+ }
+ if (curve->hasXMinusError()) {
+ _curveTab->setXMinusError(curve->xMinusErrorVector());
+ }
+ if (curve->hasYMinusError()) {
+ _curveTab->setYMinusError(curve->yMinusErrorVector());
+ }
+ _curveTab->curveAppearance()->setColor(curve->color());
+ _curveTab->curveAppearance()->setShowPoints(curve->hasPoints());
+ _curveTab->curveAppearance()->setShowLines(curve->hasLines());
+ _curveTab->curveAppearance()->setShowBars(curve->hasBars());
+ _curveTab->curveAppearance()->setLineWidth(curve->lineWidth());
+ _curveTab->curveAppearance()->setLineStyle(curve->lineStyle());
+ _curveTab->curveAppearance()->setPointType(curve->pointType());
+ _curveTab->curveAppearance()->setPointDensity(curve->pointDensity());
+ _curveTab->curveAppearance()->setBarStyle(curve->barStyle());
+ _curveTab->hidePlacementOptions();
+ }
+}
+
+
void CurveDialog::updateButtons() {
_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_curveTab->xVector() && _curveTab->yVector());
}
@@ -236,8 +277,28 @@
ObjectPtr CurveDialog::editExistingDataObject() const {
- qDebug() << "editExistingDataObject" << endl;
- return 0;
+ if (CurvePtr curve = kst_cast<Curve>(dataObject())) {
+ curve->writeLock();
+ curve->setXVector(_curveTab->xVector());
+ curve->setYVector(_curveTab->yVector());
+ curve->setXError(_curveTab->xError());
+ curve->setYError(_curveTab->yError());
+ curve->setXMinusError(_curveTab->xMinusError());
+ curve->setYMinusError(_curveTab->yMinusError());
+ curve->setColor(_curveTab->curveAppearance()->color());
+ curve->setHasPoints(_curveTab->curveAppearance()->showPoints());
+ curve->setHasLines(_curveTab->curveAppearance()->showLines());
+ curve->setHasBars(_curveTab->curveAppearance()->showBars());
+ curve->setLineWidth(_curveTab->curveAppearance()->lineWidth());
+ curve->setLineStyle(_curveTab->curveAppearance()->lineStyle());
+ curve->setPointType(_curveTab->curveAppearance()->pointType());
+ curve->setPointDensity(_curveTab->curveAppearance()->pointDensity());
+ curve->setBarStyle(_curveTab->curveAppearance()->barStyle());
+
+ curve->update(0);
+ curve->unlock();
+ }
+ return dataObject();
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.h #736788:736789
@@ -52,6 +52,7 @@
CurvePlacement* curvePlacement() const;
void setObjectStore(ObjectStore *store);
+ void hidePlacementOptions();
Q_SIGNALS:
void vectorsChanged();
@@ -75,6 +76,8 @@
void updateButtons();
private:
+ void configureTab(ObjectPtr curve);
+
CurveTab *_curveTab;
};
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #736788:736789
@@ -20,6 +20,7 @@
#include "objectstore.h"
#include "dataobject.h"
+#include "curve.h"
#include <QHeaderView>
#include <QToolBar>
@@ -28,7 +29,7 @@
namespace Kst {
DataManager::DataManager(QWidget *parent, Document *doc)
- : QDialog(parent), _doc(doc) {
+ : QDialog(parent), _doc(doc), _currentObject(0) {
setupUi(this);
_session->header()->setResizeMode(QHeaderView::ResizeToContents);
@@ -117,26 +118,40 @@
void DataManager::showContextMenu(const QPoint &position) {
- QList<QAction *> actions;
- if (_session->indexAt(position).isValid()) {
- DataObjectPtr p = _doc->objectStore()->getObjects<DataObject>().at(_session->indexAt(position).row());
- if (p) {
- QAction *action = new QAction(p->tag().displayString(), this);
- actions.append(action);
+ QList<QAction *> actions;
+ if (_session->indexAt(position).isValid()) {
+ SessionModel *model = static_cast<SessionModel*>(_session->model());
+ _currentObject = model->generateObjectList().at(_session->indexAt(position).row());
+ if (_currentObject) {
+ QAction *action = new QAction(_currentObject->tag().displayString(), this);
+ actions.append(action);
- action = new DataButtonAction(tr("Edit"));
- connect(action, SIGNAL(triggered()), this, SLOT(showEditDialog()));
- actions.append(action);
+ action = new DataButtonAction(tr("Edit"));
+ connect(action, SIGNAL(triggered()), this, SLOT(showEditDialog()));
+ actions.append(action);
- action = new DataButtonAction(tr("Delete"));
- connect(action, SIGNAL(triggered()), this, SLOT(deleteObject()));
- actions.append(action);
- }
+ action = new DataButtonAction(tr("Delete"));
+ connect(action, SIGNAL(triggered()), this, SLOT(deleteObject()));
+ actions.append(action);
}
- if (actions.count() > 0)
- QMenu::exec(actions, _session->mapToGlobal(position));
+ }
+ if (actions.count() > 0)
+ QMenu::exec(actions, _session->mapToGlobal(position));
}
+
+void DataManager::showEditDialog() {
+ if (_currentObject) {
+ if (CurvePtr curve = kst_cast<Curve>(_currentObject)) {
+ DialogLauncher::self()->showCurveDialog(curve);
+ }
+ }
}
+
+void DataManager::deleteObject() {
+}
+
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.h #736788:736789
@@ -13,6 +13,7 @@
#define DATAMANAGER_H
#include <QDialog>
+#include "object.h"
#include "ui_datamanager.h"
@@ -33,6 +34,8 @@
public Q_SLOTS:
void showContextMenu(const QPoint &);
+ void showEditDialog();
+ void deleteObject();
private:
Document *_doc;
@@ -42,6 +45,8 @@
QToolBar *_fits;
QToolBar *_filters;
+ ObjectPtr _currentObject;
+
QMenu *_contextMenu;
};
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #736788:736789
@@ -768,7 +768,7 @@
curve->setHasPoints(_pagePlot->drawLinesAndPoints() || _pagePlot->drawPoints());
curve->setHasLines(_pagePlot->drawLinesAndPoints() || _pagePlot->drawLines());
curve->setLineWidth(Settings::globalSettings()->defaultLineWeight);
- curve->pointType = ptype++ % KSTPOINT_MAXTYPE;
+ curve->setPointType(ptype++ % KSTPOINT_MAXTYPE);
curve->writeLock();
curve->update(0);
@@ -841,7 +841,7 @@
curve->setHasPoints(_pagePlot->drawLinesAndPoints() || _pagePlot->drawPoints());
curve->setHasLines(_pagePlot->drawLinesAndPoints() || _pagePlot->drawLines());
curve->setLineWidth(Settings::globalSettings()->defaultLineWeight);
- curve->pointType = ptype++ % KSTPOINT_MAXTYPE;
+ curve->setPointType(ptype++ % KSTPOINT_MAXTYPE);
if (_pageDataPresentation->plotPSD() || colors.count() <= indexColor) {
color = ColorSequence::next();
--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.cpp #736788:736789
@@ -220,7 +220,7 @@
curve->setHasBars(_equationTab->curveAppearance()->showBars());
curve->setLineWidth(_equationTab->curveAppearance()->lineWidth());
curve->setLineStyle(_equationTab->curveAppearance()->lineStyle());
- curve->pointType = _equationTab->curveAppearance()->pointType();
+ curve->setPointType(_equationTab->curveAppearance()->pointType());
curve->setPointDensity(_equationTab->curveAppearance()->pointDensity());
curve->setBarStyle(_equationTab->curveAppearance()->barStyle());
--- branches/work/kst/portto4/kst/src/libkstapp/histogramdialog.cpp #736788:736789
@@ -205,7 +205,7 @@
curve->setHasBars(_histogramTab->curveAppearance()->showBars());
curve->setLineWidth(_histogramTab->curveAppearance()->lineWidth());
curve->setLineStyle(_histogramTab->curveAppearance()->lineStyle());
- curve->pointType = _histogramTab->curveAppearance()->pointType();
+ curve->setPointType(_histogramTab->curveAppearance()->pointType());
curve->setPointDensity(_histogramTab->curveAppearance()->pointDensity());
curve->setBarStyle(_histogramTab->curveAppearance()->barStyle());
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #736788:736789
@@ -145,7 +145,7 @@
curve->setHasBars(_powerSpectrumTab->curveAppearance()->showBars());
curve->setLineWidth(_powerSpectrumTab->curveAppearance()->lineWidth());
curve->setLineStyle(_powerSpectrumTab->curveAppearance()->lineStyle());
- curve->pointType = _powerSpectrumTab->curveAppearance()->pointType();
+ curve->setPointType(_powerSpectrumTab->curveAppearance()->pointType());
curve->setPointDensity(_powerSpectrumTab->curveAppearance()->pointDensity());
curve->setBarStyle(_powerSpectrumTab->curveAppearance()->barStyle());
--- branches/work/kst/portto4/kst/src/libkstapp/sessionmodel.h #736788:736789
@@ -34,12 +34,12 @@
QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ const ObjectList<Object> generateObjectList() const;
private:
QVariant vectorData(DataObjectPtr parent, const QModelIndex& index) const;
QVariant dataObjectData(DataObjectPtr dataObject, const QModelIndex& index) const;
QVariant relationData(RelationPtr relation, const QModelIndex& index) const;
- const ObjectList<Object> generateObjectList() const;
ObjectStore *_store;
};
--- branches/work/kst/portto4/kst/src/libkstmath/curve.cpp #736788:736789
@@ -156,7 +156,7 @@
} else if (e.tagName() == "hasbars") {
HasBars = e.text() != "0";
} else if (e.tagName() == "pointtype") {
- pointType = e.text().toInt();
+ PointType = e.text().toInt();
} else if (e.tagName() == "linewidth") {
LineWidth = e.text().toInt();
} else if (e.tagName() == "linestyle") {
@@ -498,7 +498,7 @@
s.writeAttribute("linestyle", QString::number(LineStyle));
s.writeAttribute("haspoints", QVariant(HasPoints).toString());
- s.writeAttribute("pointtype", QString::number(pointType));
+ s.writeAttribute("pointtype", QString::number(PointType));
s.writeAttribute("pointdensity", QString::number(PointDensity));
s.writeAttribute("hasbars", QVariant(HasBars).toString());
@@ -798,7 +798,7 @@
void Curve::setPointType(int in_PointType) {
- pointType = in_PointType;
+ PointType = in_PointType;
setDirty();
}
@@ -1475,7 +1475,7 @@
pt.setX(d2i(m_X * rX + b_X));
pt.setY(d2i(m_Y * rY + b_Y));
if (rgn.contains(pt)) {
- CurvePointSymbol::draw(pointType, p, pt.x(), pt.y(), width);
+ CurvePointSymbol::draw(PointType, p, pt.x(), pt.y(), width);
rgn -= QRegion(pt.x()-(size/2), pt.y()-(size/2), size, size, QRegion::Ellipse);
}
}
@@ -1493,7 +1493,7 @@
X1 = m_X * rX + b_X;
Y1 = m_Y * rY + b_Y;
if (X1 >= Lx && X1 <= Hx && Y1 >= Ly && Y1 <= Hy) {
- CurvePointSymbol::draw(pointType, p, d2i(X1), d2i(Y1), width);
+ CurvePointSymbol::draw(PointType, p, d2i(X1), d2i(Y1), width);
}
}
}
@@ -1836,7 +1836,7 @@
if (hasPoints()) {
// draw a point in the middle
p->setPen(QPen(color(), width));
- CurvePointSymbol::draw(pointType, p, bound.left() + bound.width()/2, bound.top() + bound.height()/2, width, 600);
+ CurvePointSymbol::draw(PointType, p, bound.left() + bound.width()/2, bound.top() + bound.height()/2, width, 600);
}
p->restore();
}
--- branches/work/kst/portto4/kst/src/libkstmath/curve.h #736788:736789
@@ -117,6 +117,7 @@
virtual int lineStyle() const { return LineStyle; }
virtual int barStyle() const { return BarStyle; }
virtual int pointDensity() const { return PointDensity; }
+ virtual int pointType() const { return PointType; }
virtual QColor color() const { return Color; }
virtual void setColor(const QColor& new_c);
@@ -128,8 +129,8 @@
void popLineWidth() { setLineWidth(_widthStack.pop()); }
void pushLineStyle(int s) { _lineStyleStack.push(lineStyle()); setLineStyle(s); }
void popLineStyle() { setLineStyle(_lineStyleStack.pop()); }
- void pushPointStyle(int s) { _pointStyleStack.push(pointType); pointType = s; }
- void popPointStyle() { pointType = _pointStyleStack.pop(); }
+ void pushPointStyle(int s) { _pointStyleStack.push(PointType); PointType = s; }
+ void popPointStyle() { PointType = _pointStyleStack.pop(); }
void pushHasPoints(bool h) { _hasPointsStack.push(hasPoints()); setHasPoints(h); }
void popHasPoints() { setHasPoints(_hasPointsStack.pop()); }
void pushHasLines(bool h) { _hasLinesStack.push(hasLines()); setHasLines(h); }
@@ -137,8 +138,6 @@
void pushPointDensity(int d) { _pointDensityStack.push(pointDensity()); setPointDensity(d); }
void popPointDensity() { setPointDensity(_pointDensityStack.pop()); }
- int pointType;
-
#if 0
virtual KstRelationPtr makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap);
#endif
@@ -177,6 +176,7 @@
int LineWidth;
int LineStyle;
int PointDensity;
+ int PointType;
bool HasPoints;
bool HasLines;
More information about the Kst
mailing list