[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Fri Mar 26 02:31:29 CET 2010
SVN commit 1107563 by netterfield:
Prevent object updates from squeezing out view updates.
M +0 -6 devel-docs/Kst2Specs/Bugs
M +14 -14 src/libkst/updatemanager.cpp
M +6 -6 src/libkst/updatemanager.h
M +1 -32 src/libkstapp/mainwindow.cpp
M +0 -2 src/libkstapp/mainwindow.h
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Bugs #1107562:1107563
@@ -14,12 +14,6 @@
--------------------
-Text for labels and axes is rendered (anti-aliased) non-uniformly. One
-plot may look sharp whereas the plot immediately below it will have text
-that looks blurry (even out of focus).
-
---------------------
-
When in data mode, the position of the data mode indicator and the
values in the bottom status bar only update if you move the mouse. When
live data is scrolling by and the mouse is still, the data mode
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.cpp #1107562:1107563
@@ -9,28 +9,18 @@
* *
***************************************************************************/
-#include "../libkstapp/tabwidget.h"
#include "updatemanager.h"
#include "primitive.h"
#include "datasource.h"
#include "objectstore.h"
-//#include "application.h"
-//#include "document.h"
#include <QCoreApplication>
#include <QTimer>
#include <QDebug>
-#define MAX_UPDATES 2000
+#define DEFAULT_MIN_UPDATE_PERIOD 2000
-#define BENCHMARK 0
-
-#if BENCHMARK
- QTime bench_time, benchtmp;
- int b1 = 0, b2 = 0;
-#endif
-
namespace Kst {
static UpdateManager *_self = 0;
@@ -51,10 +41,11 @@
UpdateManager::UpdateManager() {
_serial = 0;
- _maxUpdate = MAX_UPDATES;
+ _minUpdatePeriod = DEFAULT_MIN_UPDATE_PERIOD;
_paused = false;
_store = 0;
_delayedUpdateScheduled = false;
+ _updateInProgress = false;
_time.start();
}
@@ -68,6 +59,10 @@
}
void UpdateManager::doUpdates(bool forceImmediate) {
+ if (_delayedUpdateScheduled && !forceImmediate) {
+ return;
+ }
+
if (!_store) {
return;
}
@@ -77,13 +72,18 @@
}
int dT = _time.elapsed();
- if ((dT<_maxUpdate) && (!forceImmediate)) {
+ if (((dT<_minUpdatePeriod) || (_updateInProgress)) && (!forceImmediate)) {
if (!_delayedUpdateScheduled) {
_delayedUpdateScheduled = true;
- QTimer::singleShot(_maxUpdate-dT, this, SLOT(delayedUpdates()));
+ int deferTime = _minUpdatePeriod-dT;
+ if (deferTime <= 0) {
+ deferTime = 20; // if an update is already in progess, wait this long to check again.
+ }
+ QTimer::singleShot(deferTime, this, SLOT(delayedUpdates()));
}
return;
}
+ _updateInProgress = true;
_time.restart();
_serial++;
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.h #1107562:1107563
@@ -19,7 +19,6 @@
namespace Kst {
class ObjectStore;
-class TabWidget;
class UpdateManager : public QObject
{
@@ -27,18 +26,19 @@
public:
static UpdateManager *self();
- void setMinimumUpdatePeriod(const int period) { _maxUpdate = period; }
- int minimumUpdatePeriod() { return _maxUpdate; }
+ void setMinimumUpdatePeriod(const int period) { _minUpdatePeriod = period; }
+ int minimumUpdatePeriod() { return _minUpdatePeriod; }
void setPaused(bool paused) { _paused = paused;}
bool paused() { return _paused; }
void setStore(ObjectStore *store) {_store = store;}
- void setTabWidget(TabWidget *tabWidget) {_tabWidget = tabWidget;}
+
public Q_SLOTS:
void doUpdates(bool forceImmediate = false);
void delayedUpdates();
+ void viewItemUpdateFinished() { _updateInProgress = false; }
Q_SIGNALS:
void objectsUpdated(qint64 serial);
@@ -51,12 +51,12 @@
private:
bool _delayedUpdate;
- int _maxUpdate;
+ int _minUpdatePeriod;
bool _paused;
bool _delayedUpdateScheduled;
+ bool _updateInProgress;
qint64 _serial;
ObjectStore *_store;
- TabWidget *_tabWidget;
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1107562:1107563
@@ -56,15 +56,7 @@
#include <QtGui>
-// Enable Demo Vector Model 0 Disabled 1 Enabled.
-#define DEMO_VECTOR_MODEL 0
-#if DEMO_VECTOR_MODEL
-#include "equation.h"
-#include "generatedvector.h"
-#endif
-
-
namespace Kst {
MainWindow::MainWindow() :
@@ -633,23 +625,6 @@
DialogLauncher::self()->showCSDDialog();
}
-void MainWindow::demoModel() {
-#if DEMO_VECTOR_MODEL
- Q_ASSERT(document() && document()->objectStore());
- GeneratedVectorPtr gv = kst_cast<GeneratedVector>(document()->objectStore()->createObject<GeneratedVector>());
- Q_ASSERT(gv);
- gv->changeRange(0, 100, 1000);
- EquationPtr ep = kst_cast<Equation>(document()->objectStore()->createObject<Equation>());
- Q_ASSERT(ep);
- ep->setExistingXVector(VectorPtr(gv), false);
- ep->setEquation("x^2");
- ep->writeLock();
- ep->update();
- ep->unlock();
-#endif
-}
-
-
void MainWindow::createActions() {
_undoAct = _undoGroup->createUndoAction(this);
_undoAct->setShortcut(tr("Ctrl+Z"));
@@ -987,13 +962,6 @@
_helpMenu->addSeparator();
_helpMenu->addAction(_aboutAct);
-#if DEMO_VECTOR_MODEL
- QMenu *demoMenu = menuBar()->addMenu("&Demo");
-
- QAction *demoModel = new QAction("Vector model", this);
- connect(demoModel, SIGNAL(triggered()), this, SLOT(demoModel()));
- demoMenu->addAction(demoModel);
-#endif
}
@@ -1214,6 +1182,7 @@
_tabWidget->currentView()->update();
}
+ QTimer::singleShot(20, UpdateManager::self(), SLOT(viewItemUpdateFinished()));
}
void MainWindow::showVectorEditor() {
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #1107562:1107563
@@ -116,8 +116,6 @@
void createImage();
void createSpectogram();
- void demoModel();
-
void performHeavyStartupActions();
void cleanup();
More information about the Kst
mailing list