Bug 95117 - redraw is very inefficient
Summary: redraw is very inefficient
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.0.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: George Staikos
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-14 02:06 UTC by Andrew Walker
Modified: 2005-03-18 19:50 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2004-12-14 02:06:41 UTC
Version:           1.0.0 (using KDE KDE 3.2.1)
Installed from:    Compiled From Sources
OS:                Linux

If a curve's attributes are modified via the context menu then instead of simply redrawing the one plot, all the plots in the Kst session are redrawn (as opposed to simply being repainted).

Obviously, this can be very inefficient.
Comment 1 George Staikos 2004-12-21 07:20:14 UTC
This will be fixed as part of the update reworking that I'm doing.
Comment 2 George Staikos 2005-03-18 03:21:32 UTC
*** Bug has been marked as fixed ***.
Comment 3 George Staikos 2005-03-18 03:23:26 UTC
Oops, didn't commit this part yet.
Comment 4 George Staikos 2005-03-18 19:50:34 UTC
CVS commit by staikos: 

change the default paint mechanism to P_PAINT from P_DATA and introduce a hack
to the update thread to pass the list of changed curves in the event.  Kst2DPlot
is a mess and too dangerous to put into the update thread right now.  This hack
will go away when Kst2DPlot gets cleaned up.

BUG: 95117


  M +1 -1      kst.cpp   1.293
  M +1 -1      kst.h   1.126
  M +29 -3     kstdoc.cpp   1.154
  M +1 -1      stdinsource.cpp   1.12
  M +1 -0      threadevents.h   1.6
  M +9 -2      updatethread.cpp   1.44
  M +3 -0      updatethread.h   1.7


--- kdeextragear-2/kst/kst/kst.cpp  #1.292:1.293
@@ -1414,5 +1414,5 @@ void KstApp::paintAll(KstPaintType pt) {
   t.start();
 #endif
-  if (mdiMode() == KMdi::TabPageMode) {
+  if (mdiMode() == KMdi::TabPageMode) { // Optimization
     KstViewWindow *view = dynamic_cast<KstViewWindow*>(activeWindow());
     if (pt == P_DATA) { // what about P_PLOT?  I think it's not needed anyway

--- kdeextragear-2/kst/kst/kst.h  #1.125:1.126
@@ -123,5 +123,5 @@ class KstApp : public KMdiMainFrm {
     bool dataMode() const;
 
-    void paintAll(KstPaintType = P_DATA);
+    void paintAll(KstPaintType = P_PAINT);
 
     void EventELOGSubmitEntry(const QString& message);

--- kdeextragear-2/kst/kst/kstdoc.cpp  #1.153:1.154
@@ -38,4 +38,5 @@
 #include <kfiledialog.h>
 #include <kmessagebox.h>
+#include <kmdimainfrm.h>
 #include <kprogress.h>
 #include <ksavefile.h>
@@ -832,7 +833,32 @@ bool KstDoc::event(QEvent *e) {
     switch (te->_eventType) {
       case ThreadEvent::UpdateDataDialogs:
+        {
         //kdDebug() << "Update data dialogs" << endl;
         emit dataChanged();
+          // HACK: remove me later
+          KMdiIterator<KMdiChildView*> *it = KstApp::inst()->createIterator();
+          if (it) {
+            while (it->currentItem()) {
+              KstViewWindow *view = dynamic_cast<KstViewWindow*>(it->currentItem());
+              if (!view) {
+                it->next();
+                continue;
+              }
+
+              Kst2DPlotList pl = view->view()->findChildrenType<Kst2DPlot>(true);
+              for (Kst2DPlotList::Iterator i = pl.begin(); i != pl.end(); ++i) {
+                for (QValueList<KstBaseCurve*>::ConstIterator j = te->_curves.begin(); j != te->_curves.end(); ++j) {
+                  if ((*i)->Curves.contains(*j)) {
+                    (*i)->setDirty();
+                    break;
+                  }
+                }
+              }
+              it->next();
+            }
+            KstApp::inst()->deleteIterator(it);
+          }
         KstApp::inst()->paintAll();
+        }
         break;
       case ThreadEvent::UpdateAllDialogs:

--- kdeextragear-2/kst/kst/stdinsource.cpp  #1.11:1.12
@@ -40,5 +40,5 @@ KstStdinSource::KstStdinSource(KConfig *
   _file = new KTempFile;
   _filename = _file->name();
-  update();
+  update(); // FIXME
   _src = KstDataSource::loadSource(_filename, "ASCII");
   if (_src && _src->isValid()) {

--- kdeextragear-2/kst/kst/threadevents.h  #1.5:1.6
@@ -29,4 +29,5 @@ class ThreadEvent : public QEvent {
 
     ThreadEventType _eventType;
+    QValueList<KstBaseCurve*> _curves; // HACK: for temporary use in update reworking
 };
 

--- kdeextragear-2/kst/kst/updatethread.cpp  #1.43:1.44
@@ -87,6 +87,7 @@ void UpdateThread::run() {
       if (gotData) {
         kdDebug() << "Posting UpdateDataDialogs" << endl;
-        QApplication::postEvent(_doc,
-                       new ThreadEvent(ThreadEvent::UpdateDataDialogs));
+        ThreadEvent *e = new ThreadEvent(ThreadEvent::UpdateDataDialogs);
+        e->_curves = _updatedCurves;
+        QApplication::postEvent(_doc, e);
         // this event also triggers an implicit repaint
       } else {
@@ -128,4 +129,6 @@ bool UpdateThread::doUpdates(bool force,
   KstObject::UpdateType U = KstObject::NO_CHANGE;
 
+  _updatedCurves.clear(); // HACK
+
   if (gotData) {
     *gotData = false;
@@ -162,4 +165,8 @@ bool UpdateThread::doUpdates(bool force,
       bcp->writeUnlock();
 
+      if (ut == KstObject::UPDATE) { // HACK
+        _updatedCurves.append(bcp);
+      }
+
       if (U != KstObject::UPDATE) {
         U = ut;

--- kdeextragear-2/kst/kst/updatethread.h  #1.6:1.7
@@ -21,7 +21,9 @@
 #include <qmutex.h>
 #include <qthread.h>
+#include <qvaluelist.h>
 
 #include "kstwaitcondition.h"
 
+class KstBaseCurve;
 class KstDoc;
 
@@ -50,4 +52,5 @@ class UpdateThread : public QThread {
     int _updateCounter;
     int _updateTime;
+    QValueList<KstBaseCurve*> _updatedCurves; // HACK: temporary use in update reworking
 };