8#include "config-kstars.h"
9#include "ksnotification.h"
10#include "kstars_debug.h"
12#include "catalogobject.h"
17#include "starobject.h"
18#include "auxiliary/kspaths.h"
26#include <libraw/libraw.h>
30#include <sys/sysctl.h>
38#include <QProcessEnvironment>
39#include <QLoggingCategory>
41#ifdef HAVE_STELLARSOLVER
42#include <stellarsolver.h>
47bool isHardwareLimited()
70 double dss_default_size = Options::defaultDSSImageSize();
71 double dss_padding = Options::dSSPadding();
74 Q_ASSERT(dss_default_size > 0.0 && dss_padding >= 0.0);
92 width = a * sin(pa) + b * cos(pa);
93 height = a * cos(pa) + b * sin(pa);
97 height += dss_padding;
104 height = width = dss_default_size;
107 if (height < dss_default_size)
108 height = dss_default_size;
109 if (width < dss_default_size)
110 width = dss_default_size;
112 return getDSSURL(p->
ra0(), p->
dec0(), width, height);
115QString getDSSURL(
const dms &ra,
const dms &dec,
float width,
float height,
118 const QString URLprefix(
"https://archive.stsci.edu/cgi-bin/dss_search?");
120 const double dss_default_size = Options::defaultDSSImageSize();
122 char decsgn = (
dec.Degrees() < 0.0) ?
'-' :
'+';
123 int dd = abs(
dec.degree());
124 int dm = abs(
dec.arcmin());
125 int ds = abs(
dec.arcsec());
128 if (!qIsFinite(height) || height <= 0.0)
129 height = dss_default_size;
130 if (!qIsFinite(width) || width <= 0.0)
131 width = dss_default_size;
139 QString RAString, DecString, SizeString;
144 return (URLprefix + RAString + DecString + SizeString + URLsuffix);
157 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"N"),
158 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"NNE"),
159 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"NE"),
160 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"ENE"),
161 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"E"),
162 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"ESE"),
163 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"SE"),
164 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"SSE"),
165 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"S"),
166 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"SSW"),
167 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"SW"),
168 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"WSW"),
169 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"W"),
170 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"WNW"),
171 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"NW"),
172 ki18nc(
"Abbreviated cardinal / intercardinal etc. direction",
"NNW"),
173 ki18nc(
"Unknown cardinal / intercardinal direction",
"???")
179 if (index < 0 || index > 16)
182 index = (index == 16 ? 0 : index);
184 return directions[index].
toString();
221 return QString(
"Camelopardalis");
225 return QString(
"Canum Venaticorum");
227 return QString(
"Canis Majoris");
229 return QString(
"Canis Minoris");
243 return QString(
"Chamaeleontis");
249 return QString(
"Comae Berenices");
251 return QString(
"Coronae Austrinae");
253 return QString(
"Coronae Borealis");
293 return QString(
"Leonis Minoris");
333 return QString(
"Piscis Austrini");
361 return QString(
"Trianguli Australis");
365 return QString(
"Ursae Majoris");
367 return QString(
"Ursae Minoris");
402 return QString(
"Camelopardalis");
406 return QString(
"Canes Venatici");
430 return QString(
"Coma Berenices");
432 return QString(
"Corona Australis");
434 return QString(
"Corona Borealis");
488 return QString(
"Microscopium");
514 return QString(
"Piscis Austrinus");
542 return QString(
"Triangulum Australe");
563 if (fullName ==
"andromeda")
565 if (fullName ==
"antlia")
567 if (fullName ==
"apus")
569 if (fullName ==
"aquarius")
571 if (fullName ==
"aquila")
573 if (fullName ==
"ara")
575 if (fullName ==
"aries")
577 if (fullName ==
"auriga")
579 if (fullName ==
"bootes")
581 if (fullName ==
"caelum")
583 if (fullName ==
"camelopardalis")
585 if (fullName ==
"cancer")
587 if (fullName ==
"canes venatici")
589 if (fullName ==
"canis major")
591 if (fullName ==
"canis minor")
593 if (fullName ==
"capricornus")
595 if (fullName ==
"carina")
597 if (fullName ==
"cassiopeia")
599 if (fullName ==
"centaurus")
601 if (fullName ==
"cepheus")
603 if (fullName ==
"cetus")
605 if (fullName ==
"chamaeleon")
607 if (fullName ==
"circinus")
609 if (fullName ==
"columba")
611 if (fullName ==
"coma berenices")
613 if (fullName ==
"corona australis")
615 if (fullName ==
"corona borealis")
617 if (fullName ==
"corvus")
619 if (fullName ==
"crater")
621 if (fullName ==
"crux")
623 if (fullName ==
"cygnus")
625 if (fullName ==
"delphinus")
627 if (fullName ==
"doradus")
629 if (fullName ==
"draco")
631 if (fullName ==
"equuleus")
633 if (fullName ==
"eridanus")
635 if (fullName ==
"fornax")
637 if (fullName ==
"gemini")
639 if (fullName ==
"grus")
641 if (fullName ==
"hercules")
643 if (fullName ==
"horologium")
645 if (fullName ==
"hydra")
647 if (fullName ==
"hydrus")
649 if (fullName ==
"indus")
651 if (fullName ==
"lacerta")
653 if (fullName ==
"leo")
655 if (fullName ==
"leo minor")
657 if (fullName ==
"lepus")
659 if (fullName ==
"libra")
661 if (fullName ==
"lupus")
663 if (fullName ==
"lynx")
665 if (fullName ==
"lyra")
667 if (fullName ==
"mensa")
669 if (fullName ==
"microscopium")
671 if (fullName ==
"monoceros")
673 if (fullName ==
"musca")
675 if (fullName ==
"norma")
677 if (fullName ==
"octans")
679 if (fullName ==
"ophiuchus")
681 if (fullName ==
"orion")
683 if (fullName ==
"pavo")
685 if (fullName ==
"pegasus")
687 if (fullName ==
"perseus")
689 if (fullName ==
"phoenix")
691 if (fullName ==
"pictor")
693 if (fullName ==
"pisces")
695 if (fullName ==
"piscis austrinus")
697 if (fullName ==
"puppis")
699 if (fullName ==
"pyxis")
701 if (fullName ==
"reticulum")
703 if (fullName ==
"sagitta")
705 if (fullName ==
"sagittarius")
707 if (fullName ==
"scorpius")
709 if (fullName ==
"sculptor")
711 if (fullName ==
"scutum")
713 if (fullName ==
"serpens")
715 if (fullName ==
"sextans")
717 if (fullName ==
"taurus")
719 if (fullName ==
"telescopium")
721 if (fullName ==
"triangulum")
723 if (fullName ==
"triangulum australe")
725 if (fullName ==
"tucana")
727 if (fullName ==
"ursa major")
729 if (fullName ==
"ursa minor")
731 if (fullName ==
"vela")
733 if (fullName ==
"virgo")
735 if (fullName ==
"volans")
737 if (fullName ==
"vulpecula")
745 if (genetive ==
"andromedae")
747 if (genetive ==
"antliae")
749 if (genetive ==
"apodis")
751 if (genetive ==
"aquarii")
753 if (genetive ==
"aquilae")
755 if (genetive ==
"arae")
757 if (genetive ==
"arietis")
759 if (genetive ==
"aurigae")
761 if (genetive ==
"bootis")
763 if (genetive ==
"caeli")
765 if (genetive ==
"camelopardalis")
767 if (genetive ==
"cancri")
769 if (genetive ==
"canum venaticorum")
771 if (genetive ==
"canis majoris")
773 if (genetive ==
"canis minoris")
775 if (genetive ==
"capricorni")
777 if (genetive ==
"carinae")
779 if (genetive ==
"cassiopeiae")
781 if (genetive ==
"centauri")
783 if (genetive ==
"cephei")
785 if (genetive ==
"ceti")
787 if (genetive ==
"chamaeleontis")
789 if (genetive ==
"circini")
791 if (genetive ==
"columbae")
793 if (genetive ==
"comae berenices")
795 if (genetive ==
"coronae austrinae")
797 if (genetive ==
"coronae borealis")
799 if (genetive ==
"corvi")
801 if (genetive ==
"crateris")
803 if (genetive ==
"crucis")
805 if (genetive ==
"cygni")
807 if (genetive ==
"delphini")
809 if (genetive ==
"doradus")
811 if (genetive ==
"draconis")
813 if (genetive ==
"equulei")
815 if (genetive ==
"eridani")
817 if (genetive ==
"fornacis")
819 if (genetive ==
"geminorum")
821 if (genetive ==
"gruis")
823 if (genetive ==
"herculis")
825 if (genetive ==
"horologii")
827 if (genetive ==
"hydrae")
829 if (genetive ==
"hydri")
831 if (genetive ==
"indi")
833 if (genetive ==
"lacertae")
835 if (genetive ==
"leonis")
837 if (genetive ==
"leonis minoris")
839 if (genetive ==
"leporis")
841 if (genetive ==
"librae")
843 if (genetive ==
"lupi")
845 if (genetive ==
"lyncis")
847 if (genetive ==
"lyrae")
849 if (genetive ==
"mensae")
851 if (genetive ==
"microscopii")
853 if (genetive ==
"monocerotis")
855 if (genetive ==
"muscae")
857 if (genetive ==
"normae")
859 if (genetive ==
"octantis")
861 if (genetive ==
"ophiuchi")
863 if (genetive ==
"orionis")
865 if (genetive ==
"pavonis")
867 if (genetive ==
"pegasi")
869 if (genetive ==
"persei")
871 if (genetive ==
"phoenicis")
873 if (genetive ==
"pictoris")
875 if (genetive ==
"piscium")
877 if (genetive ==
"piscis austrini")
879 if (genetive ==
"puppis")
881 if (genetive ==
"pyxidis")
883 if (genetive ==
"reticuli")
885 if (genetive ==
"sagittae")
887 if (genetive ==
"sagittarii")
889 if (genetive ==
"scorpii")
891 if (genetive ==
"sculptoris")
893 if (genetive ==
"scuti")
895 if (genetive ==
"serpentis")
897 if (genetive ==
"sextantis")
899 if (genetive ==
"tauri")
901 if (genetive ==
"telescopii")
903 if (genetive ==
"trianguli")
905 if (genetive ==
"trianguli australis")
907 if (genetive ==
"tucanae")
909 if (genetive ==
"ursae majoris")
911 if (genetive ==
"ursae minoris")
913 if (genetive ==
"velorum")
915 if (genetive ==
"virginis")
917 if (genetive ==
"volantis")
919 if (genetive ==
"vulpeculae")
940 QFile file(_filename);
945 qSetMessagePattern(
"[%{time yyyy-MM-dd h:mm:ss.zzz t} "
946 "%{if-debug}DEBG%{endif}%{if-info}INFO%{endif}%{if-warning}WARN%{"
947 "endif}%{if-critical}CRIT%{endif}%{if-fatal}FATL%{endif}] "
948 "%{if-category}[%{category}]%{endif} - %{message}");
949 qInstallMessageHandler(File);
954 QFile file(_filename);
958 Write(stream, type, context, msg);
964 qSetMessagePattern(
"[%{time yyyy-MM-dd h:mm:ss.zzz t} "
965 "%{if-debug}DEBG%{endif}%{if-info}INFO%{endif}%{if-warning}WARN%{"
966 "endif}%{if-critical}CRIT%{endif}%{if-fatal}FATL%{endif}] "
967 "%{if-category}[%{category}]%{endif} - %{message}");
968 qInstallMessageHandler(Stdout);
975 Write(stream, type, context, msg);
980 qInstallMessageHandler(Stderr);
987 Write(stream, type, context, msg);
990void Logging::Write(
QTextStream &stream, QtMsgType type,
1016 stream <<
"[" << qSetFieldWidth(30) << context.category << qSetFieldWidth(0)
1018 stream << msg <<
'\n';
1025 qInstallMessageHandler(
nullptr);
1030 qInstallMessageHandler(Disabled);
1062 rules <<
"org.kde.kstars.ekos.debug"
1063 << (Options::verboseLogging() ?
"true" :
"false");
1064 rules <<
"org.kde.kstars.indi.debug" << (Options::iNDILogging() ?
"true" :
"false");
1065 rules <<
"org.kde.kstars.fits.debug" << (Options::fITSLogging() ?
"true" :
"false");
1066 rules <<
"org.kde.kstars.ekos.capture.debug"
1067 << (Options::captureLogging() ?
"true" :
"false");
1068 rules <<
"org.kde.kstars.ekos.focus.debug"
1069 << (Options::focusLogging() ?
"true" :
"false");
1070 rules <<
"org.kde.kstars.ekos.guide.debug"
1071 << (Options::guideLogging() ?
"true" :
"false");
1072 rules <<
"org.kde.kstars.ekos.align.debug"
1073 << (Options::alignmentLogging() ?
"true" :
"false");
1074 rules <<
"org.kde.kstars.ekos.mount.debug"
1075 << (Options::mountLogging() ?
"true" :
"false");
1076 rules <<
"org.kde.kstars.ekos.scheduler.debug"
1077 << (Options::schedulerLogging() ?
"true" :
"false");
1078 rules <<
"org.kde.kstars.ekos.observatory.debug"
1079 << (Options::observatoryLogging() ?
"true" :
"false");
1080 rules <<
"org.kde.kstars.debug" << (Options::verboseLogging() ?
"true" :
"false");
1083 for (
int i = 0; i < rules.
size(); i += 2)
1084 formattedRules.
append(
QString(
"%1=%2\n").arg(rules[i], rules[i + 1]));
1112 prefix = appimg + userPrefix;
1113 else if (flat.
isEmpty() ==
false)
1117 else if (snap.
isEmpty() ==
false)
1118 prefix = snap + userPrefix;
1120 if (option ==
"fitsDir")
1124 else if (option ==
"indiServer")
1126#if defined(INDI_PREFIX)
1127 return QString(INDI_PREFIX
"/bin/indiserver");
1128#elif defined(Q_OS_MACOS)
1129 return "/usr/local/bin/indiserver";
1131 return prefix +
"/bin/indiserver";
1133 else if (option ==
"PlaceholderFormat")
1135#if defined(Q_OS_WIN)
1136 return "\\%t\\%T\\%F\\%t_%T_%F";
1138 return "/%t/%T/%F/%t_%T_%F";
1141 else if (option ==
"INDIHubAgent")
1143#if defined(INDI_PREFIX)
1144 return QString(INDI_PREFIX
"/bin/indihub-agent");
1145#elif defined(Q_OS_MACOS)
1146 return "/usr/local/bin/indihub-agent";
1148 return prefix +
"/bin/indihub-agent";
1150 else if (option ==
"indiDriversDir")
1152#if defined(INDI_PREFIX)
1153 return QString(INDI_PREFIX
"/share/indi");
1154#elif defined(Q_OS_MACOS)
1155 return "/usr/local/share/indi";
1156#elif defined(Q_OS_LINUX)
1157 return prefix +
"/share/indi";
1163 else if (option ==
"AstrometrySolverBinary")
1165#if defined(ASTROMETRY_PREFIX)
1166 return QString(ASTROMETRY_PREFIX
"/bin/solve-field");
1167#elif defined(Q_OS_MACOS)
1168 return "/usr/local/bin/solve-field";
1169#elif defined(Q_OS_WIN)
1171 "/AppData/Local/cygwin_ansvr/lib/astrometry/bin/solve-field.exe";
1173 return prefix +
"/bin/solve-field";
1175 else if (option ==
"WatneyBinary")
1177#if defined(ASTROMETRY_PREFIX)
1178 return QString(ASTROMETRY_PREFIX
"/opt/watney/watney-solve");
1179#elif defined(Q_OS_MACOS)
1180 return "/usr/local/bin/watney-solve";
1181#elif defined(Q_OS_WIN)
1182 return "C:/watney/watney-solve.exe";
1184 return prefix +
"/opt/watney/watney-solve";
1186 else if (option ==
"SextractorBinary")
1188#if defined(SEXTRACTOR_PREFIX)
1189 return QString(SEXTRACTOR_PREFIX
"/bin/source-extractor");
1190#elif defined(Q_OS_MACOS)
1191 return "/usr/local/bin/sex";
1193 return prefix +
"/bin/source-extractor";
1195 else if (option ==
"AstrometryWCSInfo")
1197#if defined(ASTROMETRY_PREFIX)
1198 return QString(ASTROMETRY_PREFIX
"/bin/wcsinfo");
1199#elif defined(Q_OS_MACOS)
1200 return "/usr/local/bin/wcsinfo";
1201#elif defined(Q_OS_WIN)
1203 "/AppData/Local/cygwin_ansvr/lib/astrometry/bin/wcsinfo.exe";
1205 return prefix +
"/bin/wcsinfo";
1207 else if (option ==
"AstrometryConfFile")
1209#if defined(ASTROMETRY_CONF_IN_PREFIX) && defined(ASTROMETRY_PREFIX)
1210 return QString(ASTROMETRY_PREFIX
"/etc/astrometry.cfg");
1211#elif defined(Q_OS_MACOS)
1212 return "/usr/local/etc/astrometry.cfg";
1213#elif defined(Q_OS_WIN)
1215 "/AppData/Local/cygwin_ansvr/etc/astrometry/backend.cfg";
1218 prefix.
remove(userPrefix);
1219 return prefix +
"/etc/astrometry.cfg";
1221 else if (option ==
"AstrometryIndexFileLocation")
1223#if defined(ASTROMETRY_PREFIX)
1224 return QString(ASTROMETRY_PREFIX
"/share/astrometry");
1225#elif defined(Q_OS_MACOS)
1229 return prefix +
"/share/astrometry/";
1231 else if (option ==
"AstrometryLogFilepath")
1235 else if (option ==
"XplanetPath")
1237#if defined(XPLANET_PREFIX)
1238 return QString(XPLANET_PREFIX
"/bin/xplanet");
1239#elif defined(Q_OS_MACOS)
1240 return "/usr/local/bin/xplanet";
1242 return prefix +
"/bin/xplanet";
1244 else if (option ==
"ASTAP")
1246#if defined(Q_OS_MACOS)
1247 return "/Applications/ASTAP.app/Contents/MacOS/astap";
1248#elif defined(Q_OS_WIN)
1249 return "C:/Program Files/astap/astap.exe";
1251 return "/opt/astap/astap";
1263 folderPaths << confDir;
1265 QDir writableDir(confDir);
1266 if (writableDir.exists() ==
false)
1268 if (writableDir.mkdir(confDir) ==
false)
1270 qCCritical(KSTARS) <<
"Failed to create local astrometry directory";
1271 folderPaths.
clear();
1275#ifdef HAVE_STELLARSOLVER
1276 folderPaths.
append(StellarSolver::getDefaultIndexFolderPaths());
1281#if defined(Q_OS_MACOS)
1283void copyResourcesFolderFromAppBundle(
QString folder)
1287 QDir folderSourceDir;
1288 if (folder ==
"kstars")
1296 if (folderSourceDir.
exists())
1302 writableDir.
mkdir(folderLocation);
1303 copyRecursively(folderSourceDir.
absolutePath(), folderLocation);
1307bool setupMacKStarsIfNeeded()
1310 copyResourcesFolderFromAppBundle(
"locale");
1311 copyResourcesFolderFromAppBundle(
"knotifications5");
1312 copyResourcesFolderFromAppBundle(
"sounds");
1315 copyResourcesFolderFromAppBundle(
"kstars");
1316 copyResourcesFolderFromAppBundle(
"kstars/xplanet");
1318 if (Options::kStarsFirstRun())
1321 Options::setIndiServerIsInternal(
true);
1322 Options::setIndiServer(
"*Internal INDI Server*");
1323 Options::setIndiDriversAreInternal(
true);
1324 Options::setIndiDriversDir(
"*Internal INDI Drivers*");
1325 Options::setXplanetIsInternal(
true);
1326 Options::setXplanetPath(
"*Internal XPlanet*");
1337bool configureAstrometry()
1339 QStringList astrometryDataDirs = getAstrometryDataDirs();
1340 if (astrometryDataDirs.
count() == 0)
1342 QString defaultAstrometryDataDir = getDefaultPath(
"AstrometryIndexFileLocation");
1343 if (astrometryDataDirs.
contains(
"IndexFileLocationNotYetSet"))
1344 replaceIndexFileNotYetSet();
1345 if (
QDir(defaultAstrometryDataDir).exists() ==
false)
1349 i18n(
"The selected Astrometry Index File Location:\n %1 \n does not "
1350 "exist. Do you want to make the directory?",
1351 defaultAstrometryDataDir),
1354 if (
QDir(defaultAstrometryDataDir).
mkdir(defaultAstrometryDataDir))
1356 KSNotification::info(
1357 i18n(
"The Default Astrometry Index File Location was created."));
1361 KSNotification::sorry(
1362 i18n(
"The Default Astrometry Index File Directory does not exist and "
1363 "was not able to be created."));
1375bool replaceIndexFileNotYetSet()
1377 QString confPath = KSUtils::getAstrometryConfFilePath();
1379 QFile confFile(confPath);
1383 KSNotification::error(
i18n(
"Astrometry Configuration File Read Error."));
1391 contents.
replace(
"IndexFileLocationNotYetSet",
1392 getDefaultPath(
"AstrometryIndexFileLocation"));
1396 KSNotification::error(
1397 i18n(
"Internal Astrometry Configuration File Write Error."));
1412 QDir sourceDir(sourceFolder);
1414 if (!sourceDir.exists())
1417 QDir destDir(destFolder);
1418 if (!destDir.exists())
1419 destDir.mkdir(destFolder);
1422 for (
int i = 0; i < files.
count(); i++)
1431 for (
int i = 0; i < files.
count(); i++)
1435 copyRecursively(srcName, destName);
1442QString getAstrometryConfFilePath()
1444 return Options::astrometryConfFile();
1449 QStringList optionsDataDirs = Options::astrometryIndexFolderList();
1451 bool updated =
false;
1454 for (
int dir = 0;
dir < optionsDataDirs.
count();
dir++)
1456 QString optionsDataDirName = optionsDataDirs.
at(dir);
1457 QDir optionsDataDir(optionsDataDirName);
1458 if (optionsDataDir.exists())
1461 if (optionsDataDir.absolutePath() != optionsDataDirName)
1463 optionsDataDirs.
replace(dir, optionsDataDir.absolutePath());
1477 QFile confFile(KSUtils::getAstrometryConfFilePath());
1487 line = in.readLine();
1500 for (
QString astrometryDataDirName : confDataDirs)
1502 QDir astrometryDataDir(astrometryDataDirName);
1504 if (!astrometryDataDir.exists())
1506 QString astrometryDataDirPath = astrometryDataDir.absolutePath();
1507 if (!optionsDataDirs.
contains(astrometryDataDirPath))
1509 optionsDataDirs.
append(astrometryDataDirPath);
1521 Options::setAstrometryIndexFolderList(optionsDataDirs);
1523 return optionsDataDirs;
1526bool addAstrometryDataDir(
const QString &dataDir)
1532 QString confPath = KSUtils::getAstrometryConfFilePath();
1533 QStringList astrometryDataDirs = getAstrometryDataDirs();
1535 QFile confFile(confPath);
1539 KSNotification::error(
i18n(
"Astrometry Configuration File Read Error."));
1546 bool foundSpot =
false;
1549 line = in.readLine();
1556 for (
QString astrometryDataDir : astrometryDataDirs)
1557 contents +=
"add_path " + astrometryDataDir +
'\n';
1558 contents +=
"add_path " + dataDir +
'\n';
1567 contents += line +
'\n';
1572 for (
QString astrometryDataDir : astrometryDataDirs)
1573 contents +=
"add_path " + astrometryDataDir +
'\n';
1574 contents +=
"add_path " + dataDir +
'\n';
1581 KSNotification::error(
1582 i18n(
"Internal Astrometry Configuration File Write Error."));
1595bool removeAstrometryDataDir(
const QString &dataDir)
1597 QString confPath = KSUtils::getAstrometryConfFilePath();
1598 QStringList astrometryDataDirs = getAstrometryDataDirs();
1600 QFile confFile(confPath);
1604 KSNotification::error(
i18n(
"Astrometry Configuration File Read Error."));
1613 line = in.readLine();
1616 contents += line +
'\n';
1623 KSNotification::error(
1624 i18n(
"Internal Astrometry Configuration File Write Error."));
1647 if (filters.
size() > 0)
1650 for (
const auto &item : filters)
1652 filter_string +=
"\"" + item.item +
"|" + item.op +
"|" + item.value +
"\",";
1655 filter_string.chop(1);
1656 filter_string +=
"]}";
1658 query +=
"&sb-cdata=" + filter_string;
1662 query +=
"&fields=" + dataFields;
1670 errorMessage =
i18n(
"Unable to find dcraw and cjpeg. Please install the required "
1671 "tools to convert CR2/NEF to JPEG.");
1676 LibRaw RawProcessor;
1679 if ((ret = RawProcessor.open_file(rawImage.
toLatin1().
data())) != LIBRAW_SUCCESS)
1682 RawProcessor.recycle();
1687 if ((ret = RawProcessor.unpack_thumb()) != LIBRAW_SUCCESS)
1689 errorMessage =
i18n(
"Cannot unpack_thumb %1: %2", rawImage, libraw_strerror(ret));
1690 RawProcessor.recycle();
1697 if (LIBRAW_SUCCESS !=
1698 (ret = RawProcessor.dcraw_thumb_writer(output.
toLatin1().
data())))
1700 errorMessage =
i18n(
"Cannot write %s %1: %2", output, libraw_strerror(ret));
1701 RawProcessor.recycle();
1709double getAvailableRAM()
1711#if defined(Q_OS_MACOS)
1712 int mib[] = { CTL_HW, HW_MEMSIZE };
1714 length =
sizeof(int64_t);
1716 if (sysctl(mib, 2, &RAMcheck, &length, NULL, 0))
1720#elif defined(Q_OS_LINUX)
1723 <<
"/proc/meminfo");
1728 return (memory.
toLong() * 1024.0);
1729#elif defined(Q_OS_WIN32)
1730 MEMORYSTATUSEX memory_status;
1731 ZeroMemory(&memory_status,
sizeof(MEMORYSTATUSEX));
1732 memory_status.dwLength =
sizeof(MEMORYSTATUSEX);
1733 if (GlobalMemoryStatusEx(&memory_status))
1735 return memory_status.ullAvailPhys;
1745JPLParser::JPLParser(
const QString &path)
1747 QFile jpl_file(path);
1750 throw std::runtime_error(
"Could not open file.");
1754 const auto &fields = ast_json[
"fields"].toArray();
1755 m_data = ast_json[
"data"].toArray();
1759 for (
const auto &field : fields)
1761 m_field_map[field.toString()] = i++;
1766MPCParser::MPCParser(
const QString &path)
1768 QFile mpc_file(path);
1771 throw std::runtime_error(
"Could not open file.");
1779 const uint32_t len = 32768;
1781 while (!gzeof(file))
1783 char buffer[len] = {0};
1784 int bytes_read = gzread(file, buffer, len - 1);
1787 buffer[bytes_read] = 0;
1793 m_data = ast_json.array();
1796 qCritical(KSTARS) <<
"Failed to read MPC comets data file" <<
path;
1799void setGlobalSettings(
const QVariantMap &settings)
1801 for (
auto &key : settings.keys())
1803 auto property = key;
1806 if (property.startsWith(
"kcfg_"))
1808 property.remove(
"kcfg_");
1809 property.replace(0, 1, property.at(0).toLower());
1811 Options::self()->setProperty(property.toLatin1(), settings[key]);
1814 Options::self()->save();
1824 if (sanitized !=
i18n(
"unnamed"))
1827 sanitized = sanitized.
replace(re1,
"_" )
1836double rangePA(
double pa)
1845double range360(
double r)
1850 while (res > 359.99)
1855double rotationToPositionAngle(
double value)
1857 double pa = value + 180;
1865double positionAngleToRotation(
double value)
1867 double rotation = value - 180;
1868 while (rotation > 180)
1870 while (rotation < -180)
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
static void UseDefault()
Use the default logging mechanism.
static void UseStdout()
Output logs to stdout.
static void SyncFilterRules()
SyncFilterRules Sync QtLogging filter rules from Options.
static void Disable()
Disable logging.
static void UseFile()
Store all logs into the specified file.
static void UseStderr()
Output logs to stderr.
KStars utility functions.
The sky coordinates of a point in the sky.
const CachingDms & ra0() const
const CachingDms & dec0() const
This is a subclass of SkyObject.
An angle, stored as degrees, but expressible in many ways.
const dms reduce() const
return the equivalent angle between 0 and 360 degrees.
const double & Degrees() const
static constexpr double DegToRad
DegToRad is a const static member equal to the number of radians in one degree (dms::PI/180....
KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text)
QString i18n(const char *text, const TYPE &arg...)
QString fullName(const PartType &type)
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
KCALUTILS_EXPORT QString errorMessage(const KCalendarCore::Exception &exception)
KIOCORE_EXPORT MkdirJob * mkdir(const QUrl &url, int permissions=-1)
QString path(const QString &relativePath)
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
KIOCORE_EXPORT QString dir(const QString &fileClass)
QByteArray & append(QByteArrayView data)
const char * constData() const const
QString applicationDirPath()
QDateTime currentDateTime()
QString toString(QStringView format, QCalendar cal) const const
QString absolutePath() const const
bool exists() const const
QString filePath(const QString &fileName) const const
bool mkdir(const QString &dirName) const const
QString toNativeSeparators(const QString &pathName)
bool copy(const QString &fileName, const QString &newName)
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
void setFileName(const QString &name)
virtual void close() override
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
void removeAt(qsizetype i)
void replace(qsizetype i, parameter_type value)
qsizetype size() const const
void setFilterRules(const QString &rules)
virtual void close() override
QByteArray readAllStandardOutput()
void start(OpenMode mode)
bool waitForFinished(int msecs)
QProcessEnvironment systemEnvironment()
QString value(const QString &name, const QString &defaultValue) const const
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
QString writableLocation(StandardLocation type)
QString & append(QChar ch)
QString arg(Args &&... args) const const
QString asprintf(const char *cformat,...)
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
bool isNull() const const
QString mid(qsizetype position, qsizetype n) const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QByteArray toLatin1() const const
long toLong(bool *ok, int base) const const
QString toLower() const const
QString trimmed() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
qsizetype removeDuplicates()
QTextStream & dec(QTextStream &stream)