CFEL - ASG Software Suite  2.5.0
CASS
track_zoomer_2d.cpp
Go to the documentation of this file.
1 // Copyright (C) 2013 Lutz Foucar
2 
3 /**
4  * @file track_zoomer_2d.cpp contains zoomer for a 2d plot with tracking information
5  *
6  * @author Lutz Foucar
7  */
8 #include <QtCore/QDebug>
9 #include <QtCore/QPoint>
10 
11 #if QT_VERSION >= 0x050000
12 #include <QtWidgets/QStatusBar>
13 #else
14 #include <QtGui/QStatusBar>
15 #endif
16 
17 #include <cmath>
18 
19 #include "track_zoomer_2d.h"
20 
21 #include "two_d_viewer_data.h"
22 
23 using namespace jocassview;
24 using namespace std;
25 
27  : ScrollZoomer(canvas),
28  _data(0),
29  _statusbar(0)
30 {
31  setTrackerMode(AlwaysOn);
32 }
33 
34 QwtText TrackZoomer2D::trackerTextF(const QPointF &pos) const
35 {
36  QString text_string;
37  if (_data)
38  {
39  text_string = "x:" + QString::number(pos.x()) + " , " +
40  "y:" + QString::number(pos.y()) + " , " +
41  "z:" + QString::number(_data->value(pos.x(),pos.y()));
42  if (!qFuzzyIsNull(_wavelength_A) &&
43  !qFuzzyIsNull(_cameraDistance_cm) &&
44  !qFuzzyIsNull(_pixelsize_um))
45  {
46  const double x_cm = _pixelsize_um * 1e-4 * pos.x();
47  const double y_cm = _pixelsize_um * 1e-4 * pos.y();
48  const double radius_cm = sqrt(x_cm*x_cm + y_cm*y_cm);
49  const double Q =
50  2. / _wavelength_A * sin(0.5*atan(radius_cm/_cameraDistance_cm));
51  const double d = 1. / Q;
52  text_string.append(" , D:" + QString::number(d) + "A");
53  }
54  }
55 
56  if (_statusbar)
57  _statusbar->showMessage(text_string);
58 
59  QColor bg(Qt::white);
60  bg.setAlpha(200);
61 
62  QwtText text(text_string);
63  text.setBackgroundBrush( QBrush( bg ));
64  return text;
65 }
66 
68 {
69  _data = data;
70 }
71 
72 void TrackZoomer2D::setWavelength_A(double wavelength_A)
73 {
74  _wavelength_A = wavelength_A;
75 }
76 
77 void TrackZoomer2D::setCameraDistance_cm(double cameradistance_cm)
78 {
79  _cameraDistance_cm = cameradistance_cm;
80 }
81 
82 
83 void TrackZoomer2D::setPixelSize_um(double pixelsize_um)
84 {
85  _pixelsize_um = pixelsize_um;
86 }
87 
89 {
90  _statusbar = statusbar;
91 }
contains zoomer for a 2d plot with tracking information
TrackZoomer2D(QWidget *canvas)
constructor
showMessage(const QString &message, int timeout=0)
contains the wrappe of the data for the 2d viewer
void setWavelength_A(double wavelength_A)
set the wavelength that is needed of the optional resolution calculation
QStatusBar * _statusbar
pointer to the statusbar to put the text to
setAlpha(int alpha)
STL namespace.
void setCameraDistance_cm(double cameradistance_cm)
set the camera distance that is needed of the optional resolution calculation
double _wavelength_A
the wavelength in Angstroem (for resolution determination)
number(long n, int base=10)
append(const QString &str)
void setPixelSize_um(double pixelsize_um)
set the size of a pixel in micro meters
virtual QwtText trackerTextF(const QPointF &pos) const
change the tracker text
the 2d data wrapper
TwoDViewerData * _data
the data
auxiliary data[Processor]
virtual double value(double x, double y) const
return the value of the data at point x,y
void setData(TwoDViewerData *data)
set the data to retrieve the values from
void setStatusBar(QStatusBar *statusbar)
set the statusbar pointer
double _cameraDistance_cm
the cameraDistance in cm (for resolution determination)
double _pixelsize_um
the pixel size in micro meters (for resolution determination)