Working solver
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
#include "platesolving.h"
|
||||
#include "ui_platesolving.h"
|
||||
#include "solver.h"
|
||||
#include "imageringlist.h"
|
||||
|
||||
PlateSolving::PlateSolving(QWidget *parent)
|
||||
: QDockWidget(parent)
|
||||
, ui(new Ui::PlateSolving)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
_solver = new Solver(this);
|
||||
|
||||
auto profiles = StellarSolver::getBuiltInProfiles();
|
||||
for(auto &profile : profiles)
|
||||
{
|
||||
ui->profileComboBox->addItem(profile.listName);
|
||||
}
|
||||
|
||||
connect(ui->profileComboBox, &QComboBox::currentIndexChanged, [this](int index){
|
||||
auto profiles = StellarSolver::getBuiltInProfiles();
|
||||
_solver->setParameters(profiles[index]);
|
||||
});
|
||||
|
||||
connect(ui->extractButton, &QPushButton::clicked, this, &PlateSolving::extract);
|
||||
connect(ui->solveButton, &QPushButton::clicked, this, &PlateSolving::solve);
|
||||
connect(_solver, &Solver::solvingDone, this, &PlateSolving::solvingDone);
|
||||
connect(_solver, &Solver::extractionDone, this, &PlateSolving::extractionDone);
|
||||
}
|
||||
|
||||
PlateSolving::~PlateSolving()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PlateSolving::extract()
|
||||
{
|
||||
ui->solveButton->setDisabled(true);
|
||||
ui->extractButton->setDisabled(true);
|
||||
|
||||
_solver->loadImage(_rawImage, _path);
|
||||
_solver->extractSources(ui->withHFR->isChecked());
|
||||
}
|
||||
|
||||
void PlateSolving::extractionDone()
|
||||
{
|
||||
auto stars = _solver->getStars();
|
||||
float a = 0;
|
||||
float b = 0;
|
||||
float hfr = 0;
|
||||
for(auto &star : stars)
|
||||
{
|
||||
a += star.a;
|
||||
b += star.b;
|
||||
hfr += star.HFR;
|
||||
}
|
||||
if(size_t size = stars.size())
|
||||
{
|
||||
a /= size;
|
||||
b /= size;
|
||||
hfr /= size;
|
||||
}
|
||||
|
||||
ui->stars->setText(QString::number(stars.size()));
|
||||
ui->hfr->setText(QString("%1 %2x%3").arg(hfr).arg(a).arg(b));
|
||||
|
||||
ui->solveButton->setDisabled(false);
|
||||
ui->extractButton->setDisabled(false);
|
||||
}
|
||||
|
||||
void PlateSolving::solve()
|
||||
{
|
||||
ui->solveButton->setDisabled(true);
|
||||
ui->extractButton->setDisabled(true);
|
||||
|
||||
_solver->loadImage(_rawImage, _path);
|
||||
_solver->solveImage();
|
||||
}
|
||||
|
||||
void PlateSolving::solvingDone()
|
||||
{
|
||||
ui->solveButton->setDisabled(false);
|
||||
ui->extractButton->setDisabled(false);
|
||||
|
||||
auto solution = _solver->getSolution();
|
||||
ui->ra->setText(QString::number(solution.ra));
|
||||
ui->dec->setText(QString::number(solution.dec));
|
||||
ui->orientation->setText(QString::number(solution.orientation));
|
||||
ui->fieldWidth->setText(QString::number(solution.fieldWidth));
|
||||
ui->fieldHeight->setText(QString::number(solution.fieldHeight));
|
||||
ui->pixelScale->setText(QString::number(solution.pixscale));
|
||||
}
|
||||
|
||||
void PlateSolving::imageLoaded(Image *image)
|
||||
{
|
||||
if(image)
|
||||
{
|
||||
_rawImage = image->rawImage();
|
||||
_path = image->name();
|
||||
ui->ra->clear();
|
||||
ui->dec->clear();
|
||||
ui->orientation->clear();
|
||||
ui->fieldWidth->clear();
|
||||
ui->fieldHeight->clear();
|
||||
ui->pixelScale->clear();
|
||||
ui->hfr->clear();
|
||||
ui->stars->clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user