[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Fri Jan 14 05:03:50 CET 2005


CVS commit by staikos: 

postpone cleanup() calls until after plots are created - reduces code from
O(n^3) to O(n^2) for creation of plots from the data wizard.


  M +13 -11    datawizard.ui.h   1.109
  M +5 -3      ksttoplevelview.h   1.51


--- kdeextragear-2/kst/kst/datawizard.ui.h  #1.108:1.109
@@ -545,5 +545,5 @@ void DataWizard::finished()
     bool relayout = true;
     if (_onePlot->isChecked()) {
-        Kst2DPlotPtr p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName())));
+        Kst2DPlotPtr p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName(), false)));
         plots.append(p.data());
         if (_radioButtonPlotDataPSD->isChecked()) {
@@ -553,5 +553,5 @@ void DataWizard::finished()
                 w = static_cast<KstViewWindow*>(app->findWindow(n));
             }
-            Kst2DPlotPtr p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName())));
+            Kst2DPlotPtr p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName(), false)));
             plots.append(p.data());
         }
@@ -560,5 +560,5 @@ void DataWizard::finished()
         if (_radioButtonPlotDataPSD->isChecked()) {
             for (uint i = 0; i < l.count(); ++i) {
-                p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName())));
+                p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName(), false)));
                 plots.append(p.data());
             }
@@ -571,5 +571,5 @@ void DataWizard::finished()
         }
         for (uint i = 0; i < l.count(); ++i) {
-            p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName())));
+            p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName(), false)));
             plots.append(p.data());
         }
@@ -588,5 +588,5 @@ void DataWizard::finished()
         if (_radioButtonPlotDataPSD->isChecked()) {
             for (int i = 0; i < _plotNumber->value(); ++i) {
-                p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName())));
+                p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName(), false)));
                 plots.append(p.data());
             }
@@ -598,5 +598,5 @@ void DataWizard::finished()
         }
         for (int i = 0; i < _plotNumber->value(); ++i) {
-            p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName())));
+            p = kst_cast<Kst2DPlot>(w->view()->findChild(w->createPlot<Kst2DPlot>(KST::suggestPlotName(), false)));
             plots.append(p.data());
         }
@@ -772,4 +772,6 @@ void DataWizard::finished()
         w->view()->cleanup(signed(sqrt(plots.count())));
       }
+    } else if (w->view()->onGrid()) {
+        w->view()->cleanup(-1);
     }
     w->view()->paint(P_DATA);

--- kdeextragear-2/kst/kst/ksttoplevelview.h  #1.50:1.51
@@ -58,5 +58,5 @@ class KstTopLevelView : public KstViewOb
     KstViewObjectPtr pressTarget() const { return _pressTarget; }
 
-    template<class T> KstSharedPtr<T> createPlot(const QString& name);
+    template<class T> KstSharedPtr<T> createPlot(const QString& name, bool doCleanup = true);
 
     virtual bool removeChild(KstViewObjectPtr obj, bool recursive = false);
@@ -118,10 +118,12 @@ typedef KstObjectList<KstTopLevelViewPtr
 
 template<class T>
-KstSharedPtr<T> KstTopLevelView::createPlot(const QString& name) {
+KstSharedPtr<T> KstTopLevelView::createPlot(const QString& name, bool doCleanup) {
   T *plot = new T(name);
   if (_onGrid) {
     // FIXME: make this more powerful, preserve columns
     appendChild(plot);
+    if (doCleanup) {
     this->cleanup(-1); // GCC 2.95/ppc bug.  Don't touch!!!
+    }
   } else {
     QSize sz = averageChildSize();




More information about the Kst mailing list