Bug 109148 - Images are not updated in plots unless the plot is scrolled
Summary: Images are not updated in plots unless the plot is scrolled
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Rick Chern
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-16 02:03 UTC by Rick Chern
Modified: 2005-08-03 19:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Chern 2005-07-16 02:03:31 UTC
Version:            (using KDE KDE 3.3.0)

Images are not updated in plots unless the plot is scrolled/zoomed - in particular, images are blank upon loading a kst file until the plot is scrolled/zoomed.

This should be fixed after Images become BaseCurves
Comment 1 Rick Chern 2005-07-19 22:29:32 UTC
SVN commit 436470 by rchern:

Hacks within hacks to get plots with only images to update for now

CCMAIL: 109148@bugs.kde.org

 M  +17 -0     kstdoc.cpp  
 M  +1 -0      threadevents.h  
 M  +48 -1     updatethread.cpp  
 M  +2 -0      updatethread.h  


--- trunk/extragear/graphics/kst/kst/kstdoc.cpp #436469:436470
@@ -932,6 +932,23 @@
                     break;
                   }
                 }
+                // HACK: hack within hack to update plots with only images
+                if (!(*i)->dirty()) {
+                  for (QValueList<KstImage*>::ConstIterator j = te->_images.begin(); j != te->_images.end(); ++j) {
+                    const KstImageList& il = (*i)->_images;
+                    bool doBreak = false;
+                    for (KstImageList::ConstIterator k = il.begin(); k != il.end(); ++k) {
+                      if (*j == *k) {
+                        (*i)->setDirty();
+                        doBreak = true;
+                        break;  
+                      }  
+                    }
+                    if (doBreak) {
+                      break;  
+                    }  
+                  }  
+                }
               }
               it->next();
             }
--- trunk/extragear/graphics/kst/kst/threadevents.h #436469:436470
@@ -29,6 +29,7 @@
 
     ThreadEventType _eventType;
     QValueList<KstBaseCurve*> _curves; // HACK: for temporary use in update reworking
+    QValueList<KstImage*> _images; //HACK: hack too
 };
 
 
--- trunk/extragear/graphics/kst/kst/updatethread.cpp #436469:436470
@@ -23,6 +23,7 @@
 
 #include "kstdatacollection.h"
 #include "kstdoc.h"
+#include "kstimage.h"
 #include "kstrvector.h"
 #include "kstvcurve.h"
 #include "threadevents.h"
@@ -88,6 +89,7 @@
         kdDebug() << "Posting UpdateDataDialogs" << endl;
         ThreadEvent *e = new ThreadEvent(ThreadEvent::UpdateDataDialogs);
         e->_curves = _updatedCurves;
+        e->_images = _updatedImages;
         QApplication::postEvent(_doc, e);
         // this event also triggers an implicit repaint
       } else {
@@ -129,6 +131,7 @@
   KstObject::UpdateType U = KstObject::NO_CHANGE;
 
   _updatedCurves.clear(); // HACK
+  _updatedImages.clear(); // HACK
 
   if (gotData) {
     *gotData = false;
@@ -153,8 +156,19 @@
     // Must make a copy to avoid deadlock
     KstBaseCurveList cl;
     KstDataObjectList dol;
+    KstImageList il;
     kstObjectSplitList<KstDataObject, KstBaseCurve>(KST::dataObjectList, cl, dol);
-
+    il = kstObjectSubList<KstDataObject,KstImage>(dol);
+    // testing
+//     printf("dol has: \n");
+//     for (KstDataObjectList::ConstIterator i = dol.begin(); i != dol.end(); ++i) {
+//       printf("%s\n", (*i)->tagName().latin1());  
+//     }
+//     printf("il has: \n");
+//     for (KstImageList::ConstIterator i = il.begin(); i != il.end(); ++i) {
+//       printf("%s\n", (*i)->tagName().latin1());  
+//     }
+    
     // Update all curves
     for (uint i = 0; i < cl.count(); ++i) {
       KstBaseCurvePtr bcp = cl[i];
@@ -186,7 +200,40 @@
         return U == KstObject::UPDATE;
       }
     }
+    
+    // update all images too
+    for (uint i = 0; i < il.count(); ++i) {
+      KstImagePtr ip = il[i];
+      assert(ip.data());
+#if UPDATEDEBUG > 1
+      kdDebug() << "updating image: " << (void*)ip << " - " << ip->tagName() << endl;
+#endif
+      ip->writeLock();
+      KstObject::UpdateType ut = ip->update(_updateCounter);
+      ip->writeUnlock();
 
+      if (ut == KstObject::UPDATE) { // HACK
+        _updatedImages.append(ip);
+      }
+
+      if (U != KstObject::UPDATE) {
+        U = ut;
+        if (U == KstObject::UPDATE) {
+#if UPDATEDEBUG > 0
+          kdDebug() << "Image " << ip->tagName() << " said UPDATE" << endl;
+#endif
+        }
+      }
+
+      if (_done || (_paused && !force)) {
+#if UPDATEDEBUG > 1
+        kdDebug() << "5 Returning from scan with U=" << (int)U << endl;
+#endif
+        return U == KstObject::UPDATE;
+      }
+    }
+    
+
     // Update all data objects
     for (uint i = 0; i < dol.count(); ++i) {
       KstDataObjectPtr dp = dol[i];
--- trunk/extragear/graphics/kst/kst/updatethread.h #436469:436470
@@ -25,6 +25,7 @@
 #include "kstwaitcondition.h"
 
 class KstBaseCurve;
+class KstImage;
 class KstDoc;
 
 class UpdateThread : public QThread {
@@ -52,6 +53,7 @@
     int _updateCounter;
     int _updateTime;
     QValueList<KstBaseCurve*> _updatedCurves; // HACK: temporary use in update reworking
+    QValueList<KstImage*> _updatedImages; // HACK: hack too 
 };
 
 
Comment 2 George Staikos 2005-07-25 19:38:51 UTC
  This hack is quite a performance concern so we need to keep a focus to 
remove it ASAP.
Comment 3 Rick Chern 2005-08-03 19:30:52 UTC
Hacks on hacks removed as Images are now KstBaseCurves.