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

#include <qxrdcenterfinderplot.h>

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

Public Slots

void onParameterChanged ()
 
void onCenterXChanged (double cx)
 
void onCenterYChanged (double cy)
 
void onCenterChanged (double cx, double cy)
 
void onCenterChanged (QPointF c)
 
void onProcessedImageAvailable (QcepDoubleImageDataPtr image)
 
void onMaskedImageAvailable (QcepDoubleImageDataPtr image, QcepMaskDataPtr mask)
 
- Public Slots inherited from QcepPlot
virtual void autoScale ()
 
void printGraph ()
 
void zoomIn ()
 
void zoomOut ()
 
void enableZooming ()
 
void enableMeasuring ()
 
virtual void onLegendClicked (const QVariant &itemInfo, int index)
 
virtual void onLegendChecked (const QVariant &itemInfo, bool on, int index)
 
void setXAxisLog (bool isLog)
 
void setYAxisLog (bool isLog)
 
void setX2AxisLog (bool isLog)
 
void setY2AxisLog (bool isLog)
 
void setLogAxis (int axis, int isLog)
 
int logAxis (int axis)
 

Public Member Functions

 QxrdCenterFinderPlot (QWidget *parent=0)
 
void init (QcepPlotSettingsWPtr settings)
 
void setWindow (QxrdWindow *win)
 
- Public Member Functions inherited from QcepPlot
 QcepPlot (QWidget *parent=0)
 
virtual ~QcepPlot ()
 
void init (QcepPlotSettingsWPtr settings)
 
void setPlotCurveStyle (int index, QwtPlotCurve *curve)
 
virtual QwtText trackerTextF (const QPointF &pos)
 
void contextMenuEvent (QContextMenuEvent *event)
 
void updateZoomer ()
 

Private Attributes

QcepObjectNamer m_ObjectNamer
 
QVector< double > m_XData
 
QVector< double > m_YData
 
QxrdWindowm_Window
 
QxrdDataProcessorWPtr m_DataProcessor
 
QxrdCenterFinderWPtr m_CenterFinder
 
bool m_FirstTime
 

Additional Inherited Members

- Protected Attributes inherited from QcepPlot
QcepPlotSettingsWPtr m_PlotSettings
 
QwtLegend * m_Legend
 
QwtPlotZoomer * m_Zoomer
 
QwtPlotPanner * m_Panner
 
QwtPlotMagnifier * m_Magnifier
 
QcepPlotMeasurerPtr m_Measurer
 
int m_IsLog [QwtPlot::axisCnt]
 

Detailed Description

Definition at line 16 of file qxrdcenterfinderplot.h.

Constructor & Destructor Documentation

QxrdCenterFinderPlot::QxrdCenterFinderPlot ( QWidget *  parent = 0)

Definition at line 21 of file qxrdcenterfinderplot.cpp.

22  : QcepPlot(parent),
23  m_ObjectNamer(this, "centeringGraph"),
24  m_Window(),
27  m_FirstTime(true)
28 {
29 }
QcepPlot(QWidget *parent=0)
Definition: qcepplot.cpp:18
QxrdCenterFinderWPtr m_CenterFinder
QcepObjectNamer m_ObjectNamer
QxrdDataProcessorWPtr m_DataProcessor

Member Function Documentation

void QxrdCenterFinderPlot::init ( QcepPlotSettingsWPtr  settings)

Definition at line 31 of file qxrdcenterfinderplot.cpp.

References QcepPlot::init(), and QcepPlot::m_Legend.

32 {
33  QcepPlot::init(settings);
34 
35  if (m_Legend) {
36  insertLegend(m_Legend, QwtPlot::RightLegend);
37  }
38 }
QwtLegend * m_Legend
Definition: qcepplot.h:58
void init(QcepPlotSettingsWPtr settings)
Definition: qcepplot.cpp:36

Here is the call graph for this function:

void QxrdCenterFinderPlot::onCenterChanged ( double  cx,
double  cy 
)
slot

Definition at line 116 of file qxrdcenterfinderplot.cpp.

References QcepPlot::autoScale(), g_Application, m_CenterFinder, m_FirstTime, m_Window, m_XData, m_YData, QcepPlot::m_Zoomer, and QcepApplication::printMessage().

Referenced by onCenterChanged(), onCenterXChanged(), onCenterYChanged(), onMaskedImageAvailable(), onParameterChanged(), and onProcessedImageAvailable().

117 {
118  QxrdWindow *wp = m_Window;
120 
121  if (wp && cf) {
122  try {
123  QcepDoubleImageDataPtr img = wp -> data();
124  QcepMaskDataPtr mask = wp -> mask();
125 
126  if (img /* && mask*/) {
127  int width =img->get_Width();
128  int height=img->get_Height();
129 
130  int len = (int) sqrt((double)(width*width+height*height));
131 
132  detachItems(QwtPlotItem::Rtti_PlotCurve);
133  detachItems(QwtPlotItem::Rtti_PlotMarker);
134 
135  QPen pen;
136 
137  for (double ang=0; ang<2*M_PI; ang+=M_PI/36) {
138  double x = cx, y = cy;
139  double dx = cos(ang);
140  double dy = sin(ang);
141  int nn=0;
142 
143  double distance = cf->get_DetectorDistance();
144 
145  if (distance <= 0) distance = 1000;
146 
147  double plx = cf->get_DetectorXPixelSize();
148  double ply = cf->get_DetectorYPixelSize();
149 
150  m_XData.resize(len);
151  m_YData.resize(len);
152 
153  if (cf->get_ImplementTilt()) {
154  double rot = cf->get_TiltPlaneRotation()*M_PI/180.0;
155  double sinrot = sin(rot);
156  double cosrot = cos(rot);
157  double beta = cf->get_DetectorTilt()*M_PI/180.0;
158  double sinbeta = sin(beta);
159  double cosbeta = cos(beta);
160 
161  for (int n = 0; n<=len; n++) {
162  double twoTheta = cf->getTwoTheta(cx,cy,distance,x,y,plx,ply,cosbeta,sinbeta,cosrot,sinrot);
163 
164  int ix = (int)qRound(x);
165  int iy = (int)qRound(y);
166 
167  if (ix >= 0 && iy >= 0 && ix < width && iy < height) {
168  double v = img->value(ix,iy);
169 
170  bool mv = true;
171 
172  if (mask) {
173  mv = mask->maskValue(ix,iy);
174  }
175 
176  if (mv) {
177  m_XData[nn] = twoTheta;
178  m_YData[nn] = v;
179 
180  nn++;
181  }
182  }
183 
184  x += dx;
185  y += dy;
186  }
187  } else {
188  for (int n = 0; n<=len; n++) {
189  double delx = (x - cx)*plx/1000.0;
190  double dely = (y - cy)*ply/1000.0;
191 
192  double radius = sqrt(delx*delx + dely*dely);
193  double twoTheta = atan2(radius, distance)*180.0/M_PI;
194 
195  int ix = (int)qRound(x);
196  int iy = (int)qRound(y);
197 
198  if (ix >= 0 && iy >= 0 && ix < width && iy < height) {
199  double v = img->value(ix,iy);
200 
201  bool mv = true;
202 
203  if (mask) {
204  mv = mask->maskValue(ix,iy);
205  }
206 
207  if (mv) {
208  m_XData[nn] = twoTheta;
209  m_YData[nn] = v;
210 
211  nn++;
212  }
213  }
214 
215  x += dx;
216  y += dy;
217  }
218  }
219 
220  m_XData.resize(nn);
221  m_YData.resize(nn);
222 
223  double angdeg = 180*(ang)/M_PI;
224 
225  QwtPlotCurve *pc = new QwtPlotPiecewiseCurve(this,QString("%1").arg(180*(ang)/M_PI));
226 
227  pc->setSamples(m_XData, m_YData);
228  // pc->setStyle(QwtPlotCurve::Dots);
229  pen.setColor(QColor::fromHsv((int) angdeg, 255, 255));
230 
231  QwtSymbol *s = new QwtSymbol();
232 
233  s->setStyle(QwtSymbol::Rect);
234  s->setSize(3,3);
235  s->setPen(pen);
236 
237  pc->setSymbol(s);
238  pc->setPen(pen);
239  pc->attach(this);
240  }
241 
242  QString title = QString("Center:%1:").arg(img->get_Title());
243  title += QString("(%1,%2):").arg(cx).arg(cy);
244 
245  setTitle(title);
246 
247  setAxisTitle(xBottom, "2Theta (deg)");
248 
249  if (m_Zoomer && m_Zoomer -> zoomRectIndex() == 0) {
250  m_Zoomer -> setZoomBase();
251  }
252 
253  if (m_FirstTime) {
254  autoScale();
255  m_FirstTime = false;
256  } else {
257  replot();
258  }
259  }
260  }
261 
262  catch(...) {
263  if (g_Application) {
264  g_Application->printMessage("QxrdCenterFinderPlot::onCenterChanged failed");
265  }
266  }
267  }
268 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdCenterFinderWPtr m_CenterFinder
virtual void autoScale()
Definition: qcepplot.cpp:188
QwtPlotZoomer * m_Zoomer
Definition: qcepplot.h:59
A class which draws piecewise curves.
QVector< double > m_YData
QVector< double > m_XData
virtual void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())=0
QcepApplication * g_Application
QSharedPointer< QcepMaskData > QcepMaskDataPtr
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdCenterFinderPlot::onCenterChanged ( QPointF  c)
slot

Definition at line 111 of file qxrdcenterfinderplot.cpp.

References onCenterChanged().

112 {
113  onCenterChanged(c.x(), c.y());
114 }
void onCenterChanged(double cx, double cy)

Here is the call graph for this function:

void QxrdCenterFinderPlot::onCenterXChanged ( double  cx)
slot

Definition at line 93 of file qxrdcenterfinderplot.cpp.

References m_CenterFinder, and onCenterChanged().

Referenced by QxrdWindow::initialize().

94 {
96 
97  if (cf) {
98  onCenterChanged(cx, cf -> get_CenterY());
99  }
100 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdCenterFinderWPtr m_CenterFinder
void onCenterChanged(double cx, double cy)

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdCenterFinderPlot::onCenterYChanged ( double  cy)
slot

Definition at line 102 of file qxrdcenterfinderplot.cpp.

References m_CenterFinder, and onCenterChanged().

Referenced by QxrdWindow::initialize().

103 {
105 
106  if (cf) {
107  onCenterChanged(cf -> get_CenterX(), cy);
108  }
109 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdCenterFinderWPtr m_CenterFinder
void onCenterChanged(double cx, double cy)

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdCenterFinderPlot::onMaskedImageAvailable ( QcepDoubleImageDataPtr  image,
QcepMaskDataPtr  mask 
)
slot

Definition at line 84 of file qxrdcenterfinderplot.cpp.

References m_CenterFinder, and onCenterChanged().

85 {
87 
88  if (cf) {
89  onCenterChanged(cf -> get_CenterX(), cf -> get_CenterY());
90  }
91 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdCenterFinderWPtr m_CenterFinder
void onCenterChanged(double cx, double cy)

Here is the call graph for this function:

void QxrdCenterFinderPlot::onParameterChanged ( )
slot

Definition at line 66 of file qxrdcenterfinderplot.cpp.

References m_CenterFinder, and onCenterChanged().

Referenced by setWindow().

67 {
69 
70  if (cf) {
71  onCenterChanged(cf -> get_CenterX(), cf -> get_CenterY());
72  }
73 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdCenterFinderWPtr m_CenterFinder
void onCenterChanged(double cx, double cy)

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdCenterFinderPlot::onProcessedImageAvailable ( QcepDoubleImageDataPtr  image)
slot

Definition at line 75 of file qxrdcenterfinderplot.cpp.

References m_CenterFinder, and onCenterChanged().

76 {
78 
79  if (cf) {
80  onCenterChanged(cf -> get_CenterX(), cf -> get_CenterY());
81  }
82 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QxrdCenterFinderWPtr m_CenterFinder
void onCenterChanged(double cx, double cy)

Here is the call graph for this function:

void QxrdCenterFinderPlot::setWindow ( QxrdWindow win)

Definition at line 40 of file qxrdcenterfinderplot.cpp.

References m_CenterFinder, m_DataProcessor, QcepPlot::m_Measurer, m_Window, onParameterChanged(), QxrdCenterFinder::parameterChanged(), and QxrdDataProcessorBase::printMeasuredPolygon().

41 {
42  m_Window = win;
43 
44  QxrdWindow *wp = m_Window;
45 
46  if (wp) {
47  m_DataProcessor = wp -> dataProcessor();
48  }
49 
51 
52  if (dp) {
53  m_CenterFinder = dp -> centerFinder();
54 
55  connect(m_Measurer, (void (QcepPlotMeasurer::*)( const QVector<QPointF> &)) &QcepPlotMeasurer::selected,
57 
59 
60  if (cf) {
62  }
63  }
64 }
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QSharedPointer< QxrdDataProcessor > QxrdDataProcessorPtr
QxrdCenterFinderWPtr m_CenterFinder
void printMeasuredPolygon(QVector< QPointF > poly)
void parameterChanged()
QxrdDataProcessorWPtr m_DataProcessor
QcepPlotMeasurerPtr m_Measurer
Definition: qcepplot.h:62

Here is the call graph for this function:

Member Data Documentation

QxrdCenterFinderWPtr QxrdCenterFinderPlot::m_CenterFinder
private
QxrdDataProcessorWPtr QxrdCenterFinderPlot::m_DataProcessor
private

Definition at line 39 of file qxrdcenterfinderplot.h.

Referenced by setWindow().

bool QxrdCenterFinderPlot::m_FirstTime
private

Definition at line 41 of file qxrdcenterfinderplot.h.

Referenced by onCenterChanged().

QcepObjectNamer QxrdCenterFinderPlot::m_ObjectNamer
private

Definition at line 36 of file qxrdcenterfinderplot.h.

QxrdWindow* QxrdCenterFinderPlot::m_Window
private

Definition at line 38 of file qxrdcenterfinderplot.h.

Referenced by onCenterChanged(), and setWindow().

QVector<double> QxrdCenterFinderPlot::m_XData
private

Definition at line 37 of file qxrdcenterfinderplot.h.

Referenced by onCenterChanged().

QVector<double> QxrdCenterFinderPlot::m_YData
private

Definition at line 37 of file qxrdcenterfinderplot.h.

Referenced by onCenterChanged().


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