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()
56bool openDataFile(QFile &file,
const QString &s)
67QString getDSSURL(
const SkyPoint *
const p)
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);
76 const auto *dso =
dynamic_cast<const CatalogObject *
>(p);
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?");
119 QString URLsuffix = QString(
"&e=J2000&f=%1&c=none&fov=NONE").arg(type);
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);
147QString toDirectionString(dms angle)
155 static const KLocalizedString directions[] =
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();
187QList<SkyObject *> *castStarObjListToSkyObjList(QList<StarObject *> *starObjList)
189 QList<SkyObject *> *skyObjList =
new QList<SkyObject *>();
191 foreach (StarObject *so, *starObjList)
198QString constGenetiveFromAbbrev(
const QString &code)
201 return QString(
"Andromedae");
203 return QString(
"Antliae");
205 return QString(
"Apodis");
207 return QString(
"Aquarii");
209 return QString(
"Aquilae");
211 return QString(
"Arae");
213 return QString(
"Arietis");
215 return QString(
"Aurigae");
217 return QString(
"Bootis");
219 return QString(
"Caeli");
221 return QString(
"Camelopardalis");
223 return QString(
"Cancri");
225 return QString(
"Canum Venaticorum");
227 return QString(
"Canis Majoris");
229 return QString(
"Canis Minoris");
231 return QString(
"Capricorni");
233 return QString(
"Carinae");
235 return QString(
"Cassiopeiae");
237 return QString(
"Centauri");
239 return QString(
"Cephei");
241 return QString(
"Ceti");
243 return QString(
"Chamaeleontis");
245 return QString(
"Circini");
247 return QString(
"Columbae");
249 return QString(
"Comae Berenices");
251 return QString(
"Coronae Austrinae");
253 return QString(
"Coronae Borealis");
255 return QString(
"Corvi");
257 return QString(
"Crateris");
259 return QString(
"Crucis");
261 return QString(
"Cygni");
263 return QString(
"Delphini");
265 return QString(
"Doradus");
267 return QString(
"Draconis");
269 return QString(
"Equulei");
271 return QString(
"Eridani");
273 return QString(
"Fornacis");
275 return QString(
"Geminorum");
277 return QString(
"Gruis");
279 return QString(
"Herculis");
281 return QString(
"Horologii");
283 return QString(
"Hydrae");
285 return QString(
"Hydri");
287 return QString(
"Indi");
289 return QString(
"Lacertae");
291 return QString(
"Leonis");
293 return QString(
"Leonis Minoris");
295 return QString(
"Leporis");
297 return QString(
"Librae");
299 return QString(
"Lupi");
301 return QString(
"Lyncis");
303 return QString(
"Lyrae");
305 return QString(
"Mensae");
307 return QString(
"Microscopii");
309 return QString(
"Monocerotis");
311 return QString(
"Muscae");
313 return QString(
"Normae");
315 return QString(
"Octantis");
317 return QString(
"Ophiuchi");
319 return QString(
"Orionis");
321 return QString(
"Pavonis");
323 return QString(
"Pegasi");
325 return QString(
"Persei");
327 return QString(
"Phoenicis");
329 return QString(
"Pictoris");
331 return QString(
"Piscium");
333 return QString(
"Piscis Austrini");
335 return QString(
"Puppis");
337 return QString(
"Pyxidis");
339 return QString(
"Reticuli");
341 return QString(
"Sagittae");
343 return QString(
"Sagittarii");
345 return QString(
"Scorpii");
347 return QString(
"Sculptoris");
349 return QString(
"Scuti");
351 return QString(
"Serpentis");
353 return QString(
"Sextantis");
355 return QString(
"Tauri");
357 return QString(
"Telescopii");
359 return QString(
"Trianguli");
361 return QString(
"Trianguli Australis");
363 return QString(
"Tucanae");
365 return QString(
"Ursae Majoris");
367 return QString(
"Ursae Minoris");
369 return QString(
"Velorum");
371 return QString(
"Virginis");
373 return QString(
"Volantis");
375 return QString(
"Vulpeculae");
379QString constNameFromAbbrev(
const QString &code)
382 return QString(
"Andromeda");
384 return QString(
"Antlia");
386 return QString(
"Apus");
388 return QString(
"Aquarius");
390 return QString(
"Aquila");
392 return QString(
"Ara");
394 return QString(
"Aries");
396 return QString(
"Auriga");
398 return QString(
"Bootes");
400 return QString(
"Caelum");
402 return QString(
"Camelopardalis");
404 return QString(
"Cancer");
406 return QString(
"Canes Venatici");
408 return QString(
"Canis Major");
410 return QString(
"Canis Minor");
412 return QString(
"Capricornus");
414 return QString(
"Carina");
416 return QString(
"Cassiopeia");
418 return QString(
"Centaurus");
420 return QString(
"Cepheus");
422 return QString(
"Cetus");
424 return QString(
"Chamaeleon");
426 return QString(
"Circinus");
428 return QString(
"Columba");
430 return QString(
"Coma Berenices");
432 return QString(
"Corona Australis");
434 return QString(
"Corona Borealis");
436 return QString(
"Corvus");
438 return QString(
"Crater");
440 return QString(
"Crux");
442 return QString(
"Cygnus");
444 return QString(
"Delphinus");
446 return QString(
"Doradus");
448 return QString(
"Draco");
450 return QString(
"Equuleus");
452 return QString(
"Eridanus");
454 return QString(
"Fornax");
456 return QString(
"Gemini");
458 return QString(
"Grus");
460 return QString(
"Hercules");
462 return QString(
"Horologium");
464 return QString(
"Hydra");
466 return QString(
"Hydrus");
468 return QString(
"Indus");
470 return QString(
"Lacerta");
472 return QString(
"Leo");
474 return QString(
"Leo Minor");
476 return QString(
"Lepus");
478 return QString(
"Libra");
480 return QString(
"Lupus");
482 return QString(
"Lynx");
484 return QString(
"Lyra");
486 return QString(
"Mensa");
488 return QString(
"Microscopium");
490 return QString(
"Monoceros");
492 return QString(
"Musca");
494 return QString(
"Norma");
496 return QString(
"Octans");
498 return QString(
"Ophiuchus");
500 return QString(
"Orion");
502 return QString(
"Pavo");
504 return QString(
"Pegasus");
506 return QString(
"Perseus");
508 return QString(
"Phoenix");
510 return QString(
"Pictor");
512 return QString(
"Pisces");
514 return QString(
"Piscis Austrinus");
516 return QString(
"Puppis");
518 return QString(
"Pyxis");
520 return QString(
"Reticulum");
522 return QString(
"Sagitta");
524 return QString(
"Sagittarius");
526 return QString(
"Scorpius");
528 return QString(
"Sculptor");
530 return QString(
"Scutum");
532 return QString(
"Serpens");
534 return QString(
"Sextans");
536 return QString(
"Taurus");
538 return QString(
"Telescopium");
540 return QString(
"Triangulum");
542 return QString(
"Triangulum Australe");
544 return QString(
"Tucana");
546 return QString(
"Ursa Major");
548 return QString(
"Ursa Minor");
550 return QString(
"Vela");
552 return QString(
"Virgo");
554 return QString(
"Volans");
556 return QString(
"Vulpecula");
560QString constNameToAbbrev(
const QString &fullName_)
563 if (fullName ==
"andromeda")
564 return QString(
"And");
565 if (fullName ==
"antlia")
566 return QString(
"Ant");
567 if (fullName ==
"apus")
568 return QString(
"Aps");
569 if (fullName ==
"aquarius")
570 return QString(
"Aqr");
571 if (fullName ==
"aquila")
572 return QString(
"Aql");
573 if (fullName ==
"ara")
574 return QString(
"Ara");
575 if (fullName ==
"aries")
576 return QString(
"Ari");
577 if (fullName ==
"auriga")
578 return QString(
"Aur");
579 if (fullName ==
"bootes")
580 return QString(
"Boo");
581 if (fullName ==
"caelum")
582 return QString(
"Cae");
583 if (fullName ==
"camelopardalis")
584 return QString(
"Cam");
585 if (fullName ==
"cancer")
586 return QString(
"Cnc");
587 if (fullName ==
"canes venatici")
588 return QString(
"CVn");
589 if (fullName ==
"canis major")
590 return QString(
"CMa");
591 if (fullName ==
"canis minor")
592 return QString(
"CMi");
593 if (fullName ==
"capricornus")
594 return QString(
"Cap");
595 if (fullName ==
"carina")
596 return QString(
"Car");
597 if (fullName ==
"cassiopeia")
598 return QString(
"Cas");
599 if (fullName ==
"centaurus")
600 return QString(
"Cen");
601 if (fullName ==
"cepheus")
602 return QString(
"Cep");
603 if (fullName ==
"cetus")
604 return QString(
"Cet");
605 if (fullName ==
"chamaeleon")
606 return QString(
"Cha");
607 if (fullName ==
"circinus")
608 return QString(
"Cir");
609 if (fullName ==
"columba")
610 return QString(
"Col");
611 if (fullName ==
"coma berenices")
612 return QString(
"Com");
613 if (fullName ==
"corona australis")
614 return QString(
"CrA");
615 if (fullName ==
"corona borealis")
616 return QString(
"CrB");
617 if (fullName ==
"corvus")
618 return QString(
"Crv");
619 if (fullName ==
"crater")
620 return QString(
"Crt");
621 if (fullName ==
"crux")
622 return QString(
"Cru");
623 if (fullName ==
"cygnus")
624 return QString(
"Cyg");
625 if (fullName ==
"delphinus")
626 return QString(
"Del");
627 if (fullName ==
"doradus")
628 return QString(
"Dor");
629 if (fullName ==
"draco")
630 return QString(
"Dra");
631 if (fullName ==
"equuleus")
632 return QString(
"Equ");
633 if (fullName ==
"eridanus")
634 return QString(
"Eri");
635 if (fullName ==
"fornax")
636 return QString(
"For");
637 if (fullName ==
"gemini")
638 return QString(
"Gem");
639 if (fullName ==
"grus")
640 return QString(
"Gru");
641 if (fullName ==
"hercules")
642 return QString(
"Her");
643 if (fullName ==
"horologium")
644 return QString(
"Hor");
645 if (fullName ==
"hydra")
646 return QString(
"Hya");
647 if (fullName ==
"hydrus")
648 return QString(
"Hyi");
649 if (fullName ==
"indus")
650 return QString(
"Ind");
651 if (fullName ==
"lacerta")
652 return QString(
"Lac");
653 if (fullName ==
"leo")
654 return QString(
"Leo");
655 if (fullName ==
"leo minor")
656 return QString(
"LMi");
657 if (fullName ==
"lepus")
658 return QString(
"Lep");
659 if (fullName ==
"libra")
660 return QString(
"Lib");
661 if (fullName ==
"lupus")
662 return QString(
"Lup");
663 if (fullName ==
"lynx")
664 return QString(
"Lyn");
665 if (fullName ==
"lyra")
666 return QString(
"Lyr");
667 if (fullName ==
"mensa")
668 return QString(
"Men");
669 if (fullName ==
"microscopium")
670 return QString(
"Mic");
671 if (fullName ==
"monoceros")
672 return QString(
"Mon");
673 if (fullName ==
"musca")
674 return QString(
"Mus");
675 if (fullName ==
"norma")
676 return QString(
"Nor");
677 if (fullName ==
"octans")
678 return QString(
"Oct");
679 if (fullName ==
"ophiuchus")
680 return QString(
"Oph");
681 if (fullName ==
"orion")
682 return QString(
"Ori");
683 if (fullName ==
"pavo")
684 return QString(
"Pav");
685 if (fullName ==
"pegasus")
686 return QString(
"Peg");
687 if (fullName ==
"perseus")
688 return QString(
"Per");
689 if (fullName ==
"phoenix")
690 return QString(
"Phe");
691 if (fullName ==
"pictor")
692 return QString(
"Pic");
693 if (fullName ==
"pisces")
694 return QString(
"Psc");
695 if (fullName ==
"piscis austrinus")
696 return QString(
"PsA");
697 if (fullName ==
"puppis")
698 return QString(
"Pup");
699 if (fullName ==
"pyxis")
700 return QString(
"Pyx");
701 if (fullName ==
"reticulum")
702 return QString(
"Ret");
703 if (fullName ==
"sagitta")
704 return QString(
"Sge");
705 if (fullName ==
"sagittarius")
706 return QString(
"Sgr");
707 if (fullName ==
"scorpius")
708 return QString(
"Sco");
709 if (fullName ==
"sculptor")
710 return QString(
"Scl");
711 if (fullName ==
"scutum")
712 return QString(
"Sct");
713 if (fullName ==
"serpens")
714 return QString(
"Ser");
715 if (fullName ==
"sextans")
716 return QString(
"Sex");
717 if (fullName ==
"taurus")
718 return QString(
"Tau");
719 if (fullName ==
"telescopium")
720 return QString(
"Tel");
721 if (fullName ==
"triangulum")
722 return QString(
"Tri");
723 if (fullName ==
"triangulum australe")
724 return QString(
"TrA");
725 if (fullName ==
"tucana")
726 return QString(
"Tuc");
727 if (fullName ==
"ursa major")
728 return QString(
"UMa");
729 if (fullName ==
"ursa minor")
730 return QString(
"UMi");
731 if (fullName ==
"vela")
732 return QString(
"Vel");
733 if (fullName ==
"virgo")
734 return QString(
"Vir");
735 if (fullName ==
"volans")
736 return QString(
"Vol");
737 if (fullName ==
"vulpecula")
738 return QString(
"Vul");
742QString constGenetiveToAbbrev(
const QString &genetive_)
744 QString genetive = genetive_.
toLower();
745 if (genetive ==
"andromedae")
746 return QString(
"And");
747 if (genetive ==
"antliae")
748 return QString(
"Ant");
749 if (genetive ==
"apodis")
750 return QString(
"Aps");
751 if (genetive ==
"aquarii")
752 return QString(
"Aqr");
753 if (genetive ==
"aquilae")
754 return QString(
"Aql");
755 if (genetive ==
"arae")
756 return QString(
"Ara");
757 if (genetive ==
"arietis")
758 return QString(
"Ari");
759 if (genetive ==
"aurigae")
760 return QString(
"Aur");
761 if (genetive ==
"bootis")
762 return QString(
"Boo");
763 if (genetive ==
"caeli")
764 return QString(
"Cae");
765 if (genetive ==
"camelopardalis")
766 return QString(
"Cam");
767 if (genetive ==
"cancri")
768 return QString(
"Cnc");
769 if (genetive ==
"canum venaticorum")
770 return QString(
"CVn");
771 if (genetive ==
"canis majoris")
772 return QString(
"CMa");
773 if (genetive ==
"canis minoris")
774 return QString(
"CMi");
775 if (genetive ==
"capricorni")
776 return QString(
"Cap");
777 if (genetive ==
"carinae")
778 return QString(
"Car");
779 if (genetive ==
"cassiopeiae")
780 return QString(
"Cas");
781 if (genetive ==
"centauri")
782 return QString(
"Cen");
783 if (genetive ==
"cephei")
784 return QString(
"Cep");
785 if (genetive ==
"ceti")
786 return QString(
"Cet");
787 if (genetive ==
"chamaeleontis")
788 return QString(
"Cha");
789 if (genetive ==
"circini")
790 return QString(
"Cir");
791 if (genetive ==
"columbae")
792 return QString(
"Col");
793 if (genetive ==
"comae berenices")
794 return QString(
"Com");
795 if (genetive ==
"coronae austrinae")
796 return QString(
"CrA");
797 if (genetive ==
"coronae borealis")
798 return QString(
"CrB");
799 if (genetive ==
"corvi")
800 return QString(
"Crv");
801 if (genetive ==
"crateris")
802 return QString(
"Crt");
803 if (genetive ==
"crucis")
804 return QString(
"Cru");
805 if (genetive ==
"cygni")
806 return QString(
"Cyg");
807 if (genetive ==
"delphini")
808 return QString(
"Del");
809 if (genetive ==
"doradus")
810 return QString(
"Dor");
811 if (genetive ==
"draconis")
812 return QString(
"Dra");
813 if (genetive ==
"equulei")
814 return QString(
"Equ");
815 if (genetive ==
"eridani")
816 return QString(
"Eri");
817 if (genetive ==
"fornacis")
818 return QString(
"For");
819 if (genetive ==
"geminorum")
820 return QString(
"Gem");
821 if (genetive ==
"gruis")
822 return QString(
"Gru");
823 if (genetive ==
"herculis")
824 return QString(
"Her");
825 if (genetive ==
"horologii")
826 return QString(
"Hor");
827 if (genetive ==
"hydrae")
828 return QString(
"Hya");
829 if (genetive ==
"hydri")
830 return QString(
"Hyi");
831 if (genetive ==
"indi")
832 return QString(
"Ind");
833 if (genetive ==
"lacertae")
834 return QString(
"Lac");
835 if (genetive ==
"leonis")
836 return QString(
"Leo");
837 if (genetive ==
"leonis minoris")
838 return QString(
"LMi");
839 if (genetive ==
"leporis")
840 return QString(
"Lep");
841 if (genetive ==
"librae")
842 return QString(
"Lib");
843 if (genetive ==
"lupi")
844 return QString(
"Lup");
845 if (genetive ==
"lyncis")
846 return QString(
"Lyn");
847 if (genetive ==
"lyrae")
848 return QString(
"Lyr");
849 if (genetive ==
"mensae")
850 return QString(
"Men");
851 if (genetive ==
"microscopii")
852 return QString(
"Mic");
853 if (genetive ==
"monocerotis")
854 return QString(
"Mon");
855 if (genetive ==
"muscae")
856 return QString(
"Mus");
857 if (genetive ==
"normae")
858 return QString(
"Nor");
859 if (genetive ==
"octantis")
860 return QString(
"Oct");
861 if (genetive ==
"ophiuchi")
862 return QString(
"Oph");
863 if (genetive ==
"orionis")
864 return QString(
"Ori");
865 if (genetive ==
"pavonis")
866 return QString(
"Pav");
867 if (genetive ==
"pegasi")
868 return QString(
"Peg");
869 if (genetive ==
"persei")
870 return QString(
"Per");
871 if (genetive ==
"phoenicis")
872 return QString(
"Phe");
873 if (genetive ==
"pictoris")
874 return QString(
"Pic");
875 if (genetive ==
"piscium")
876 return QString(
"Psc");
877 if (genetive ==
"piscis austrini")
878 return QString(
"PsA");
879 if (genetive ==
"puppis")
880 return QString(
"Pup");
881 if (genetive ==
"pyxidis")
882 return QString(
"Pyx");
883 if (genetive ==
"reticuli")
884 return QString(
"Ret");
885 if (genetive ==
"sagittae")
886 return QString(
"Sge");
887 if (genetive ==
"sagittarii")
888 return QString(
"Sgr");
889 if (genetive ==
"scorpii")
890 return QString(
"Sco");
891 if (genetive ==
"sculptoris")
892 return QString(
"Scl");
893 if (genetive ==
"scuti")
894 return QString(
"Sct");
895 if (genetive ==
"serpentis")
896 return QString(
"Ser");
897 if (genetive ==
"sextantis")
898 return QString(
"Sex");
899 if (genetive ==
"tauri")
900 return QString(
"Tau");
901 if (genetive ==
"telescopii")
902 return QString(
"Tel");
903 if (genetive ==
"trianguli")
904 return QString(
"Tri");
905 if (genetive ==
"trianguli australis")
906 return QString(
"TrA");
907 if (genetive ==
"tucanae")
908 return QString(
"Tuc");
909 if (genetive ==
"ursae majoris")
910 return QString(
"UMa");
911 if (genetive ==
"ursae minoris")
912 return QString(
"UMi");
913 if (genetive ==
"velorum")
914 return QString(
"Vel");
915 if (genetive ==
"virginis")
916 return QString(
"Vir");
917 if (genetive ==
"volantis")
918 return QString(
"Vol");
919 if (genetive ==
"vulpeculae")
920 return QString(
"Vul");
924QString Logging::_filename;
928 if (_filename.isEmpty())
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)
1227 .filePath(
"Astrometry/");
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";
1257QStringList getAstrometryDefaultIndexFolderPaths()
1259 QStringList folderPaths;
1260 const QString confDir =
1262 .filePath(QLatin1String(
"astrometry"));
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."));
1388 QByteArray fileContent = confFile.readAll();
1391 contents.
replace(
"IndexFileLocationNotYetSet",
1392 getDefaultPath(
"AstrometryIndexFileLocation"));
1396 KSNotification::error(
1397 i18n(
"Internal Astrometry Configuration File Write Error."));
1402 QTextStream out(&confFile);
1410bool copyRecursively(QString sourceFolder, QString destFolder)
1412 QDir sourceDir(sourceFolder);
1414 if (!sourceDir.exists())
1417 QDir destDir(destFolder);
1418 if (!destDir.exists())
1419 destDir.mkdir(destFolder);
1421 QStringList files = sourceDir.entryList(
QDir::Files);
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();
1447QStringList getAstrometryDataDirs()
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());
1480 QStringList confDataDirs;
1481 QTextStream in(&confFile);
1487 line = in.readLine();
1492 if (line.
startsWith(QLatin1String(
"add_path")))
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."));
1544 QTextStream in(&confFile);
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."));
1587 QTextStream out(&confFile);
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."));
1609 QTextStream in(&confFile);
1613 line = in.readLine();
1616 contents += line +
'\n';
1623 KSNotification::error(
1624 i18n(
"Internal Astrometry Configuration File Write Error."));
1629 QTextStream out(&confFile);
1637QByteArray getJPLQueryString(
const QByteArray &kind,
const QByteArray &dataFields,
1638 const QVector<JPLFilter> &filters)
1644 QByteArray
query(
"sb-kind=" + kind +
"&full-prec=true");
1647 if (filters.
size() > 0)
1649 QByteArray filter_string(
"{\"AND\":[");
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;
1667bool RAWToJPEG(
const QString &rawImage,
const QString &output, QString &errorMessage)
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)
1722 p.
start(
"awk", QStringList() <<
"/MemAvailable/ { print $2 }"
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();
1817QString sanitize(
const QString &text)
1819 static const QRegularExpression re1(
"\\s|/|\\(|\\)|:|\\*|\\+|~|\"" );
1820 static const QRegularExpression re2(
"_{2,}");
1821 static const QRegularExpression re3(
"_$");
1823 QString sanitized = text;
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)
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.
const CachingDms & ra0() const
const CachingDms & dec0() const
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 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)