Commit e120f3d0 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

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

parents cead4ef9 40427782
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0.1" package="org.kde.kstars" android:installLocation="auto" android:versionCode="7">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0.1" package="org.kde.kstars" android:installLocation="auto" android:versionCode="8">
<application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="KStars Lite" android:icon="@drawable/icon">
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="KStars Lite" android:screenOrientation="unspecified" android:theme="@style/AppTheme" android:launchMode="singleTop" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation">
<intent-filter>
......
......@@ -299,7 +299,7 @@ void ColorScheme::loadFromConfig() {
setStarColorModeIntensity( cg.readEntry( "StarColorMode", 0 ), cg.readEntry( "StarColorIntensity", 5 ) );
FileName = cg.readEntry( "ColorSchemeFile", "classic.colors" );
FileName = cg.readEntry( "ColorSchemeFile", "moonless-night.colors" );
}
void ColorScheme::saveToConfig() {
......
......@@ -27,6 +27,10 @@
#include <QUrl>
#include <QStandardPaths>
#ifndef KSTARS_LITE
#include <KMessageBox>
#endif
#include <cmath>
#include "auxiliary/kspaths.h"
......@@ -626,7 +630,7 @@ QString constGenetiveToAbbrev( const QString &genetive_ ) {
}
#ifdef Q_OS_OSX
void KStarsData::copyDataFolderFromAppBundleIfNeeded()
void copyDataFolderFromAppBundleIfNeeded()
{
QString dataLocation=QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kstars", QStandardPaths::LocateDirectory);
......@@ -645,7 +649,7 @@ void KStarsData::copyDataFolderFromAppBundleIfNeeded()
}
}
bool KStarsData::copyRecursively(QString sourceFolder, QString destFolder)
bool copyRecursively(QString sourceFolder, QString destFolder)
{
bool success = false;
QDir sourceDir(sourceFolder);
......
......@@ -225,8 +225,8 @@ namespace KSUtils {
};
#ifdef Q_OS_OSX
static void copyDataFolderFromAppBundleIfNeeded();
static bool copyRecursively(QString sourceFolder, QString destFolder);
void copyDataFolderFromAppBundleIfNeeded();
bool copyRecursively(QString sourceFolder, QString destFolder);
#endif
}
......
......@@ -108,16 +108,16 @@ Align::Align()
connect(correctAzB, SIGNAL(clicked()), this, SLOT(correctAzError()));
connect(loadSlewB, SIGNAL(clicked()), this, SLOT(loadAndSlew()));
gotoModeButtonGroup->setId(syncR, GOTO_SYNC);
gotoModeButtonGroup->setId(slewR, GOTO_SLEW);
gotoModeButtonGroup->setId(nothingR, GOTO_NOTHING);
connect(gotoModeButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, [=](int id){ this->currentGotoMode = static_cast<GotoMode>(id); });
// TODO make this configurable, 3 minutes timeout
alignTimer.setInterval(180*1000);
connect(&alignTimer, SIGNAL(timeout()), this, SLOT(checkAlignmentTimeout()));
int i=0;
foreach(QAbstractButton *button, gotoModeButtonGroup->buttons())
gotoModeButtonGroup->setId(button, i++);
currentGotoMode = static_cast<GotoMode>(Options::solverGotoOption());
gotoModeButtonGroup->button(currentGotoMode)->setChecked(true);
......@@ -721,7 +721,10 @@ void Align::newFITS(IBLOB *bp)
if (darkData)
DarkLibrary::Instance()->subtract(darkData, currentImage, FITS_NONE, offsetX, offsetY);
else
DarkLibrary::Instance()->captureAndSubtract(targetChip, currentImage, exposureIN->value(), offsetX, offsetY);
{
bool rc = DarkLibrary::Instance()->captureAndSubtract(targetChip, currentImage, exposureIN->value(), offsetX, offsetY);
alignDarkFrameCheck->setChecked(rc);
}
return;
}
......@@ -908,10 +911,11 @@ void Align::solverFinished(double orientation, double ra, double dec, double pix
{
case GOTO_SYNC:
executeGOTO();
return;
break;
case GOTO_SLEW:
if (targetDiff > accuracySpin->value())
if (loadSlewState == IPS_BUSY || targetDiff > accuracySpin->value())
{
if (loadSlewState == IPS_IDLE && ++solverIterations == MAXIMUM_SOLVER_ITERATIONS)
{
......@@ -1054,28 +1058,42 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
ScopeRAOut->setText(ra_dms);
ScopeDecOut->setText(dec_dms);
if (Options::alignmentLogging())
qDebug() << "Alignment: State is " << Ekos::getAlignStatusString(state) << " isSlewing? " << currentTelescope->isSlewing() << " slew Dirty? " << slew_dirty
<< " Current GOTO Mode? " << currentGotoMode << " LoadSlewState? " << pstateStr(loadSlewState);
if (currentTelescope->isSlewing() && slew_dirty == false)
switch (coord->s)
{
slew_dirty = true;
if (Options::alignmentLogging())
qDebug() << "Alignment: slew dirty is true.";
}
else if (currentTelescope->isSlewing() == false && slew_dirty)
case IPS_OK:
{
slew_dirty = false;
if (Options::alignmentLogging())
qDebug() << "Alignment: slew dirty is false.";
if (Options::solverUpdateCoords())
// Update the boxes as the mount just finished slewing
if (slew_dirty && Options::solverUpdateCoords())
copyCoordsToBoxes();
if (state >= ALIGN_PROGRESS)
switch (state)
{
case ALIGN_PROGRESS:
break;
case ALIGN_SYNCING:
{
slew_dirty = false;
if (currentGotoMode == GOTO_SLEW)
{
Slew();
return;
}
else
{
appendLogText(i18n("Mount is synced to solution coordinates. Astrometric solver is successful."));
KNotification::event( QLatin1String( "AlignSuccessful"), i18n("Astrometry alignment completed successfully") );
state = ALIGN_COMPLETE;
emit newStatus(state);
}
}
break;
case ALIGN_SLEWING:
if (slew_dirty == false)
break;
slew_dirty = false;
if (loadSlewState == IPS_BUSY)
{
loadSlewState = IPS_IDLE;
......@@ -1089,9 +1107,9 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve()));
return;
}
else if (currentGotoMode == GOTO_SLEW && state == ALIGN_SLEWING)
else if(currentGotoMode == GOTO_SLEW)
{
appendLogText(i18n("Target accuracy is not met, running solver again..."));
appendLogText(i18n("Slew complete. Target accuracy is not met, running solver again..."));
state = ALIGN_PROGRESS;
emit newStatus(state);
......@@ -1099,8 +1117,59 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve()));
return;
}
break;
default:
{
slew_dirty = false;
}
break;
}
}
break;
case IPS_BUSY:
{
slew_dirty = true;
}
break;
case IPS_ALERT:
{
if (state == ALIGN_SYNCING || state == ALIGN_SLEWING)
{
if (state == ALIGN_SYNCING)
appendLogText(i18n("Syncing failed!"));
else
appendLogText(i18n("Slewing failed!"));
if (++retries == 3)
{
abort();
return;
}
else
{
if (currentGotoMode == GOTO_SLEW)
Slew();
else
Sync();
}
}
return;
}
break;
default:
break;
}
if (Options::alignmentLogging())
qDebug() << "Alignment: State is " << Ekos::getAlignStatusString(state) << " isSlewing? " << currentTelescope->isSlewing() << " slew Dirty? " << slew_dirty
<< " Current GOTO Mode? " << currentGotoMode << " LoadSlewState? " << pstateStr(loadSlewState);
switch (azStage)
{
......@@ -1182,24 +1251,40 @@ void Align::executeGOTO()
void Align::Sync()
{
if (currentTelescope->Sync(&alignCoord))
appendLogText(i18n("Syncing to RA (%1) DEC (%2) is successful.", alignCoord.ra().toHMSString(), alignCoord.dec().toDMSString()));
state = ALIGN_SYNCING;
if (currentTelescope->Sync(&alignCoord))
{
emit newStatus(state);
appendLogText(i18n("Syncing to RA (%1) DEC (%2)", alignCoord.ra().toHMSString(), alignCoord.dec().toDMSString()));
}
else
{
state = ALIGN_IDLE;
emit newStatus(state);
appendLogText(i18n("Syncing failed."));
}
}
void Align::SlewToTarget()
void Align::Slew()
{
if (canSync && loadSlewState == IPS_IDLE)
Sync();
state = ALIGN_SLEWING;
emit newStatus(state);
currentTelescope->Slew(&targetCoord);
appendLogText(i18n("Slewing to target coordinates: RA (%1) DEC (%2).", targetCoord.ra().toHMSString(), targetCoord.dec().toDMSString()));
appendLogText(i18n("Slewing to target coordinates: RA (%1) DEC (%2).", targetCoord.ra().toHMSString(), targetCoord.dec().toDMSString()));
}
void Align::SlewToTarget()
{
if (canSync && loadSlewState == IPS_IDLE)
{
Sync();
return;
}
Slew();
}
void Align::executePolarAlign()
......@@ -1668,6 +1753,7 @@ void Align::loadAndSlew(QString fileURL)
loadSlewState=IPS_BUSY;
slewR->setChecked(true);
currentGotoMode = GOTO_SLEW;
solveB->setEnabled(false);
stopB->setEnabled(true);
......
......@@ -331,6 +331,11 @@ private:
*/
void Sync();
/**
* @brief Slew the telescope to the solved alignment coordinate.
*/
void Slew();
/**
* @brief Sync the telescope to the solved alignment coordinate, and then slew to the target coordinate.
*/
......
......@@ -164,20 +164,45 @@ bool DarkLibrary::subtract(FITSData *darkData, FITSView *lightImage, FITSScale f
Q_ASSERT(darkData);
Q_ASSERT(lightImage);
switch (darkData->getDataType())
{
switch (darkData->getDataType())
{
case TBYTE:
return subtract<uint8_t>(darkData, lightImage, filter, offsetX, offsetY);
break;
break;
case TSHORT:
return subtract<int16_t>(darkData, lightImage, filter, offsetX, offsetY);
break;
case TUSHORT:
return subtract<uint16_t>(darkData, lightImage, filter, offsetX, offsetY);
break;
break;
case TLONG:
return subtract<int32_t>(darkData, lightImage, filter, offsetX, offsetY);
break;
case TULONG:
return subtract<uint32_t>(darkData, lightImage, filter, offsetX, offsetY);
break;
case TFLOAT:
return subtract<float>(darkData, lightImage, filter, offsetX, offsetY);
break;
default:
return false;
case TLONGLONG:
return subtract<int64_t>(darkData, lightImage, filter, offsetX, offsetY);
break;
}
case TDOUBLE:
return subtract<double>(darkData, lightImage, filter, offsetX, offsetY);
break;
default:
break;
}
return false;
}
template<typename T> bool DarkLibrary::subtract(FITSData *darkData, FITSView *lightImage, FITSScale filter, uint16_t offsetX, uint16_t offsetY)
......@@ -220,7 +245,7 @@ template<typename T> bool DarkLibrary::subtract(FITSData *darkData, FITSView *li
}
void DarkLibrary::captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetImage, double duration, uint16_t offsetX, uint16_t offsetY)
bool DarkLibrary::captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetImage, double duration, uint16_t offsetX, uint16_t offsetY)
{
QStringList shutterfulCCDs = Options::shutterfulCCDs();
QStringList shutterlessCCDs = Options::shutterlessCCDs();
......@@ -250,13 +275,13 @@ void DarkLibrary::captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetIm
if (hasNoShutter)
{
if ( (KMessageBox::warningContinueCancel(NULL, i18n("Cover the telescope or camera in order to take a dark exposure."), i18n("Dark Exposure"),
KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "dark_exposure_dialog_notification"))
== KMessageBox::Cancel)
if ( KMessageBox::warningContinueCancel(NULL, i18n("Cover the telescope or camera in order to take a dark exposure."), i18n("Dark Exposure"),
KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "dark_exposure_dialog_notification") == KMessageBox::Cancel)
{
emit newLog(i18n("Dark frame capture cancelled."));
disconnect(targetChip->getCCD(), SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
emit darkFrameCompleted(false);
return false;
}
}
......@@ -275,6 +300,8 @@ void DarkLibrary::captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetIm
emit newLog(i18n("Capturing dark frame..."));
targetChip->capture(duration);
return true;
}
void DarkLibrary::newFITS(IBLOB *bp)
......
......@@ -34,7 +34,8 @@ public:
FITSData * getDarkFrame(ISD::CCDChip *targetChip, double duration);
bool subtract(FITSData *darkData, FITSView *lightImage, FITSScale filter, uint16_t offsetX, uint16_t offsetY);
void captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetImage, double duration, uint16_t offsetX, uint16_t offsetY);
// Return false if canceled. True if dark capture proceeds
bool captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetImage, double duration, uint16_t offsetX, uint16_t offsetY);
signals:
void darkFrameCompleted(bool);
......
......@@ -36,9 +36,9 @@ namespace Ekos
const QString &getFocusStatusString(FocusState state);
// Align States
static const QStringList alignStates = { I18N_NOOP("Idle"), I18N_NOOP("Complete"), I18N_NOOP("Failed"), I18N_NOOP("Aborted"), I18N_NOOP("In Progress"), I18N_NOOP("Slewing")};
static const QStringList alignStates = { I18N_NOOP("Idle"), I18N_NOOP("Complete"), I18N_NOOP("Failed"), I18N_NOOP("Aborted"), I18N_NOOP("In Progress"), I18N_NOOP("Syncing"), I18N_NOOP("Slewing")};
typedef enum { ALIGN_IDLE, ALIGN_COMPLETE, ALIGN_FAILED, ALIGN_ABORTED, ALIGN_PROGRESS, ALIGN_SLEWING} AlignState;
typedef enum { ALIGN_IDLE, ALIGN_COMPLETE, ALIGN_FAILED, ALIGN_ABORTED, ALIGN_PROGRESS, ALIGN_SYNCING, ALIGN_SLEWING} AlignState;
const QString &getAlignStatusString(AlignState state);
}
......
......@@ -977,7 +977,10 @@ void Focus::newFITS(IBLOB *bp)
if (darkData)
DarkLibrary::Instance()->subtract(darkData, focusView, defaultScale, offsetX, offsetY);
else
DarkLibrary::Instance()->captureAndSubtract(targetChip, focusView, exposureIN->value(), offsetX, offsetY);
{
bool rc = DarkLibrary::Instance()->captureAndSubtract(targetChip, focusView, exposureIN->value(), offsetX, offsetY);
darkFrameCheck->setChecked(rc);
}
return;
}
......
......@@ -2078,7 +2078,10 @@ bool Guide::executeOneOperation(GuideState operation)
if (darkData)
DarkLibrary::Instance()->subtract(darkData, guideView, targetChip->getCaptureFilter(), offsetX, offsetY);
else
DarkLibrary::Instance()->captureAndSubtract(targetChip, guideView, exposureIN->value(), offsetX, offsetY);
{
bool rc = DarkLibrary::Instance()->captureAndSubtract(targetChip, guideView, exposureIN->value(), offsetX, offsetY);
setDarkFrameEnabled(rc);
}
}
}
break;
......
......@@ -547,9 +547,35 @@ Vector cgmath::findLocalStarPosition( void ) const
{
case TBYTE:
return findLocalStarPosition<uint8_t>();
break;
case TSHORT:
return findLocalStarPosition<int16_t>();
break;
case TUSHORT:
return findLocalStarPosition<uint16_t>();
break;
case TLONG:
return findLocalStarPosition<int32_t>();
break;
case TULONG:
return findLocalStarPosition<uint32_t>();
break;
case TFLOAT:
return findLocalStarPosition<float>();
break;
case TLONGLONG:
return findLocalStarPosition<int64_t>();
break;
case TDOUBLE:
return findLocalStarPosition<double>();
break;
default:
break;
......@@ -934,7 +960,7 @@ void cgmath::process_axes( void )
void cgmath::performProcessing( void )
{
Vector arc_star_pos, arc_reticle_pos, pos, p;
Vector arc_star_pos, arc_reticle_pos;
// do nothing if suspended
if( suspended )
......
......@@ -769,12 +769,13 @@ bool InternalGuider::processGuiding()
// do pulse
out = pmath->getOutputParameters();
if (out->pulse_length[GUIDE_RA] == Options::rAMaximumPulse() || out->pulse_length[GUIDE_DEC] == Options::dECMaximumPulse())
// If within 90% of max pulse repeatedly, let's abort
if (out->pulse_length[GUIDE_RA] >= (0.9 * Options::rAMaximumPulse()) || out->pulse_length[GUIDE_DEC] >= (0.9 * Options::dECMaximumPulse()))
maxPulseCounter++;
else
maxPulseCounter=0;
if (maxPulseCounter > 3)
if (maxPulseCounter >= 3)
{
emit newLog(i18n("Lost track of the guide star. Aborting guiding..."));
abort();
......
......@@ -24,6 +24,7 @@
#include <cmath>
#include <cstdlib>
#include <climits>
#include <float.h>
#include <QApplication>
#include <QStringList>
......@@ -180,29 +181,39 @@ bool FITSData::loadFITS (const QString &inFilename, bool silent)
switch (stats.bitpix)
{
case 8:
case BYTE_IMG:
data_type = TBYTE;
stats.bytesPerPixel = sizeof(uint8_t);
break;
case 16:
case SHORT_IMG:
// Read SHORT image as USHORT
data_type = TUSHORT;
stats.bytesPerPixel = sizeof(int16_t);
break;
case USHORT_IMG:
data_type = TUSHORT;
stats.bytesPerPixel = sizeof(uint16_t);
break;
case 32:
data_type = TINT;
case LONG_IMG:
// Read LONG image as ULONG
data_type = TULONG;
stats.bytesPerPixel = sizeof(int32_t);
break;
case ULONG_IMG:
data_type = TULONG;
stats.bytesPerPixel = sizeof(uint32_t);
break;
case -32:
case FLOAT_IMG:
data_type = TFLOAT;
stats.bytesPerPixel = sizeof(float_t);
stats.bytesPerPixel = sizeof(float);
break;
case 64:
case LONGLONG_IMG:
data_type = TLONGLONG;
stats.bytesPerPixel = sizeof(long long);
stats.bytesPerPixel = sizeof(int64_t);
break;
case -64:
case DOUBLE_IMG:
data_type = TDOUBLE;
stats.bytesPerPixel = sizeof(double_t);
stats.bytesPerPixel = sizeof(double);
default:
errMessage = i18n("Bit depth %1 is not supported.", stats.bitpix);
#ifndef KSTARS_LITE
......@@ -449,15 +460,42 @@ void FITSData::calculateStats(bool refresh)
calculateMinMax(refresh);
// Get standard deviation and mean in one run
switch(data_type)
switch (data_type)
{
case TBYTE:
runningAverageStdDev<uint8_t>();
break;
case TBYTE:
runningAverageStdDev<uint8_t>();
break;
case TUSHORT:
runningAverageStdDev<uint16_t>();
case TSHORT:
runningAverageStdDev<int16_t>();
break;
case TUSHORT:
runningAverageStdDev<uint16_t>();
break;
case TLONG:
runningAverageStdDev<int32_t>();
break;
case TULONG:
runningAverageStdDev<uint32_t>();
break;
case TFLOAT:
runningAverageStdDev<float>();
break;
case TLONGLONG: