FACT++  1.0
void UIConnector::on_autoScaleColor_clicked ( )
slot

Definition at line 2139 of file RawEventsViewer.cc.

References end, i, and start().

2140 {
2141  if (!autoScaleColor->isChecked())
2142  {
2143  GLWindow->ss[0] = 0.496;
2144  GLWindow->ss[1] = 0.507;
2145  GLWindow->ss[2] = 0.518;
2146  GLWindow->ss[3] = 0.529;
2147  GLWindow->ss[4] = 0.540;;
2148  colorRange0->setValue(GLWindow->ss[0]);
2149  colorRange1->setValue(GLWindow->ss[1]);
2150  colorRange2->setValue(GLWindow->ss[2]);
2151  colorRange3->setValue(GLWindow->ss[3]);
2152  colorRange4->setValue(GLWindow->ss[4]);
2153  return;
2154  }
2155  if (!GLWindow->nRoi)
2156  return;
2157 
2158  int start = 0;
2159  int end = 1440;
2160 
2161  if (!entireCameraScale->isChecked())
2162  {
2163  start = GLWindow->selectedPixel;
2164  end = GLWindow->selectedPixel+1;
2165  if (end == 0)
2166  {
2167  start = 0;
2168  end = 1440;
2169  }
2170  }
2171 
2172  int min = 100000; //real min = -2048, int_16 = -32768 to 32767
2173  int max = -100000; //real max = 2047
2174 
2175  long average = 0;
2176  long numSamples = 0;
2177  int errorDetected = -1;
2178 
2179  for (int i=start;i<end;i++)
2180  {
2181  if (i==863)//keep crazy pixel out of the autoscale
2182  continue;
2183  for (int j=10;j<GLWindow->nRoi-50;j++)
2184  {
2185  int cValue = GLWindow->eventData[i*GLWindow->nRoi+j];
2186  if (cValue > max && cValue < 32767)
2187  max = cValue;
2188  if (cValue < min && cValue > -32768)
2189  min = cValue;
2190  if (cValue < 32767 && cValue > -32768)
2191  {
2192  average+=cValue;
2193  numSamples++;
2194  }
2195  else
2196  {
2197  errorDetected = i;
2198  }
2199 // numSamples++;
2200  }
2201  }
2202  average /= numSamples;
2203  if (errorDetected != -1)
2204  {
2205  cout << "Overflow detected at pixel " << errorDetected << " (at least)" << endl;
2206  }
2207 // cout << "min: " << min << " max: " << max << " average: " << average << endl;
2208  float minRange = (float)(min+(GLWindow->VALUES_SPAN/2))/(float)(GLWindow->VALUES_SPAN-1);
2209  float maxRange = (float)(max+(GLWindow->VALUES_SPAN/2))/(float)(GLWindow->VALUES_SPAN-1);
2210  float midRange = (float)(average+(GLWindow->VALUES_SPAN/2))/(float)(GLWindow->VALUES_SPAN-1);
2211  if (GLWindow->logScale)
2212  {
2213  minRange *= 9;
2214  maxRange *= 9;
2215 // midRange *= 9;
2216  minRange += 1;
2217  maxRange += 1;
2218 // midRange += 1;
2219  minRange = log10(minRange);
2220  maxRange = log10(maxRange);
2221 // midRange = (minRange + maxRange)/2.f;
2222  midRange = log10(midRange);
2223  }
2224 
2225  GLWindow->ss[0] = minRange;
2226  colorRange0->setValue(GLWindow->ss[0]);
2227  GLWindow->ss[4] = maxRange;
2228  colorRange4->setValue(GLWindow->ss[4]);
2229 // GLWindow->ss[2] = midRange;
2230 // range2->setValue(GLWindow->ss[2]);
2231 // GLWindow->ss[1] = (minRange+midRange)/2;
2232 // range1->setValue(GLWindow->ss[1]);
2233 // GLWindow->ss[3] = (maxRange+midRange)/2;
2234 // range3->setValue(GLWindow->ss[3]);
2235 
2236  GLWindow->ss[2] = (maxRange+minRange)/2;
2237  colorRange2->setValue(GLWindow->ss[2]);
2238 
2239  GLWindow->ss[1] = minRange+(maxRange-minRange)/4;
2240  colorRange1->setValue(GLWindow->ss[1]);
2241 
2242  GLWindow->ss[3] = minRange+3*(maxRange-minRange)/4;
2243  colorRange3->setValue(GLWindow->ss[3]);
2244 }
int start(int initState)
Definition: feeserver.c:1740
int i
Definition: db_dim_client.c:21
double end

+ Here is the call graph for this function: