Commit 6f4596f5 authored by Jasem Mutlaq's avatar Jasem Mutlaq

Merge branch 'master' of git://anongit.kde.org/kstars

parents fd30589e 7b5387ae
......@@ -198,7 +198,6 @@ set(libkstarstools_SRCS
tools/eyepiecefield.cpp
tools/exporteyepieceview.cpp
tools/starhopperdialog.cpp
tools/nameresolver.cpp
)
if (${KF5_VERSION} VERSION_EQUAL 5.18.0 OR ${KF5_VERSION} VERSION_GREATER 5.18.0)
......
......@@ -884,44 +884,49 @@ void Focus::newFITS(IBLOB *bp)
disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
image_data->findStars();
// If we're not framing, let's try to detect stars
if (inFocusLoop == false)
{
image_data->findStars();
currentHFR= image_data->getHFR(HFR_MAX);
currentHFR= image_data->getHFR(HFR_MAX);
if (currentHFR == -1)
{
currentHFR = image_data->getHFR();
}
if (currentHFR == -1)
{
currentHFR = image_data->getHFR();
}
if (Options::focusLogging())
qDebug() << "Focus newFITS: Current HFR " << currentHFR;
if (Options::focusLogging())
qDebug() << "Focus newFITS: Current HFR " << currentHFR;
HFRText = QString("%1").arg(currentHFR, 0,'g', 3);
HFRText = QString("%1").arg(currentHFR, 0,'g', 3);
if (inFocusLoop == false && focusType == FOCUS_MANUAL && lastHFR == -1)
appendLogText(i18n("FITS received. No stars detected."));
if (focusType == FOCUS_MANUAL && lastHFR == -1)
appendLogText(i18n("FITS received. No stars detected."));
HFROut->setText(HFRText);
HFROut->setText(HFRText);
if (currentHFR > 0)
{
if (currentHFR > maxHFR)
maxHFR = currentHFR;
if (currentHFR > 0)
{
if (currentHFR > maxHFR)
maxHFR = currentHFR;
if (hfr_position.empty())
hfr_position.append(1);
else
hfr_position.append(hfr_position.last()+1);
hfr_value.append(currentHFR);
if (hfr_position.empty())
hfr_position.append(1);
else
hfr_position.append(hfr_position.last()+1);
hfr_value.append(currentHFR);
if (focusType == FOCUS_MANUAL || (inAutoFocus && canAbsMove == false && canRelMove == false))
drawHFRPlot();
if (focusType == FOCUS_MANUAL || (inAutoFocus && canAbsMove == false && canRelMove == false))
drawHFRPlot();
}
}
if (inFocusLoop)
// If just framing, let's capture again
else
{
capture();
return;
}
if (starSelected == false)
......
......@@ -1258,19 +1258,26 @@ void CCD::processBLOB(IBLOB* bp)
}
int tabRC = -1;
switch (targetChip->getCaptureMode())
{
case FITS_NORMAL:
if (normalTabID == -1 || Options::singlePreviewFITS() == false)
normalTabID = fv->addFITS(&fileURL, FITS_NORMAL, captureFilter, previewTitle);
tabRC = fv->addFITS(&fileURL, FITS_NORMAL, captureFilter, previewTitle);
else if (fv->updateFITS(&fileURL, normalTabID, captureFilter) == false)
{
fv->removeFITS(normalTabID);
normalTabID = fv->addFITS(&fileURL, FITS_NORMAL, captureFilter, previewTitle);
tabRC = fv->addFITS(&fileURL, FITS_NORMAL, captureFilter, previewTitle);
}
else
tabRC = normalTabID;
if (normalTabID >= 0)
if (tabRC >= 0)
{
normalTabID = tabRC;
targetChip->setImage(fv->getView(normalTabID), FITS_NORMAL);
}
else
// If opening file fails, we treat it the same as exposure failure and recapture again if possible
emit newExposureValue(targetChip, 0, IPS_ALERT);
......@@ -1278,47 +1285,61 @@ void CCD::processBLOB(IBLOB* bp)
case FITS_FOCUS:
if (focusTabID == -1)
focusTabID = fv->addFITS(&fileURL, FITS_FOCUS, captureFilter);
tabRC = fv->addFITS(&fileURL, FITS_FOCUS, captureFilter);
else if (fv->updateFITS(&fileURL, focusTabID, captureFilter) == false)
{
fv->removeFITS(focusTabID);
focusTabID = fv->addFITS(&fileURL, FITS_FOCUS, captureFilter);
tabRC = fv->addFITS(&fileURL, FITS_FOCUS, captureFilter);
}
else
tabRC = focusTabID;
if (focusTabID >= 0)
if (tabRC >= 0)
{
focusTabID = tabRC;
targetChip->setImage(fv->getView(focusTabID), FITS_FOCUS);
}
else
emit newExposureValue(targetChip, 0, IPS_ALERT);
break;
case FITS_GUIDE:
if (guideTabID == -1)
guideTabID = fv->addFITS(&fileURL, FITS_GUIDE, captureFilter);
tabRC = fv->addFITS(&fileURL, FITS_GUIDE, captureFilter);
else if (fv->updateFITS(&fileURL, guideTabID, captureFilter) == false)
{
fv->removeFITS(guideTabID);
guideTabID = fv->addFITS(&fileURL, FITS_GUIDE, captureFilter);
tabRC = fv->addFITS(&fileURL, FITS_GUIDE, captureFilter);
}
else
tabRC = guideTabID;
if (guideTabID >= 0)
{
guideTabID = tabRC;
targetChip->setImage(fv->getView(guideTabID), FITS_GUIDE);
}
else
emit newExposureValue(targetChip, 0, IPS_ALERT);
break;
case FITS_CALIBRATE:
if (calibrationTabID == -1)
calibrationTabID = fv->addFITS(&fileURL, FITS_CALIBRATE, captureFilter);
tabRC = fv->addFITS(&fileURL, FITS_CALIBRATE, captureFilter);
else if (fv->updateFITS(&fileURL, calibrationTabID, captureFilter) == false)
{
fv->removeFITS(calibrationTabID);
calibrationTabID = fv->addFITS(&fileURL, FITS_CALIBRATE, captureFilter);
tabRC = fv->addFITS(&fileURL, FITS_CALIBRATE, captureFilter);
}
else
tabRC = calibrationTabID;
if (calibrationTabID >= 0)
if (tabRC >= 0)
{
calibrationTabID = tabRC;
targetChip->setImage(fv->getView(calibrationTabID), FITS_CALIBRATE);
}
else
emit newExposureValue(targetChip, 0, IPS_ALERT);
break;
......
/***************************************************************************
nameresolver.cpp - K Desktop Planetarium
-------------------
begin : Sun 24 Aug 2014 02:28:09 CDT
copyright : (c) 2014 by Akarsh Simha
email : akarsh.simha@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* Project Includes */
#include "nameresolver.h"
#include "../../datahandlers/catalogentrydata.h"
/* KDE Includes */
#include <kio/filecopyjob.h>
/* Qt Includes */
#include <QUrl>
#include <QTemporaryFile>
#include <QString>
#include <QXmlStreamReader>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QDebug>
#include <QEventLoop>
class CatalogEntryData NameResolver::resolveName( const QString &name ) {
class CatalogEntryData data;
data.long_name = name;
if( !NameResolverInternals::sesameResolver( data, name ) ) {
qDebug() << "Error: sesameResolver failed. Could not resolve name on CDS Sesame!";
return data; // default data structure with no information
}
// More to be done here if the resolved name is SIMBAD
return data;
}
bool NameResolver::NameResolverInternals::sesameResolver( class CatalogEntryData &data, const QString &name ) {
QUrl resolverUrl = QUrl( QString( "http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oxpFI/SNV?%1" ).arg( name ) );
qDebug() << "Attempting to resolve object " << name << "using CDS Sesame.";
QNetworkAccessManager manager;
QNetworkReply *response = manager.get( QNetworkRequest( resolverUrl ) );
// Wait synchronously
QEventLoop event;
QObject::connect( response, SIGNAL( finished() ), &event, SLOT( quit() ) );
event.exec();
if (response->error() != QNetworkReply::NoError) {
qWarning() << "Error trying to get XML response from CDS Sesame server: " << response->errorString();
return false;
}
QXmlStreamReader xml( response->readAll() );
if( xml.atEnd() ) {
// file is empty
qDebug() << "Empty result instead of expected XML from CDS Sesame! Maybe bad internet connection?";
return false;
}
while( !xml.atEnd() && !xml.hasError() ) {
QXmlStreamReader::TokenType token = xml.readNext();
if( xml.isStartDocument() )
continue;
if( token == QXmlStreamReader::StartElement ) {
qDebug() << "Parsing token with name " << xml.name();
if( xml.name() == "Resolver" ) {
// This is the section we want
char resolver;
QXmlStreamAttributes attributes = xml.attributes();
if( attributes.hasAttribute( "name" ) )
resolver = attributes.value("name").at( 0 ).toLatin1(); // Expected to be S (Simbad), V (VizieR), or N (NED)
else {
resolver = 0; // NUL character for unknown resolver
qWarning() << "Warning: Unknown resolver " << attributes.value( "name " ) << " while reading output from CDS Sesame";
}
qDebug() << "Resolved by " << attributes.value( "name" ) << "!";
// Start reading the data to pick out the relevant ones
while( xml.readNextStartElement() ) {
if( xml.name() == "otype" ) {
const QString typeString = xml.readElementText();
data.type = interpretObjectType( typeString );
}
else if( xml.name() == "jradeg" ) {
data.ra = xml.readElementText().toDouble();
}
else if( xml.name() == "jdedeg" ) {
data.dec = xml.readElementText().toDouble();
}
else if( xml.name() == "mag" ) {
attributes = xml.attributes();
char band;
if( attributes.hasAttribute( "band" ) ) {
attributes.value("band").at(0).toLatin1();
}
else {
qWarning() << "Warning: Magnitude of unknown band found while reading output from CDS Sesame";
band = 0;
}
if( band == 'V' ) {
data.magnitude = xml.readElementText().toFloat();
}
else if( band == 'B' ) {
data.flux = xml.readElementText().toFloat(); // FIXME: This is bad
}
// Don't know what to do with other magnitudes, until we have a magnitude hash
}
else
xml.skipCurrentElement();
// TODO: Parse aliases for common names
}
break;
}
else
continue;
}
}
if( xml.hasError() ) {
qDebug() << "Error parsing XML from CDS Sesame: " << xml.errorString() << " on line " << xml.lineNumber() << " @ col = " << xml.columnNumber();
return false;
}
qDebug() << "Resolved " << name << " successfully!";
qDebug() << "Object type: " << SkyObject::typeName( data.type ) << "; Coordinates: " << data.ra << ";" << data.dec;
return true;
}
// bool NameResolver::NameResolverInternals::getDataFromSimbad( class CatalogEntryData &data ) {
// // TODO: Implement
// // QUrl( QString( "http://simbad.u-strasbg.fr/simbad/sim-script?script=output%20console=off%20script=off%0Aformat%20object%20%22%25DIM%22%0A" ) + data.name );
// }
SkyObject::TYPE NameResolver::NameResolverInternals::interpretObjectType( const QString &typeString ) {
// FIXME: Due to the quirks of Sesame (SIMBAD vs NED etc), it
// might be very difficult to discern the type in all cases. The
// best way TODO things might be to first run the query with NED,
// and if it is extragalactic, then trust NED and
// accept. Otherwise, or if NED did not return a result, re-run
// the query on SIMBAD and VizieR and use that result, if any.
// Highest likelihood is a galaxy of some form
if( typeString == "G" || typeString == "LIN" || typeString == "AGN" || typeString == "GiG" || typeString == "H2G" ) {
// this is a galaxy
return SkyObject::GALAXY;
}
// Next possibility is galaxy cluster
if( typeString == "GClstr" || typeString == "GGroup" || typeString == "GPair" || typeString == "ClG" || typeString == "CGG" ) { // NOTE (FIXME?): Compact groups and pairs of galaxies are treated like galaxy clusters
return SkyObject::GALAXY_CLUSTER;
}
if( typeString == "*Cl" || typeString == "Cl*" || typeString == "OpC" )
return SkyObject::OPEN_CLUSTER; // FIXME: NED doesn't distinguish between globular clusters and open clusters!!
if( typeString == "GlC" )
return SkyObject::GLOBULAR_CLUSTER;
if( typeString == "Neb" || typeString == "HII" )
return SkyObject::GASEOUS_NEBULA;
if( typeString == "SNR" ) // FIXME: Simbad returns "ISM" for Veil Nebula (Interstellar Medium??)
return SkyObject::SUPERNOVA_REMNANT;
if( typeString == "PN" )
return SkyObject::PLANETARY_NEBULA;
if( typeString == "*" )
return SkyObject::STAR;
return SkyObject::TYPE_UNKNOWN;
// FIXME: complete this method
}
/***************************************************************************
nameresolver.h - K Desktop Planetarium
-------------------
begin : Sat 23 Aug 2014 23:38:42 CDT
copyright : (c) 2014 by Akarsh Simha
email : akarsh.simha@kdemail.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef NAMERESOLVER_H
#define NAMERESOLVER_H
/* #include "../../datahandlers/catalogentrydata.h" */
#include "skyobject.h"
// Forward declarations
class QString;
class CatalogEntryData;
/**
* @namespace NameResolver
*
* @short Uses name resolver services to get coordinates and
* information about deep-sky objects, given their names
*
* This class uses the CDS Sesame name resolver (and potentially other
* resolvers) to resolve the names of deep-sky objects, and obtain
* coordinates, fluxes, alternate designations, and possibly other
* data.
*
* @author Akarsh Simha <akarsh.simha@kdemail.net>
*/
namespace NameResolver {
/**
* @short Resolve the name of the given DSO and extract data from
* various sources
*/
class CatalogEntryData resolveName( const QString &name );
namespace NameResolverInternals {
/**
* @short Resolve the name and obtain basic data using CDS Sesame service
*
* @param data the structure to fill with the obtained data
* @param name the name (identifier) to resolve
* @return Success value
*/
bool sesameResolver( class CatalogEntryData &data, const QString &name );
/**
* @short Retrieve additional data from SIMBAD
*
* If the object was resolved by SIMBAD, obtain additional data
* that is not available through CDS Sesame, such as the major and
* minor axes and position angle of the object.
*
* @param data the structure containing data from Sesame, to be
* filled with additional data
* @return Success value
*/
// bool getDataFromSimbad( class CatalogEntryData &data );
/**
* @short Interprets object type returned by Sesame
*
* This method reads the object type string returned by Sesame
* / other resolvers and attempts to convert it into a
* SkyObject type.
*
* @return a SkyObject::TYPE.
*/
SkyObject::TYPE interpretObjectType( const QString &typeString );
}
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment