3f36b18e
David Mayerich
Adding planewave ...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
#include "qtMainDialog.h"
#include <iostream>
qtMainDialog::qtMainDialog(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
outfile = "ui-out.bmp";
}
qtMainDialog::~qtMainDialog()
{
updating = false;
}
void qtMainDialog::closeEvent(QCloseEvent *event)
{
std::cout<<"Exiting"<<std::endl;
exit(0);
}
/********************************
Populate the user interface
********************************/
void qtMainDialog::populateUi()
{
updating = true;
//get the normal for the image plane
bsVector n = SCOPE->nf.pos.n();
ui.spinNx->setValue(n[0]);
ui.spinNy->setValue(n[1]);
ui.spinNz->setValue(n[2]);
//get the center point for the image plane
bsPoint c = SCOPE->nf.pos.p(0.5, 0.5);
ui.spinCx->setValue(c[0]);
ui.spinCy->setValue(c[1]);
ui.spinCz->setValue(c[2]);
//get the plane size (in microns)
ptype S = SCOPE->nf.pos.X.len();
ptype pad_div = SCOPE->padding * 2 + 1;
S /= pad_div;
ui.spinS->setValue(S);
//get the detector resolution
ui.spinR->setValue(SCOPE->Ud.R[0]);
updating = false;
}
/*********************************
Change the image plane position
*********************************/
void qtMainDialog::positionImage()
{
if(updating) return;
//get the plane normal
bsVector n(ui.spinNx->value(), ui.spinNy->value(), ui.spinNz->value());
//get the plane center point
bsPoint c(ui.spinCx->value(), ui.spinCy->value(), ui.spinCz->value());
//get the plane orientation
ptype theta = ui.spinTheta->value();
//get the plane size
ptype S = ui.spinS->value() * (2 * SCOPE->padding + 1);
//create a new image plane
SCOPE->nf.pos = rts::quad<ptype, 3>(c, n, S, S, theta);
}
/*********************************
Render an image
*********************************/
void qtMainDialog::renderImage()
{
//run the near-field simulation
SCOPE->SimulateScattering();
//determine the colormap type
rts::colormapType cmap = rts::cmGrayscale;
if( ui.cmbColormap->currentText() == tr("brewer") )
cmap = rts::cmBrewer;
else
cmap = rts::cmGrayscale;
//near field rendering
if( ui.radDisplayNearfield->isChecked() )
{
scalarslice S;
bool positive_vals = false;
if( ui.cmbDisplayNearfield->currentText() == tr("magnitude") )
{
std::cout<<"magnitude"<<std::endl;
S = SCOPE->nf.U.Mag();
positive_vals = true;
//S.toImage(outfile.toStdString(), positive_vals, cmap);
}
else if( ui.cmbDisplayNearfield->currentText() == tr("real") )
S = SCOPE->nf.U.Real();
else if( ui.cmbDisplayNearfield->currentText() == tr("imaginary") )
S = SCOPE->nf.U.Imag();
S.toImage(outfile.toStdString(), positive_vals, cmap);
}
//run the far-field simulation
SCOPE->SimulateImaging();
//far field rendering
if( ui.radDisplayFarfield->isChecked() )
{
scalarslice S;
bool positive_vals = false;
if( ui.cmbDisplayFarfield->currentText() == tr("magnitude") )
{
S = SCOPE->Ud.Mag();
positive_vals = true;
}
else if( ui.cmbDisplayFarfield->currentText() == tr("real") )
S = SCOPE->Ud.Real();
else if( ui.cmbDisplayFarfield->currentText() == tr("imaginary") )
S = SCOPE->Ud.Imag();
S.toImage(outfile.toStdString(), positive_vals, cmap);
}
//detector rendering
if( ui.radDisplayDetector->isChecked() )
{
scalarslice I;
bool positive_vals = true;
if( ui.cmbDisplayDetector->currentText() == tr("intensity") )
I = SCOPE->getIntensity();
else if( ui.cmbDisplayDetector->currentText() == tr("absorbance") )
I = SCOPE->getAbsorbance();
I.toImage(outfile.toStdString(), positive_vals, cmap);
}
}
|