[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Thu Mar 6 15:47:10 CET 2008
SVN commit 782933 by fenton:
Reworking of Dialog for PlotItem/PlotRenderItem. Move dialog to be based on PlotItem, and move all Log based settings into
PlotItem.
M +8 -8 cartesianrenderitem.cpp
M +2 -2 datawizard.cpp
M +2 -2 libkstapp.pro
M +8 -0 plotitem.cpp
M +3 -0 plotitem.h
A plotitemdialog.cpp [License: GPL (v2+)]
A plotitemdialog.h [License: GPL (v2+)]
M +26 -99 plotrenderitem.cpp
M +0 -12 plotrenderitem.h
D plotrenderitemdialog.cpp
D plotrenderitemdialog.h
--- branches/work/kst/portto4/kst/src/libkstapp/cartesianrenderitem.cpp #782932:782933
@@ -46,10 +46,10 @@
context.painter = painter;
context.window = QRect(); //no idea if this should be floating point
context.penWidth = painter->pen().width(); //floating point??
- context.xLog = isXAxisLog();
- context.yLog = isYAxisLog();
- context.xLogBase = xLogBase();
- context.yLogBase = yLogBase();
+ context.xLog = plotItem()->xAxisLog();
+ context.yLog = plotItem()->yAxisLog();
+ context.xLogBase = 10.0/*plotItem()->xLogBase()*/;
+ context.yLogBase = 10.0/*plotItem()->yLogBase()*/;
context.foregroundColor = painter->pen().color();
context.backgroundColor = painter->brush().color();
@@ -63,10 +63,10 @@
context.YMax = projectionRect().bottom();
//Set the log box...
- context.x_max = isXAxisLog() ? logXHi(context.XMax, context.xLogBase) : context.XMax;
- context.y_max = isYAxisLog() ? logXHi(context.YMax, context.yLogBase) : context.YMax;
- context.x_min = isXAxisLog() ? logXLo(context.XMin, context.xLogBase) : context.XMin;
- context.y_min = isYAxisLog() ? logXLo(context.YMin, context.yLogBase) : context.YMin;
+ context.x_max = plotItem()->xAxisLog() ? logXHi(context.XMax, context.xLogBase) : context.XMax;
+ context.y_max = plotItem()->yAxisLog() ? logXHi(context.YMax, context.yLogBase) : context.YMax;
+ context.x_min = plotItem()->xAxisLog() ? logXLo(context.XMin, context.xLogBase) : context.XMin;
+ context.y_min = plotItem()->yAxisLog() ? logXLo(context.YMin, context.yLogBase) : context.YMin;
//These are the bounding box in regular QGV coord
context.Lx = plotRect().left();
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #782932:782933
@@ -877,8 +877,8 @@
if (*plotIterator) {
PlotRenderItem *renderItem = (*plotIterator)->renderItem(PlotRenderItem::Cartesian);
- renderItem->setXAxisLog(_pagePlot->PSDLogX());
- renderItem->setYAxisLog(_pagePlot->PSDLogY());
+ (*plotIterator)->setXAxisLog(_pagePlot->PSDLogX());
+ (*plotIterator)->setYAxisLog(_pagePlot->PSDLogY());
renderItem->addRelation(kst_cast<Relation>(curve));
(*plotIterator)->update();
}
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #782932:782933
@@ -82,10 +82,10 @@
memorywidget.cpp \
pictureitem.cpp \
plotitem.cpp \
+ plotitemdialog.cpp \
plotitemmanager.cpp \
plotmarkers.cpp \
plotrenderitem.cpp \
- plotrenderitemdialog.cpp \
powerspectrumdialog.cpp \
scalardialog.cpp \
scalarmodel.cpp \
@@ -172,8 +172,8 @@
memorywidget.h \
pictureitem.h \
plotitem.h \
+ plotitemdialog.h \
plotmarkers.h \
- plotrenderitemdialog.h \
plotitemmanager.h \
plotrenderitem.h \
powerspectrumdialog.h \
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #782932:782933
@@ -27,6 +27,8 @@
#include "dataobjectcollection.h"
#include "cartesianrenderitem.h"
+#include "plotitemdialog.h"
+
#include "math_kst.h"
#include "settings.h"
@@ -176,6 +178,12 @@
}
+void PlotItem::edit() {
+ PlotItemDialog editDialog(this);
+ editDialog.exec();
+}
+
+
QList<PlotRenderItem*> PlotItem::renderItems() const {
return _renderers.values();
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #782932:782933
@@ -257,6 +257,9 @@
void marginsChanged();
void updatePlotRect();
+ public Q_SLOTS:
+ virtual void edit();
+
private:
virtual void paintPlot(QPainter *painter,
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #782932:782933
@@ -17,8 +17,6 @@
#include "application.h"
#include "objectstore.h"
-#include "plotrenderitemdialog.h"
-
#include <QTime>
#include <QMenu>
#include <QStatusBar>
@@ -34,11 +32,7 @@
PlotRenderItem::PlotRenderItem(PlotItem *parentItem)
: ViewItem(parentItem->parentView()),
_xAxisZoomMode(Auto),
- _yAxisZoomMode(AutoBorder),
- _isXAxisLog(false),
- _isYAxisLog(false),
- _xLogBase(10.0),
- _yLogBase(10.0) {
+ _yAxisZoomMode(AutoBorder) {
setName(tr("Plot Render"));
setZValue(PLOTRENDER_ZVALUE);
@@ -114,50 +108,6 @@
}
-bool PlotRenderItem::isXAxisLog() const {
- return _isXAxisLog;
-}
-
-
-void PlotRenderItem::setXAxisLog(bool log) {
- _isXAxisLog = log;
- _zoomLogX->setChecked(log);
- plotItem()->setXAxisLog(log);
-}
-
-
-qreal PlotRenderItem::xLogBase() const {
- return _xLogBase;
-}
-
-
-void PlotRenderItem::setXLogBase(qreal xLogBase) {
- _xLogBase = xLogBase;
-}
-
-
-bool PlotRenderItem::isYAxisLog() const {
- return _isYAxisLog;
-}
-
-
-void PlotRenderItem::setYAxisLog(bool log) {
- _isYAxisLog = log;
- _zoomLogY->setChecked(log);
- plotItem()->setYAxisLog(log);
-}
-
-
-qreal PlotRenderItem::yLogBase() const {
- return _yLogBase;
-}
-
-
-void PlotRenderItem::setYLogBase(qreal yLogBase) {
- _yLogBase = yLogBase;
-}
-
-
QRectF PlotRenderItem::plotRect() const {
QRectF plotRect = rect();
plotRect = plotRect.normalized();
@@ -218,10 +168,6 @@
xml.writeAttribute("type", QVariant(_type).toString());
xml.writeAttribute("xzoommode", QVariant(_xAxisZoomMode).toString());
xml.writeAttribute("yzoommode", QVariant(_yAxisZoomMode).toString());
- xml.writeAttribute("xlog", QVariant(_isXAxisLog).toString());
- xml.writeAttribute("ylog", QVariant(_isYAxisLog).toString());
- xml.writeAttribute("xlogbase", QVariant(_xLogBase).toString());
- xml.writeAttribute("ylogbase", QVariant(_yLogBase).toString());
xml.writeStartElement("rect");
xml.writeAttribute("x", QVariant(projectionRect().x()).toString());
xml.writeAttribute("y", QVariant(projectionRect().y()).toString());
@@ -253,22 +199,6 @@
if (!av.isNull()) {
setYAxisZoomMode((ZoomMode)av.toString().toInt());
}
- av = attrs.value("xlog");
- if (!av.isNull()) {
- setXAxisLog(QVariant(av.toString()).toBool());
- }
- av = attrs.value("ylog");
- if (!av.isNull()) {
- setYAxisLog(QVariant(av.toString()).toBool());
- }
- av = attrs.value("xlogbase");
- if (!av.isNull()) {
- setXLogBase(av.toString().toDouble());
- }
- av = attrs.value("ylogbase");
- if (!av.isNull()) {
- setYLogBase(av.toString().toDouble());
- }
QString expectedEnd;
while (!(xml.isEndElement() && (xml.name().toString() == primaryTag))) {
@@ -315,7 +245,6 @@
void PlotRenderItem::paint(QPainter *painter) {
painter->setRenderHint(QPainter::Antialiasing, false);
- painter->drawRect(rect());
#ifdef CURVE_DRAWING_TIME
QTime time;
@@ -740,7 +669,7 @@
void PlotRenderItem::zoomNormalizeXtoY() {
qDebug() << "zoomNormalizeXtoY" << endl;
- if (isXAxisLog() || isYAxisLog())
+ if (plotItem()->xAxisLog() || plotItem()->yAxisLog())
return; //apparently we don't want to do anything here according to kst2dplot...
ZoomCommand *cmd = new ZoomNormalizeXToYCommand(this);
@@ -750,7 +679,7 @@
void PlotRenderItem::zoomLogX() {
qDebug() << "zoomLogX" << endl;
- setXAxisLog(_zoomLogX->isChecked());
+ plotItem()->setXAxisLog(_zoomLogX->isChecked());
setProjectionRect(computedProjectionRect()); //need to recompute
plotItem()->update();
}
@@ -801,7 +730,7 @@
void PlotRenderItem::zoomNormalizeYtoX() {
qDebug() << "zoomNormalizeYtoX" << endl;
- if (isXAxisLog() || isYAxisLog())
+ if (plotItem()->xAxisLog() || plotItem()->yAxisLog())
return; //apparently we don't want to do anything here according to kst2dplot...
ZoomCommand *cmd = new ZoomNormalizeYToXCommand(this);
@@ -811,7 +740,7 @@
void PlotRenderItem::zoomLogY() {
qDebug() << "zoomLogY" << endl;
- setYAxisLog(_zoomLogY->isChecked());
+ plotItem()->setYAxisLog(_zoomLogY->isChecked());
setProjectionRect(computedProjectionRect()); //need to recompute
plotItem()->update();
}
@@ -880,10 +809,10 @@
void PlotRenderItem::edit() {
- PlotRenderItemDialog editDialog(this);
- editDialog.exec();
+ plotItem()->edit();
}
+
void PlotRenderItem::updateCursor(const QPointF &pos) {
if (checkBox().contains(pos)) {
setCursor(Qt::ArrowCursor);
@@ -899,10 +828,10 @@
zoomState.projectionRect = projectionRect();
zoomState.xAxisZoomMode = xAxisZoomMode();
zoomState.yAxisZoomMode = yAxisZoomMode();
- zoomState.isXAxisLog = isXAxisLog();
- zoomState.isYAxisLog = isYAxisLog();
- zoomState.xLogBase = xLogBase();
- zoomState.yLogBase = yLogBase();
+ zoomState.isXAxisLog = plotItem()->xAxisLog();
+ zoomState.isYAxisLog = plotItem()->yAxisLog();
+ zoomState.xLogBase = 10.0;
+ zoomState.yLogBase = 10.0;
return zoomState;
}
@@ -910,10 +839,8 @@
void PlotRenderItem::setCurrentZoomState(ZoomState zoomState) {
setXAxisZoomMode(ZoomMode(zoomState.xAxisZoomMode));
setYAxisZoomMode(ZoomMode(zoomState.yAxisZoomMode));
- setXAxisLog(zoomState.isXAxisLog);
- setYAxisLog(zoomState.isYAxisLog);
- setXLogBase(zoomState.xLogBase);
- setYLogBase(zoomState.yLogBase);
+ plotItem()->setXAxisLog(zoomState.isXAxisLog);
+ plotItem()->setYAxisLog(zoomState.isYAxisLog);
setProjectionRect(zoomState.projectionRect);
}
@@ -999,7 +926,7 @@
qreal maximum;
bool unInitialized = true;
- bool axisLog = orientation == Qt::Horizontal ? isXAxisLog() : isYAxisLog();
+ bool axisLog = orientation == Qt::Horizontal ? plotItem()->xAxisLog() : plotItem()->yAxisLog();
foreach (RelationPtr relation, relationList()) {
if (relation->ignoreAutoScale())
@@ -1035,8 +962,8 @@
qreal minimum = *min;
qreal maximum = *max;
- bool axisLog = orientation == Qt::Horizontal ? isXAxisLog() : isYAxisLog();
- qreal logBase = orientation == Qt::Horizontal ? xLogBase() : yLogBase();
+ bool axisLog = orientation == Qt::Horizontal ? plotItem()->xAxisLog() : plotItem()->yAxisLog();
+ qreal logBase = 10.0/*orientation == Qt::Horizontal ? xLogBase() : yLogBase()*/;
if (axisLog) {
minimum = log10(minimum)/log10(logBase);
@@ -1180,7 +1107,7 @@
QRectF compute = item->projectionRect();
qreal dx = (item->plotItem()->xMax() - item->plotItem()->xMin())*0.10;
- if (item->isXAxisLog()) {
+ if (item->plotItem()->xAxisLog()) {
compute.setLeft(pow(10, item->plotItem()->xMin() + dx));
compute.setRight(pow(10, item->plotItem()->xMax() + dx));
} else {
@@ -1203,7 +1130,7 @@
QRectF compute = item->projectionRect();
qreal dx = (item->plotItem()->xMax() - item->plotItem()->xMin())*0.10;
- if (item->isXAxisLog()) {
+ if (item->plotItem()->xAxisLog()) {
compute.setLeft(pow(10, item->plotItem()->xMin() - dx));
compute.setRight(pow(10, item->plotItem()->xMax() - dx));
} else {
@@ -1226,7 +1153,7 @@
QRectF compute = item->projectionRect();
qreal dx = (item->plotItem()->xMax() - item->plotItem()->xMin())*0.25;
- if (item->isXAxisLog()) {
+ if (item->plotItem()->xAxisLog()) {
compute.setLeft(pow(10, item->plotItem()->xMin() - dx));
compute.setRight(pow(10, item->plotItem()->xMax() + dx));
} else {
@@ -1250,7 +1177,7 @@
QRectF compute = item->projectionRect();
qreal dx = (item->plotItem()->xMax() - item->plotItem()->xMin())*0.1666666;
- if (item->isXAxisLog()) {
+ if (item->plotItem()->xAxisLog()) {
compute.setLeft(pow(10, item->plotItem()->xMin() + dx));
compute.setRight(pow(10, item->plotItem()->xMax() - dx));
} else {
@@ -1287,7 +1214,7 @@
* values between 30 and 40.
*/
void ZoomYLocalMaximumCommand::applyZoomTo(PlotRenderItem *item) {
- qreal minimum = item->isYAxisLog() ? 0.0 : -0.1;
+ qreal minimum = item->plotItem()->yAxisLog() ? 0.0 : -0.1;
qreal maximum = 0.1;
foreach (RelationPtr relation, item->relationList()) {
if (relation->ignoreAutoScale())
@@ -1300,7 +1227,7 @@
//If the axis is in log mode, the lower extent will be the
//minimum value larger than zero.
- if (item->isYAxisLog())
+ if (item->plotItem()->yAxisLog())
minimum = minimum <= 0.0 ? min : qMin(min, minimum);
else
minimum = qMin(min, minimum);
@@ -1346,7 +1273,7 @@
QRectF compute = item->projectionRect();
qreal dy = (item->plotItem()->yMax() - item->plotItem()->yMin())*0.1;
- if (item->isYAxisLog()) {
+ if (item->plotItem()->yAxisLog()) {
compute.setTop(pow(10, item->plotItem()->yMin() + dy));
compute.setBottom(pow(10, item->plotItem()->yMax() + dy));
} else {
@@ -1371,7 +1298,7 @@
QRectF compute = item->projectionRect();
qreal dy = (item->plotItem()->yMax() - item->plotItem()->yMin())*0.1;
- if (item->isYAxisLog()) {
+ if (item->plotItem()->yAxisLog()) {
compute.setTop(pow(10, item->plotItem()->yMin() - dy));
compute.setBottom(pow(10, item->plotItem()->yMax() - dy));
} else {
@@ -1396,7 +1323,7 @@
QRectF compute = item->projectionRect();
qreal dy = (item->plotItem()->yMax() - item->plotItem()->yMin())*0.25;
- if (item->isYAxisLog()) {
+ if (item->plotItem()->yAxisLog()) {
compute.setTop(pow(10, item->plotItem()->yMin() - dy));
compute.setBottom(pow(10, item->plotItem()->yMax() + dy));
} else {
@@ -1422,7 +1349,7 @@
QRectF compute = item->projectionRect();
qreal dy = (item->plotItem()->yMax() - item->plotItem()->yMin())*0.1666666;
- if (item->isYAxisLog()) {
+ if (item->plotItem()->yAxisLog()) {
compute.setTop(pow(10, item->plotItem()->yMin() + dy));
compute.setBottom(pow(10, item->plotItem()->yMax() - dy));
} else {
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #782932:782933
@@ -60,18 +60,6 @@
ZoomMode yAxisZoomMode() const;
void setYAxisZoomMode(ZoomMode mode);
- bool isXAxisLog() const;
- void setXAxisLog(bool log);
-
- qreal xLogBase() const;
- void setXLogBase(qreal xLogBase);
-
- bool isYAxisLog() const;
- void setYAxisLog(bool log);
-
- qreal yLogBase() const;
- void setYLogBase(qreal yLogBase);
-
QRectF plotRect() const;
QRectF projectionRect() const;
More information about the Kst
mailing list