[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Sun Jan 11 00:28:00 CET 2009
SVN commit 909085 by netterfield:
Add a range tab to the plot item dialog.
M +2 -2 config.pri
M +3 -0 src/libkstapp/libkstapp.pro
M +15 -0 src/libkstapp/plotitem.cpp
M +17 -1 src/libkstapp/plotitem.h
M +77 -0 src/libkstapp/plotitemdialog.cpp
M +4 -0 src/libkstapp/plotitemdialog.h
A src/libkstapp/rangetab.cpp [License: GPL (v2+)]
A src/libkstapp/rangetab.h [License: GPL (v2+)]
A src/libkstapp/rangetab.ui
--- branches/work/kst/portto4/kst/config.pri #909084:909085
@@ -2,7 +2,7 @@
HAVE_CFITSIO = 0
#Define if you have dirfile getdata library version 0.4.2 or greater required.
-HAVE_DIRFILE = 0
+HAVE_DIRFILE = 1
#Define if you have the gsl library installed
-HAVE_GSL = 0
\ No newline at end of file
+HAVE_GSL = 1
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #909084:909085
@@ -100,6 +100,7 @@
plotmarkers.cpp \
plotrenderitem.cpp \
powerspectrumdialog.cpp \
+ rangetab.cpp \
scalardialog.cpp \
scalarmodel.cpp \
scene.cpp \
@@ -206,6 +207,7 @@
plotitemmanager.h \
plotrenderitem.h \
powerspectrumdialog.h \
+ rangetab.h \
scalardialog.h \
scalarmodel.h \
scene.h \
@@ -274,6 +276,7 @@
matrixtab.ui \
powerspectrumtab.ui \
overridelabeltab.ui \
+ rangetab.ui \
scalartab.ui \
stringtab.ui \
stroketab.ui \
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #909084:909085
@@ -2251,6 +2251,13 @@
}
+void PlotItem::zoomGeneral(ZoomState &zoomstate) {
+ ZoomCommand *cmd = new ZoomGeneralCommand(this, zoomstate);
+ _undoStack->push(cmd);
+ cmd->redo();
+}
+
+
void PlotItem::zoomMaximum() {
#if DEBUG_ZOOM
qDebug() << "zoomMaximum" << endl;
@@ -2807,6 +2814,14 @@
}
}
+/*
+ * Set zoom to arbitrary state: used by the dialog
+ */
+void ZoomGeneralCommand::applyZoomTo(PlotItem *item) {
+ item->xAxis()->setAxisZoomMode((PlotAxis::ZoomMode)_zoomstate.xAxisZoomMode);
+ item->yAxis()->setAxisZoomMode((PlotAxis::ZoomMode)_zoomstate.yAxisZoomMode);
+ item->setProjectionRect(_zoomstate.projectionRect);
+}
/*
* X axis zoom to FixedExpression, Y axis zoom to FixedExpression.
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #909084:909085
@@ -236,6 +236,7 @@
LegendItem* legend();
virtual QString descriptionTip() const; // description for tooltips
+ ZoomState currentZoomState();
protected:
virtual QString _automaticDescriptiveName() const;
@@ -250,6 +251,7 @@
void zoomXRange(const QRectF &projection);
void zoomYRange(const QRectF &projection);
void zoomMaximum();
+ void zoomGeneral(ZoomState &zoomstate);
void zoomMaxSpikeInsensitive();
void zoomPrevious();
void zoomYMeanCentered();
@@ -339,7 +341,6 @@
QSizeF calculateBottomTickLabelBound(QPainter *painter);
QSizeF calculateLeftTickLabelBound(QPainter *painter);
- ZoomState currentZoomState();
void setCurrentZoomState(ZoomState zoomState);
private:
@@ -444,6 +445,7 @@
friend class ZoomCommand;
friend class ZoomMaximumCommand;
+ friend class ZoomGeneralCommand;
friend class ZoomMaxSpikeInsensitiveCommand;
friend class ZoomYMeanCenteredCommand;
friend class ZoomXMaximumCommand;
@@ -510,6 +512,20 @@
};
+class KST_EXPORT ZoomGeneralCommand : public ZoomCommand
+{
+ public:
+ ZoomGeneralCommand(PlotItem *item, const ZoomState &zoomstate)
+ : ZoomCommand(item, QObject::tr("Zoom Fixed Expression")), _zoomstate(zoomstate) {}
+ virtual ~ZoomGeneralCommand() {}
+
+ virtual void applyZoomTo(PlotItem *item);
+
+ private:
+ ZoomState _zoomstate;
+};
+
+
class KST_EXPORT ZoomXRangeCommand : public ZoomCommand
{
public:
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #909084:909085
@@ -13,6 +13,7 @@
#include "contenttab.h"
#include "axistab.h"
+#include "rangetab.h"
#include "markerstab.h"
#include "labeltab.h"
#include "overridelabeltab.h"
@@ -84,6 +85,13 @@
addDialogPage(yAxisPage);
connect(_yAxisTab, SIGNAL(apply()), this, SLOT(yAxisChanged()));
+ _rangeTab = new RangeTab(_plotItem, this);
+ DialogPage *rangePage = new DialogPage(this);
+ rangePage->setPageTitle(tr("Range"));
+ rangePage->addDialogTab(_rangeTab);
+ addDialogPage(rangePage);
+ connect(_rangeTab, SIGNAL(apply()), this, SLOT(rangeChanged()));
+
_xMarkersTab = new MarkersTab(this);
DialogPage *xMarkersPage = new DialogPage(this);
xMarkersPage->setPageTitle(tr("x-Axis markers"));
@@ -112,6 +120,7 @@
setupContent();
setupAxis();
+ setupRange();
setupLabels();
setupMarkers();
}
@@ -157,6 +166,11 @@
}
+void PlotItemDialog::setupRange() {
+ _rangeTab->setupRange();
+}
+
+
void PlotItemDialog::setupAxis() {
Q_ASSERT(_plotItem);
@@ -417,8 +431,71 @@
}
}
}
+ QPointer<PlotItem> item;
+ QRectF projectionRect;
+ int xAxisZoomMode;
+ int yAxisZoomMode;
+ bool isXAxisLog;
+ bool isYAxisLog;
+ qreal xLogBase;
+ qreal yLogBase;
+void PlotItemDialog::rangeChanged() {
+ Q_ASSERT(_plotItem);
+ ZoomState zoomstate;
+ double x;
+ double y;
+ double w;
+ double h;
+ zoomstate = _plotItem->currentZoomState();
+
+ zoomstate.item = _plotItem;
+ if (_rangeTab->xMean()) {
+ w = (_rangeTab->xRange());
+ x = (_plotItem->xMin() + _plotItem->xMax()-w)/2.0;
+ } else {
+ x = qMin(_rangeTab->xMax(), _rangeTab->xMin());
+ w = fabs(_rangeTab->xMax() - _rangeTab->xMin());
+ }
+ if (_rangeTab->yMean()) {
+ h = (_rangeTab->yRange());
+ y = (_plotItem->yMax() + _plotItem->yMin()-h)/2;
+ } else {
+ y = qMin(_rangeTab->yMax(), _rangeTab->yMin());
+ h = fabs(_rangeTab->yMax() - _rangeTab->yMin());
+ }
+
+ if (w == 0.0) w = 0.2;
+ if (h == 0.0) h = 0.2;
+
+ if (_rangeTab->xAuto()) {
+ } else if (_rangeTab->xSpike()) {
+ zoomstate.xAxisZoomMode = PlotAxis::SpikeInsensitive;
+ } else if (_rangeTab->xBorder()) {
+ zoomstate.xAxisZoomMode = PlotAxis::AutoBorder;
+ } else if (_rangeTab->xMean()) {
+ zoomstate.xAxisZoomMode = PlotAxis::MeanCentered;
+ } else if (_rangeTab->xFixed()) {
+ zoomstate.xAxisZoomMode = PlotAxis::FixedExpression;
+ }
+
+ if (_rangeTab->yAuto()) {
+ zoomstate.yAxisZoomMode = PlotAxis::Auto;
+ } else if (_rangeTab->ySpike()) {
+ zoomstate.yAxisZoomMode = PlotAxis::SpikeInsensitive;
+ } else if (_rangeTab->yBorder()) {
+ zoomstate.yAxisZoomMode = PlotAxis::AutoBorder;
+ } else if (_rangeTab->yMean()) {
+ zoomstate.yAxisZoomMode = PlotAxis::MeanCentered;
+ } else if (_rangeTab->yFixed()) {
+ zoomstate.yAxisZoomMode = PlotAxis::FixedExpression;
+ }
+ zoomstate.projectionRect = QRectF(x,y,w,h);
+
+ _plotItem->zoomGeneral(zoomstate);
+}
+
void PlotItemDialog::xAxisChanged() {
Q_ASSERT(_plotItem);
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.h #909084:909085
@@ -21,6 +21,7 @@
class ContentTab;
class PlotMarkersTab;
class AxisTab;
+class RangeTab;
class MarkersTab;
class LabelTab;
class ObjectStore;
@@ -49,9 +50,11 @@
void useLeftDefaultChanged(bool);
void useRightDefaultChanged(bool);
void useAxisDefaultChanged(bool);
+ void rangeChanged();
private:
void setupContent();
void setupAxis();
+ void setupRange();
void setupLabels();
void setupMarkers();
void addRelations();
@@ -63,6 +66,7 @@
ContentTab *_contentTab;
AxisTab *_xAxisTab;
AxisTab *_yAxisTab;
+ RangeTab *_rangeTab;
MarkersTab *_xMarkersTab;
MarkersTab *_yMarkersTab;
LabelTab *_labelTab;
More information about the Kst
mailing list