QXRD  0.11.16
Public Slots | Public Member Functions | Private Member Functions | Private Attributes | List of all members
QxrdHistogramDialog Class Reference

#include <qxrdhistogramdialog.h>

Inheritance diagram for QxrdHistogramDialog:
Inheritance graph
[legend]
Collaboration diagram for QxrdHistogramDialog:
Collaboration graph
[legend]

Public Slots

void histogramSelectionChanged (QRectF rect)
 
void updateHistogramNeeded ()
 

Public Member Functions

 QxrdHistogramDialog (QxrdHistogramDialogSettingsWPtr settings, QxrdExperimentWPtr expt, QWidget *parent)
 
virtual ~QxrdHistogramDialog ()
 
void onProcessedImageAvailable (QcepDoubleImageDataPtr image, QcepMaskDataPtr overflow)
 

Private Member Functions

void recalculateHistogram ()
 

Private Attributes

QxrdExperimentWPtr m_Experiment
 
QxrdHistogramDialogSettingsWPtr m_HistogramDialogSettings
 
QcepDoubleImageDataPtr m_Image
 

Detailed Description

Definition at line 13 of file qxrdhistogramdialog.h.

Constructor & Destructor Documentation

QxrdHistogramDialog::QxrdHistogramDialog ( QxrdHistogramDialogSettingsWPtr  settings,
QxrdExperimentWPtr  expt,
QWidget *  parent 
)
explicit

Definition at line 10 of file qxrdhistogramdialog.cpp.

References DEBUG_CONSTRUCTORS, m_HistogramDialogSettings, and qcepDebug().

12  :
13  QDockWidget(parent),
14  m_Experiment(expt),
16 {
18  printf("QxrdHistogramDialog::QxrdHistogramDialog(%p)\n", this);
19  }
20 
21  setupUi(this);
22 
24 
25  if (set) {
26  m_HistogramPlot->init(set->histogramPlotSettings());
27  }
28 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QSharedPointer< QxrdHistogramDialogSettings > QxrdHistogramDialogSettingsPtr
QxrdExperimentWPtr m_Experiment
QxrdHistogramDialogSettingsWPtr m_HistogramDialogSettings

Here is the call graph for this function:

QxrdHistogramDialog::~QxrdHistogramDialog ( )
virtual

Definition at line 30 of file qxrdhistogramdialog.cpp.

References DEBUG_CONSTRUCTORS, and qcepDebug().

31 {
33  printf("QxrdHistogramDialog::~QxrdHistogramDialog(%p)\n", this);
34  }
35 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26

Here is the call graph for this function:

Member Function Documentation

void QxrdHistogramDialog::histogramSelectionChanged ( QRectF  rect)
slot

Definition at line 44 of file qxrdhistogramdialog.cpp.

References m_HistogramDialogSettings, and recalculateHistogram().

Referenced by QxrdWindow::initialize().

45 {
47 
48  if (set) {
49  set->set_HistogramRect(rect);
50 
52  }
53 }
QSharedPointer< QxrdHistogramDialogSettings > QxrdHistogramDialogSettingsPtr
QxrdHistogramDialogSettingsWPtr m_HistogramDialogSettings

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdHistogramDialog::onProcessedImageAvailable ( QcepDoubleImageDataPtr  image,
QcepMaskDataPtr  overflow 
)

Definition at line 37 of file qxrdhistogramdialog.cpp.

References m_Image, and recalculateHistogram().

38 {
39  m_Image = image;
40 
42 }
QcepDoubleImageDataPtr m_Image

Here is the call graph for this function:

void QxrdHistogramDialog::recalculateHistogram ( )
private

Definition at line 60 of file qxrdhistogramdialog.cpp.

References DEBUG_HISTOGRAM, m_Experiment, m_HistogramDialogSettings, m_Image, and qcepDebug().

Referenced by histogramSelectionChanged(), onProcessedImageAvailable(), and updateHistogramNeeded().

61 {
63 
64  if (set && m_Image) {
66 
67  if (expt) {
68  QTime tic;
69  tic.start();
70 
71  QRectF rect = set->get_HistogramRect();
72 
73  int nsum = m_Image->get_SummedExposures();
74 
75  if (nsum < 1) {
76  nsum = 1;
77  }
78 
79  QxrdAcquisitionPtr acq(expt->acquisition());
80 
81  double satlev = 60000;
82 
83  if (acq) {
84  satlev = acq->get_OverflowLevel();
85  }
86 
87  double min = 0, max = satlev*nsum;
88 
89  const int nbins=1000;
90 
91  QcepDoubleVector x0(nbins), h0(nbins), h1(nbins);
92 
93  for (int i=0; i<nbins; i++) {
94 // double x = min+i*(max-min)/1000.0;
95  x0[i] = i*100.0/(double)nbins;
96  h0[i] = 0;
97  h1[i] = 0;
98  }
99 
100  int width = m_Image->get_Width();
101  int height= m_Image->get_Height();
102 
103  double *data = m_Image->data();
104 
105  for (int i=0; i<width; i++) {
106  for (int j=0; j<height; j++) {
107  double v = *data++;
108 
109  int n;
110 
111  if (v<min) {
112  n=0;
113  } else if (v>max) {
114  n=nbins-1;
115  } else {
116  n=(nbins-1)*(v-min)/(max-min);
117  }
118 
119  if (n<0) {
120  n=0;
121  }
122 
123  if (n>=nbins) {
124  n=nbins-1;
125  }
126 
127  h0[n]++;
128 
129  if (rect.contains(i,j)) {
130  h1[n]++;
131  }
132  }
133  }
134 
135  m_HistogramPlot->detachItems();
136 
137  QwtPlotPiecewiseCurve *pc0 = new QwtPlotPiecewiseCurve(m_HistogramPlot, "Entire Image");
138 
139  pc0->setSamples(x0, h0);
140  pc0->setPen(QPen(Qt::red));
141 
142  pc0->attach(m_HistogramPlot);
143 
144  QwtPlotPiecewiseCurve *pc1 = new QwtPlotPiecewiseCurve(m_HistogramPlot,
145  tr("[%1,%2]-[%3,%4]")
146  .arg(rect.left()).arg(rect.bottom())
147  .arg(rect.right()).arg(rect.top()));
148 
149  pc1->setSamples(x0, h1);
150  pc1->setPen(QPen(Qt::darkRed));
151 
152  pc1->attach(m_HistogramPlot);
153 
154  m_HistogramPlot->replot();
155 
156  if (qcepDebug(DEBUG_HISTOGRAM)) {
157  expt -> printMessage(tr("Histogram of data took %1 msec").arg(tic.elapsed()));
158  }
159  }
160  }
161 }
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
QSharedPointer< QxrdHistogramDialogSettings > QxrdHistogramDialogSettingsPtr
QVector< double > QcepDoubleVector
Definition: qcepmacros.h:19
QcepDoubleImageDataPtr m_Image
QxrdExperimentWPtr m_Experiment
A class which draws piecewise curves.
QxrdHistogramDialogSettingsWPtr m_HistogramDialogSettings

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdHistogramDialog::updateHistogramNeeded ( )
slot

Definition at line 55 of file qxrdhistogramdialog.cpp.

References recalculateHistogram().

Referenced by QxrdWindow::initialize().

56 {
58 }

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

QxrdExperimentWPtr QxrdHistogramDialog::m_Experiment
private

Definition at line 33 of file qxrdhistogramdialog.h.

Referenced by recalculateHistogram().

QxrdHistogramDialogSettingsWPtr QxrdHistogramDialog::m_HistogramDialogSettings
private
QcepDoubleImageDataPtr QxrdHistogramDialog::m_Image
private

Definition at line 35 of file qxrdhistogramdialog.h.

Referenced by onProcessedImageAvailable(), and recalculateHistogram().


The documentation for this class was generated from the following files: