6 #include <qwt_plot_curve.h>
7 #include <qwt_plot_picker.h>
8 #include <qwt_plot_zoomer.h>
9 #include <qwt_plot_panner.h>
10 #include <qwt_plot_magnifier.h>
11 #include <qwt_symbol.h>
12 #include <qwt_legend.h>
13 #include <QMetaMethod>
23 m_ObjectNamer(this,
"centeringGraph"),
36 insertLegend(
m_Legend, QwtPlot::RightLegend);
127 int width =img->get_Width();
128 int height=img->get_Height();
130 int len = (int) sqrt((
double)(width*width+height*height));
132 detachItems(QwtPlotItem::Rtti_PlotCurve);
133 detachItems(QwtPlotItem::Rtti_PlotMarker);
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);
143 double distance = cf->get_DetectorDistance();
145 if (distance <= 0) distance = 1000;
147 double plx = cf->get_DetectorXPixelSize();
148 double ply = cf->get_DetectorYPixelSize();
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);
161 for (
int n = 0; n<=len; n++) {
162 double twoTheta = cf->getTwoTheta(cx,cy,distance,x,y,plx,ply,cosbeta,sinbeta,cosrot,sinrot);
164 int ix = (int)qRound(x);
165 int iy = (int)qRound(y);
167 if (ix >= 0 && iy >= 0 && ix < width && iy < height) {
168 double v = img->value(ix,iy);
173 mv = mask->maskValue(ix,iy);
188 for (
int n = 0; n<=len; n++) {
189 double delx = (x - cx)*plx/1000.0;
190 double dely = (y - cy)*ply/1000.0;
192 double radius = sqrt(delx*delx + dely*dely);
193 double twoTheta = atan2(radius, distance)*180.0/M_PI;
195 int ix = (int)qRound(x);
196 int iy = (int)qRound(y);
198 if (ix >= 0 && iy >= 0 && ix < width && iy < height) {
199 double v = img->value(ix,iy);
204 mv = mask->maskValue(ix,iy);
223 double angdeg = 180*(ang)/M_PI;
229 pen.setColor(QColor::fromHsv((
int) angdeg, 255, 255));
231 QwtSymbol *s =
new QwtSymbol();
233 s->setStyle(QwtSymbol::Rect);
242 QString title = QString(
"Center:%1:").arg(img->get_Title());
243 title += QString(
"(%1,%2):").arg(cx).arg(cy);
247 setAxisTitle(xBottom,
"2Theta (deg)");
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QWeakPointer< QcepPlotSettings > QcepPlotSettingsWPtr
void onCenterYChanged(double cy)
void onCenterXChanged(double cx)
void onParameterChanged()
QSharedPointer< QxrdDataProcessor > QxrdDataProcessorPtr
QxrdCenterFinderPlot(QWidget *parent=0)
void init(QcepPlotSettingsWPtr settings)
QxrdCenterFinderWPtr m_CenterFinder
void printMeasuredPolygon(QVector< QPointF > poly)
void onCenterChanged(double cx, double cy)
A class which draws piecewise curves.
void init(QcepPlotSettingsWPtr settings)
QVector< double > m_YData
void onMaskedImageAvailable(QcepDoubleImageDataPtr image, QcepMaskDataPtr mask)
QxrdDataProcessorWPtr m_DataProcessor
QcepPlotMeasurerPtr m_Measurer
QVector< double > m_XData
virtual void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())=0
QcepApplication * g_Application
QSharedPointer< QcepMaskData > QcepMaskDataPtr
void setWindow(QxrdWindow *win)
void onProcessedImageAvailable(QcepDoubleImageDataPtr image)
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr