Skip to content

Commit e3942ce

Browse files
authored
Merge pull request #75 from gehelem/73-inspector-add-stars-deformation-analysis
73 inspector add stars deformation analysis
2 parents b97511a + 90bc629 commit e3942ce

File tree

2 files changed

+108
-11
lines changed

2 files changed

+108
-11
lines changed

src/modules/inspector/inspector.cpp

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ Inspector::Inspector(QString name, QString label, QString profile, QVariantMap a
2222
defineMeAsSequencer();
2323

2424
OST::ElementBool* b = new OST::ElementBool("Shoot", "0", "");
25+
b->setValue(false, false);
2526
getProperty("actions")->addElt("shoot", b);
26-
b = new OST::ElementBool("Loop", "2", "");
27+
28+
b = new OST::ElementBool("Loop", "1", "");
2729
b->setValue(false, false);
2830
getProperty("actions")->addElt("loop", b);
29-
b = new OST::ElementBool("Abort", "2", "");
30-
getProperty("actions")->addElt("abort", b);
31+
32+
b = new OST::ElementBool("Reload", "2", "");
3133
b->setValue(false, false);
34+
getProperty("actions")->addElt("reload", b);
35+
36+
b = new OST::ElementBool("Abort", "3", "");
37+
b->setValue(false, false);
38+
getProperty("actions")->addElt("abort", b);
3239

3340
getProperty("actions")->deleteElt("startsequence");
3441
getProperty("actions")->deleteElt("abortsequence");
@@ -82,6 +89,13 @@ void Inspector::OnMyExternalEvent(const QString &eventType, const QString &even
8289
Shoot();
8390
}
8491
}
92+
if (keyelt == "reload")
93+
{
94+
if (getEltBool(keyprop, keyelt)->setValue(false, true))
95+
{
96+
emit newImage();
97+
}
98+
}
8599
if (keyelt == "abort")
86100
{
87101
if (getEltBool(keyprop, keyelt)->setValue(false, true))
@@ -109,6 +123,9 @@ void Inspector::newBLOB(INDI::PropertyBlob pblob)
109123
delete _image;
110124
_image = new fileio();
111125
_image->loadBlob(pblob, 64);
126+
// testing : load fits, comment previous and uncomment **2** lines below
127+
//_image->loadFits("/pathoftheimage/Light_LLL_008.fits");
128+
//_image->generateQImage();
112129
stats = _image->getStats();
113130
emit newImage();
114131
}
@@ -195,22 +212,68 @@ void Inspector::OnSucessSEP()
195212
//r.setRect(0,0,im.width(),im.height());
196213

197214
/* Drw HFR ellipses around found stars */
198-
QPainter p;
199-
p.begin(&immap);
200-
p.setPen(QPen(Qt::red));
201-
//p.setFont(QFont("Times", 15, QFont::Normal));
202-
//p.drawText(r, Qt::AlignLeft, QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss zzz") );
203-
p.setPen(QPen(Qt::green));
204215
foreach( FITSImage::Star s, _solver.stars )
205216
{
217+
QPainter p2;
218+
p2.begin(&immap);
219+
p2.setPen(QPen(Qt::green));
220+
206221
//qDebug() << "draw " << s.x << "/" << s.y;
207222
int x = s.x;
208223
int y = s.y;
209224
int a = s.a;
210225
int b = s.b;
226+
float dx = 2 * s.a * cos(s.theta * 3.14159 / 360) / s.b;
227+
float dy = 2 * s.a * sin(s.theta * 3.14159 / 360) / s.b;
228+
211229
//qDebug() << "draw " << x << "/" << y;
212-
p.drawEllipse(QPoint(x / 2, y / 2), a * 5, b * 5);
230+
//p2.rotate(s.theta);
231+
//p2.drawEllipse(QPoint(x / 2, y / 2), a * 5, b * 5);
232+
p2.drawLine(x / 2 - dx, y / 2 - dy, x / 2 + dx, y / 2 + dy);
233+
p2.end();
234+
}
235+
236+
int imgWidth = _image->getStats().width;
237+
int imgHeight = _image->getStats().height;
238+
int ellipseSize = 0.20 * imgHeight / _solver.HFRZones;
239+
240+
for (int line = 0; line < _solver.HFRZones ; line++)
241+
{
242+
for (int column = 0; column < _solver.HFRZones; column++)
243+
{
244+
int zone = _solver.HFRZones * line + column;
245+
246+
//qDebug() << "zones theta" << zone << _solver.thetaAvgZone[zone] << _solver.thetaDevAvgZone[zone] <<
247+
// _solver.aAxeAvgZone[zone] <<
248+
// _solver.bAxeAvgZone[zone] << _solver.eAxeAvgZone[zone];
249+
250+
251+
int x = (imgWidth / _solver.HFRZones) * (column + 0.5) ;
252+
int y = (imgHeight / _solver.HFRZones) * (line + 0.5) ;
253+
float e = _solver.aAxeAvgZone[zone] / _solver.bAxeAvgZone[zone] - 1;
254+
float dx = ellipseSize * e * e * cos(_solver.thetaAvgZone[zone] * 3.14159 / 360);
255+
float dy = ellipseSize * e * e * sin(_solver.thetaAvgZone[zone] * 3.14159 / 360);
256+
257+
QPainter p2;
258+
p2.begin(&immap);
259+
p2.setPen(QPen(Qt::red, 5));
260+
261+
//qDebug() << "draw " << x << "/" << y;
262+
//p2.rotate(_solver.thetaAvgZone[zone]);
263+
//p2.drawEllipse(QPoint(x / 2, y / 2), a * 15, b * 15);
264+
p2.drawEllipse(QPoint(x / 2, y / 2), ellipseSize, ellipseSize);
265+
p2.drawLine(x / 2 - dx, y / 2 - dy, x / 2 + dx, y / 2 + dy);
266+
p2.end();
267+
}
213268
}
269+
QPainter p;
270+
p.begin(&immap);
271+
p.setPen(QPen(Qt::red));
272+
273+
//p.drawLine(0, imgHeight / 6, imgWidth / 2, imgHeight / 6);
274+
//p.drawLine(0, 2 * imgHeight / 6, imgWidth / 2, 2 * imgHeight / 6);
275+
//p.drawLine(imgWidth / 6, 0, imgWidth / 6, imgHeight / 2);
276+
//p.drawLine(2 * imgWidth / 6, 0, 2 * imgWidth / 6, imgHeight / 2);
214277

215278
/* determine 4 corner HFR */
216279
int upperLeftI = 0;
@@ -326,7 +389,7 @@ void Inspector::OnSucessSEP()
326389
}
327390
void Inspector::OnNewImage()
328391
{
329-
_solver.ResetSolver(stats, _image->getImageBuffer());
392+
_solver.ResetSolver(stats, _image->getImageBuffer(), getInt("parameters", "zoning"));
330393
connect(&_solver, &Solver::successSEP, this, &Inspector::OnSucessSEP);
331394
_solver.FindStars(_solver.stellarSolverProfiles[0]);
332395
}

src/modules/inspector/inspector.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
11
{
22
"properties":{
3+
"parameters": {
4+
"devcat": "Parameters",
5+
"group": "",
6+
"permission": 2,
7+
"hasprofile":true,
8+
"order":"222Parms000",
9+
"label": "Zoning parameters",
10+
"elements": {
11+
"zoning": {
12+
"order":"70",
13+
"autoupdate":true,
14+
"directedit":true,
15+
"type":"int",
16+
"label": "Zoning",
17+
"value":2,
18+
"format": "99999",
19+
"min":1,
20+
"max":64,
21+
"listOfValues":[
22+
[1,"1x1"],
23+
[2,"2x2"],
24+
[3,"3x3"],
25+
[4,"4x4"],
26+
[5,"5x5"],
27+
[6,"6x6"],
28+
[7,"7x7"],
29+
[8,"8x8"],
30+
[9,"9x9"]
31+
]
32+
33+
}
34+
35+
}
36+
}
337
}
438
}

0 commit comments

Comments
 (0)