[Kst] kst_1_0_branch: kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Mon Dec 6 04:06:28 CET 2004


CVS commit by staikos: 

backport histogram fixes from HEAD


  M +33 -4     ksthistogram.cpp   1.35.4.1
  M +1 -0      ksthistogram.h   1.24.4.1


--- kdeextragear-2/kst/kst/ksthistogram.cpp  #1.35:1.35.4.1
@@ -121,5 +121,6 @@ void KstHistogram::commonConstructor(con
     NBins = 2;
   }
-  Bins = new unsigned long[in_n_bins];
+  Bins = new unsigned long[NBins];
+  NS = 3*NBins+1;
 
   KstVectorPtr iv = new KstVector(in_tag+"-bins", NBins);
@@ -162,5 +165,5 @@ KstObject::UpdateType KstHistogram::upda
     double temp_xMin, temp_xMax;
     KstHistogram::AutoBin(V, &temp_NBins, &temp_xMax, &temp_xMin);
-    setNBins(temp_NBins);
+    internalSetNBins(temp_NBins);
     setXRange(temp_xMin, temp_xMax);
   }
@@ -253,5 +259,6 @@ void KstHistogram::setXRange(double xmin
 }
 
-void KstHistogram::setNBins(int in_n_bins) {
+
+void KstHistogram::internalSetNBins(int in_n_bins) {
   delete[] Bins;
 
@@ -259,10 +266,17 @@ void KstHistogram::setNBins(int in_n_bin
 
   if (NBins<2) NBins = 2;
-  Bins = new unsigned long[in_n_bins];
+  Bins = new unsigned long[NBins];
   W = (MaxX - MinX)/(double)NBins;
+  NS = 3*NBins+1;
 
   (*_bVector)->resize(NBins);
   (*_hVector)->resize(NBins);
+}
 
+
+void KstHistogram::setNBins(int in_n_bins) {
+  _realTimeAutoBin = false;
+  internalSetNBins(in_n_bins);
+  update(); // Have to update here otherwise Bins[] is invalid!
 }
 

--- kdeextragear-2/kst/kst/ksthistogram.h  #1.24:1.24.4.1
@@ -107,4 +107,5 @@ private:
 
   KstVectorMap::Iterator _bVector, _hVector;
+  void internalSetNBins(int in_n_bins);
 };
 





More information about the Kst mailing list