[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Thu Aug 28 22:55:53 CEST 2008
SVN commit 854111 by fenton:
Modify update manager to support PlotItem specialized returns / PlotItem based instead of PlotRenderItem based.
Add persisted zoom mode to PlotItem on update.
M +1 -0 libkst/plotiteminterface.h
M +5 -5 libkst/updatemanager.cpp
M +3 -2 libkst/updatemanager.h
M +35 -0 libkstapp/plotitem.cpp
M +2 -0 libkstapp/plotitem.h
M +1 -1 libkstapp/plotrenderitem.cpp
--- branches/work/kst/portto4/kst/src/libkst/plotiteminterface.h #854110:854111
@@ -24,6 +24,7 @@
virtual ~PlotItemInterface();
virtual QString plotName() const = 0;
+ virtual void updateObject() = 0;
};
}
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.cpp #854110:854111
@@ -72,9 +72,9 @@
}
-void UpdateManager::requestUpdate(ObjectPtr updateObject, QGraphicsRectItem* displayObject) {
+void UpdateManager::requestUpdate(ObjectPtr updateObject, PlotItemInterface* displayObject) {
if (!_displayUpdateRequests.contains(updateObject)) {
- QList<QGraphicsRectItem*> newList;
+ QList<PlotItemInterface*> newList;
newList.append(displayObject);
_displayUpdateRequests.insert(updateObject, newList);
} else {
@@ -169,9 +169,9 @@
#if DEBUG_UPDATE_CYCLE > 0
qDebug() << "UM - All updates complete, updating plots";
#endif
- foreach (QList<QGraphicsRectItem*> objectList, _displayUpdateRequests) {
- foreach (QGraphicsRectItem* object, objectList) {
- object->update();
+ foreach (QList<PlotItemInterface*> objectList, _displayUpdateRequests) {
+ foreach (PlotItemInterface* object, objectList) {
+ object->updateObject();
}
}
_dependentUpdateRequests.clear();
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.h #854110:854111
@@ -13,6 +13,7 @@
#define UPDATEMANAGER_H
#include "object.h"
+#include "plotiteminterface.h"
#include <QGraphicsRectItem>
@@ -32,7 +33,7 @@
void requestUpdate(ObjectPtr object);
void requestUpdate(ObjectPtr updateObject, ObjectPtr object);
- void requestUpdate(ObjectPtr updateObject, QGraphicsRectItem* displayObject);
+ void requestUpdate(ObjectPtr updateObject, PlotItemInterface* displayObject);
void objectDeleted(ObjectPtr object);
void updateStarted(ObjectPtr updateObject, ObjectPtr reportingObject);
@@ -55,7 +56,7 @@
QList<ObjectPtr> _updateRequests;
QMap<ObjectPtr, int> _activeUpdates;
QMap<ObjectPtr, QList<ObjectPtr> > _dependentUpdateRequests;
- QMap<ObjectPtr, QList<QGraphicsRectItem*> > _displayUpdateRequests;
+ QMap<ObjectPtr, QList<PlotItemInterface*> > _displayUpdateRequests;
bool _delayedUpdate;
int _maxUpdate;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #854110:854111
@@ -299,6 +299,41 @@
}
+void PlotItem::updateObject() {
+#if DEBUG_UPDATE_CYCLE > 1
+ qDebug() << "UP - Updating Plot";
+#endif
+ if (xAxis()->axisZoomMode() == PlotAxis::Auto) {
+ if (yAxis()->axisZoomMode() == PlotAxis::AutoBorder || yAxis()->axisZoomMode() == PlotAxis::Auto
+ || yAxis()->axisZoomMode() == PlotAxis::SpikeInsensitive || yAxis()->axisZoomMode() == PlotAxis::MeanCentered) {
+#if DEBUG_UPDATE_CYCLE > 1
+ qDebug() << "UP - Updating Plot Projection Rect - X and Y Maximum";
+#endif
+ setProjectionRect(computedProjectionRect());
+ } else {
+#if DEBUG_UPDATE_CYCLE > 1
+ qDebug() << "UP - Updating Plot Projection Rect - X Maximum";
+#endif
+ QRectF compute = computedProjectionRect();
+ setProjectionRect(QRectF(compute.x(),
+ projectionRect().y(),
+ compute.width(),
+ projectionRect().height()));
+ }
+ } else if (yAxis()->axisZoomMode() == PlotAxis::Auto) {
+#if DEBUG_UPDATE_CYCLE > 1
+ qDebug() << "UP - Updating Plot Projection Rect - Y Maximum";
+#endif
+ QRectF compute = computedProjectionRect();
+ setProjectionRect(QRectF(projectionRect().x(),
+ compute.y(),
+ projectionRect().width(),
+ compute.height()));
+ }
+ update();
+}
+
+
QList<PlotRenderItem*> PlotItem::renderItems() const {
return _renderers.values();
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #854110:854111
@@ -171,6 +171,8 @@
virtual void addToMenuForContextEvent(QMenu &menu);
virtual bool tryShortcut(const QString &keySequence);
+ virtual void updateObject();
+
LegendItem* legend();
Q_SIGNALS:
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #854110:854111
@@ -96,7 +96,7 @@
#if DEBUG_UPDATE_CYCLE > 1
qDebug() << "UP - Curve update required by Plot for update of" << object->shortName();
#endif
- UpdateManager::self()->requestUpdate(object, this);
+ UpdateManager::self()->requestUpdate(object, plotItem());
}
More information about the Kst
mailing list