diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1e3a09af4..94bcb34cc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,45 +1,47 @@ include_directories( ${kstars_SOURCE_DIR}/kstars/tools ${kstars_SOURCE_DIR}/kstars/skyobjects ${kstars_SOURCE_DIR}/kstars/skycomponents ${kstars_SOURCE_DIR}/kstars/auxiliary ${kstars_SOURCE_DIR}/kstars/time + ${kstars_SOURCE_DIR}/kstars/ekos/align ) if(WCSLIB_FOUND) include_directories( ${WCSLIB_INCLUDE_DIR} ) endif(WCSLIB_FOUND) FIND_PACKAGE(Qt5Test REQUIRED) SET( TEST_LIBRARIES Qt5::Core Qt5::Test LibKSDataHandlers htmesh ${ZLIB_LIBRARIES} KStarsLib ) SET( TEST_KSLITE_LIBRARIES Qt5::Core Qt5::Test LibKSDataHandlers htmesh ${ZLIB_LIBRARIES} KStarsLiteLib ) add_subdirectory(auxiliary) add_subdirectory(skyobjects) +add_subdirectory(polaralign) IF (CFITSIO_FOUND) add_subdirectory(fitsviewer) ENDIF () IF (UNIX AND NOT APPLE AND CFITSIO_FOUND) IF (BUILD_KSTARS_LITE) add_subdirectory(kstars_lite_ui) ENDIF () add_subdirectory(kstars_ui) ENDIF () diff --git a/Tests/polaralign/CMakeLists.txt b/Tests/polaralign/CMakeLists.txt new file mode 100644 index 000000000..656cf0b78 --- /dev/null +++ b/Tests/polaralign/CMakeLists.txt @@ -0,0 +1,3 @@ +ADD_EXECUTABLE( test_polaralign test_polaralign.cpp ) +TARGET_LINK_LIBRARIES( test_polaralign ${TEST_LIBRARIES}) +ADD_TEST( NAME TestPolarAlign COMMAND test_polaralign ) diff --git a/Tests/polaralign/test_polaralign.cpp b/Tests/polaralign/test_polaralign.cpp new file mode 100644 index 000000000..3d6644a7f --- /dev/null +++ b/Tests/polaralign/test_polaralign.cpp @@ -0,0 +1,161 @@ +/*************************************************************************** + test_polaralign.cpp - KStars Planetarium + ------------------- + begin : Tue 27 Sep 2016 20:54:28 CDT + copyright : (c) 2016 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 "test_polaralign.h" +#include "ksnumbers.h" +#include "time/kstarsdatetime.h" +#include "auxiliary/dms.h" +#include "Options.h" +#include + +TestPolarAlign::TestPolarAlign() : QObject() +{ +} + +TestPolarAlign::~TestPolarAlign() +{ +} + +void TestPolarAlign::compare(QVector3D v, double x, double y, double z) +{ + QVERIFY2(std::fabs(v.x() - x) < 0.00001, + qPrintable(QString("dc.x %1, x %2 error %3").arg(v.x()).arg(x).arg(((v.x() - x) * 3600.0), 6,'f', 1))); + QVERIFY2(std::fabs(v.y() - y) < 0.00001, + qPrintable(QString("dc.y %1, y %2 error %3").arg(v.y()).arg(y).arg(((v.y() - y) * 3600.0), 6,'f', 1))); + QVERIFY2(std::fabs(v.z() - z) < 0.00001, + qPrintable(QString("dc.z %1, z %2 error %3").arg(v.z()).arg(z).arg(((v.z() - z) * 3600.0), 6,'f', 1))); +} + +void TestPolarAlign::compare(double a, double e, QString msg) +{ + QVERIFY2(std::fabs(a - e) < 0.0003, + qPrintable(QString("%1: actual %2, expected %3 error %4").arg(msg).arg(a).arg(e).arg(((a - e) * 3600.0), 6,'f', 1))); +} + + +void TestPolarAlign::testDirCos_data() +{ + QTest::addColumn("Ha"); + QTest::addColumn("Dec"); + QTest::addColumn("X"); + QTest::addColumn("Y"); + QTest::addColumn("Z"); + + QTest::newRow("HaDec0") << 0.0 << 0.0 << 1.0 << 0.0 << 0.0; + QTest::newRow("Ha0Dec45") << 0.0 << 45.0 << 0.707107 << 0.0 << 0.707107; + QTest::newRow("Ha6Dec45") << 6.0 << 45.0 << 0.0 << 0.707107 << 0.707107; + QTest::newRow("Ha-6Dec45") << -6.0 << 45.0 << 0.0 << -0.707107 << 0.707107; + QTest::newRow("at Pole") << 0.0 << 90.0 << 0.0 << 0.0 << 1.0; + QTest::newRow("near S Pole") << -3.0 << -85.0 << 0.0616284 << -0.0616284 << -0.996195; +} + +void TestPolarAlign::testDirCos() +{ + dms h; + dms d; + QFETCH(double, Ha); + QFETCH(double, Dec); + h.setH(Ha); + d.setD(Dec); + + + QVector3D dc; + dc = PolarAlign::dirCos(h, d); + + + QFETCH(double, X); + QFETCH(double, Y); + QFETCH(double, Z); + + compare(dc, X, Y, Z); + + SkyPoint sp(Ha, Dec); + dc = PolarAlign::dirCos(sp); + QCOMPARE(dc.length(), 1.0); + compare(dc, X, Y, Z); +} + +void TestPolarAlign::testPriSec_data() +{ + testDirCos_data(); +} + +void TestPolarAlign::testPriSec() +{ + QFETCH(double, Ha); + QFETCH(double, Dec); + QFETCH(double, X); + QFETCH(double, Y); + QFETCH(double, Z); + QVector3D dc(X, Y, Z); + dms p = PolarAlign::primary(dc); + compare(p.HoursHa(), Ha, "Ha"); + compare(PolarAlign::secondary(dc).Degrees(), Dec, "Dec"); +} + + +void TestPolarAlign::testPoleAxis_data() +{ + QTest::addColumn("Ha1"); + QTest::addColumn("Dec1"); + QTest::addColumn("Ha2"); + QTest::addColumn("Dec2"); + QTest::addColumn("Ha3"); + QTest::addColumn("Dec3"); + QTest::addColumn("X"); + QTest::addColumn("Y"); + QTest::addColumn("Z"); + + QTest::newRow("Ha-606Dec0") << -6.0 << 0.0 << 0.0 << 0.0 << 6.0 << 0.0 << 0.0 << 0.0 << 1.0; + QTest::newRow("Ha20-2Dec89") << 2.0 << 89.0 << 0.0 << 89.0 << -2.0 << 89.0 << 0.0 << 0.0 << -1.0; + QTest::newRow("Ha0-22Dec89v") << 0.0 << 89.0 << -2.0 << 89.1 << 2.0 << 88.9 << -0.0006 << -0.003386 << -0.99999; + QTest::newRow("Ha2-20Dec-89") << 2.0 << -89.0 << -2.0 << -89.0 << 0.0 << -89.0 << 0.0 << 0.0 << 1.0; + QTest::newRow("Ha20-2Dec89") << 2.0 << 89.0 << 0.0 << 89.0 << -2.0 << 88.0 << 0.05633683 << 0.0150954 << 0.998298; + // failure cases, 2 or more points the same should ruturn a null matrix + QTest::newRow("Ha000Dec0") << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; + QTest::newRow("Ha100Dec0") << 1.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; + QTest::newRow("Ha110Dec0") << 1.0 << 0.0 << 1.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; + QTest::newRow("Ha011Dec0") << 0.0 << 0.0 << 1.0 << 0.0 << 1.0 << 0.0 << 0.0 << 0.0 << 0.0; +} + +void TestPolarAlign::testPoleAxis() +{ + QFETCH(double, Ha1); + QFETCH(double, Dec1); + QFETCH(double, Ha2); + QFETCH(double, Dec2); + QFETCH(double, Ha3); + QFETCH(double, Dec3); + + QFETCH(double, X); + QFETCH(double, Y); + QFETCH(double, Z); + + SkyPoint p1(Ha1, Dec1); + SkyPoint p2(Ha2, Dec2); + SkyPoint p3(Ha3, Dec3); + + + QVector3D pa = PolarAlign::poleAxis(p1, p2, p3); + + compare(pa.x(), X, "X"); + compare(pa.y(), Y, "Y"); + compare(pa.z(), Z, "Z"); +} + +QTEST_GUILESS_MAIN(TestPolarAlign) diff --git a/Tests/polaralign/test_polaralign.h b/Tests/polaralign/test_polaralign.h new file mode 100644 index 000000000..9ea1577ef --- /dev/null +++ b/Tests/polaralign/test_polaralign.h @@ -0,0 +1,58 @@ +/*************************************************************************** + test_polaralign.h - KStars Planetarium + ------------------- + begin : Tue 27 Sep 2016 20:51:21 CDT + copyright : (c) 2020 by Chris Rowland + email : +***************************************************************************/ + +/*************************************************************************** + * * + * 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 TEST_POLARALIGN_H +#define TEST_POLARALIGN_H + +#include +#include +#include + +#define UNIT_TEST + +#include "../../kstars/ekos/align/polaralign.h" + +/** + * @class TestPolarAlign + * @short Tests for some polar align operations + * @author Chris Rowland + */ + +class TestPolarAlign : public QObject +{ + Q_OBJECT + + public: + TestPolarAlign(); + ~TestPolarAlign() override; + +private slots: + void testDirCos_data(); + void testDirCos(); + void testPriSec_data(); + void testPriSec(); + void testPoleAxis_data(); + void testPoleAxis(); + +private: + void compare(QVector3D v, double x, double y, double z); + void compare(double a, double e, QString msg = ""); + void compare(float a, double e, QString msg = "") { compare (static_cast(a), e, msg); } +}; + + +#endif diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt index 503edb7e7..c03eb0aba 100644 --- a/kstars/CMakeLists.txt +++ b/kstars/CMakeLists.txt @@ -1,1219 +1,1220 @@ add_subdirectory( data ) add_subdirectory( icons ) add_subdirectory( htmesh ) if (${KF5_VERSION} VERSION_EQUAL 5.18.0 OR ${KF5_VERSION} VERSION_GREATER 5.18.0) SET(HAVE_KF5WIT 1) # if(NOT BUILD_KSTARS_LITE) # add_subdirectory( tools/whatsinteresting/qml) # endif(NOT BUILD_KSTARS_LITE) else() SET(HAVE_KF5WIT 0) endif() if (ANDROID AND CMAKE_TOOLCHAIN_FILE) include(${CMAKE_TOOLCHAIN_FILE}) endif () if (NOT ANDROID) find_package(ZLIB REQUIRED) find_package(Threads REQUIRED) endif () if(MSVC) add_definitions(-D_USE_MATH_DEFINES=1) add_definitions(-DNOMINMAX) endif() include_directories( ${kstars_SOURCE_DIR}/kstars ${kstars_SOURCE_DIR}/kstars/skyobjects ${kstars_SOURCE_DIR}/kstars/skycomponents ${kstars_SOURCE_DIR}/kstars/auxiliary ${kstars_SOURCE_DIR}/kstars/time ${kstars_SOURCE_DIR}/kstars/tools ) if (INDI_FOUND) if(BUILD_KSTARS_LITE) set (fits_klite_SRCS fitsviewer/fitsdata.cpp ) set (fits2_klite_SRCS fitsviewer/bayer.c fitsviewer/fpack.c fitsviewer/fpackutil.c ) include_directories(${CFITSIO_INCLUDE_DIR}) include_directories(${NOVA_INCLUDE_DIR}) set (indi_klite_SRCS indi/clientmanagerlite.cpp indi/inditelescopelite.cpp kstarslite/skyitems/skynodes/crosshairnode.cpp kstarslite/skyitems/telescopesymbolsitem.cpp ) endif () set(indiui_SRCS indi/streamform.ui indi/drivermanager.ui indi/opsindi.ui indi/indihostconf.ui indi/customdrivers.ui #indi/telescopewizard.ui ) set(indi_SRCS indi/drivermanager.cpp indi/servermanager.cpp indi/clientmanager.cpp indi/blobmanager.cpp indi/guimanager.cpp indi/driverinfo.cpp indi/deviceinfo.cpp indi/indidevice.cpp indi/indigroup.cpp indi/indiproperty.cpp indi/indielement.cpp indi/indistd.cpp indi/indilistener.cpp indi/inditelescope.cpp indi/indiccd.cpp indi/wsmedia.cpp indi/indifocuser.cpp indi/indifilter.cpp indi/indidome.cpp indi/indiweather.cpp indi/indicap.cpp indi/indilightbox.cpp indi/indidbus.cpp indi/opsindi.cpp #indi/telescopewizardprocess.cpp indi/streamwg.cpp indi/videowg.cpp indi/indiwebmanager.cpp indi/customdrivers.cpp ) if (CFITSIO_FOUND) set(ekosui_SRCS ekos/opsekos.ui ekos/manager.ui ekos/profileeditor.ui ekos/profilewizard.ui # Scheduler ekos/scheduler/scheduler.ui ekos/scheduler/mosaic.ui # Capture ekos/capture/capture.ui ekos/capture/calibrationoptions.ui ekos/capture/dslrinfo.ui ekos/capture/rotatorsettings.ui ekos/capture/customproperties.ui # Align ekos/align/align.ui ekos/align/opsastrometry.ui ekos/align/opsalign.ui ekos/align/opsastrometrycfg.ui ekos/align/opsastrometryindexfiles.ui ekos/align/mountmodel.ui ekos/align/opsastap.ui # Focus ekos/focus/focus.ui # Mount ekos/mount/mount.ui # Guide ekos/guide/guide.ui ekos/guide/opscalibration.ui ekos/guide/opsguide.ui ekos/guide/manualdither.ui ekos/observatory/observatory.ui #TODO remove from GIT #ekos/guide/guider.ui #ekos/guide/rcalibration.ui # Auxiliary ekos/auxiliary/filtersettings.ui ekos/auxiliary/opslogs.ui ekos/auxiliary/serialportassistant.ui # Ekos Live ekos/ekoslive/ekoslivedialog.ui # INDI Hub ekos/indihub.ui ) set(ekos_SRCS ekos/ekos.cpp ekos/manager.cpp ekos/profileeditor.cpp ekos/profilewizard.cpp ekos/qMDNS.cpp ekos/opsekos.cpp # Auxiliary ekos/auxiliary/dome.cpp ekos/auxiliary/weather.cpp ekos/auxiliary/dustcap.cpp ekos/auxiliary/darklibrary.cpp ekos/auxiliary/filtermanager.cpp ekos/auxiliary/filterdelegate.cpp ekos/auxiliary/opslogs.cpp ekos/auxiliary/serialportassistant.cpp # Capture ekos/capture/capture.cpp ekos/capture/sequencejob.cpp ekos/capture/dslrinfodialog.cpp ekos/capture/rotatorsettings.cpp ekos/capture/customproperties.cpp # Scheduler ekos/scheduler/schedulerjob.cpp ekos/scheduler/scheduler.cpp ekos/scheduler/mosaic.cpp # Focus ekos/focus/focus.cpp ekos/focus/focusalgorithms.cpp ekos/focus/polynomialfit.cpp # Mount ekos/mount/mount.cpp # Align ekos/align/align.cpp ekos/align/alignview.cpp ekos/align/astrometryparser.cpp ekos/align/opsastrometry.cpp ekos/align/opsalign.cpp ekos/align/opsastrometrycfg.cpp ekos/align/opsastrometryindexfiles.cpp ekos/align/opsastap.cpp ekos/align/offlineastrometryparser.cpp ekos/align/onlineastrometryparser.cpp ekos/align/remoteastrometryparser.cpp ekos/align/astapastrometryparser.cpp + ekos/align/polaralign.cpp # Guide ekos/guide/guide.cpp ekos/guide/guideinterface.cpp ekos/guide/opscalibration.cpp ekos/guide/opsguide.cpp # Internal Guide ekos/guide/internalguide/gmath.cpp ekos/guide/internalguide/internalguider.cpp #ekos/guide/internalguide/guider.cpp ekos/guide/internalguide/matr.cpp #ekos/guide/internalguide/rcalibration.cpp ekos/guide/internalguide/vect.cpp ekos/guide/internalguide/imageautoguiding.cpp ekos/guide/internalguide/guidelog.cpp # External Guide ekos/guide/externalguide/phd2.cpp ekos/guide/externalguide/linguider.cpp #Observatory ekos/observatory/observatory.cpp ekos/observatory/observatorymodel.cpp ekos/observatory/observatorydomemodel.cpp ekos/observatory/observatoryweathermodel.cpp # Ekos Live ekos/ekoslive/ekosliveclient.cpp ekos/ekoslive/message.cpp ekos/ekoslive/media.cpp ekos/ekoslive/cloud.cpp ) endif(CFITSIO_FOUND) include_directories(${INDI_INCLUDE_DIR}) endif (INDI_FOUND) if (CFITSIO_FOUND) set (sep_SRCS fitsviewer/sep/analyse.c fitsviewer/sep/aperture.c fitsviewer/sep/background.c fitsviewer/sep/convolve.c fitsviewer/sep/deblend.c fitsviewer/sep/extract.c fitsviewer/sep/lutz.c fitsviewer/sep/util.c ) set (hough_SRCS fitsviewer/hough/houghline.cpp ) set (fits_SRCS fitsviewer/fitslabel.cpp fitsviewer/fitsviewer.cpp fitsviewer/stretch.cpp fitsviewer/fitstab.cpp fitsviewer/fitsdebayer.cpp fitsviewer/opsfits.cpp ) if (Qt5DataVisualization_FOUND) set(fits_SRCS ${fits_SRCS} fitsviewer/starprofileviewer.cpp) endif() set (fits2_SRCS fitsviewer/bayer.c fitsviewer/fpack.c fitsviewer/fpackutil.c fitsviewer/fitshistogram.cpp fitsviewer/fitsview.cpp fitsviewer/fitsdata.cpp fitsviewer/fitsstardetector.cpp fitsviewer/fitsthresholddetector.cpp fitsviewer/fitsgradientdetector.cpp fitsviewer/fitscentroiddetector.cpp fitsviewer/fitssepdetector.cpp fitsviewer/fitsbahtinovdetector.cpp fitsviewer/fitsskyobject.cpp ) set (fitsui_SRCS fitsviewer/fitsheaderdialog.ui fitsviewer/statform.ui fitsviewer/fitsdebayer.ui indi/streamform.ui indi/recordingoptions.ui fitsviewer/fitshistogramui.ui fitsviewer/opsfits.ui ) include_directories(${CFITSIO_INCLUDE_DIR}) endif(CFITSIO_FOUND) IF (CFITSIO_FOUND) IF (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) IF (SANITIZERS) SET_SOURCE_FILES_PROPERTIES(fitsviewer/bayer.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align -fno-sanitize=address,undefined -fomit-frame-pointer") SET_SOURCE_FILES_PROPERTIES(fitsviewer/fitsdata.cpp PROPERTIES COMPILE_FLAGS "-fno-sanitize=address,undefined -fomit-frame-pointer") SET_SOURCE_FILES_PROPERTIES(fitsviewer/fitshistogram.cpp PROPERTIES COMPILE_FLAGS "-fno-sanitize=address,undefined -fomit-frame-pointer") SET_SOURCE_FILES_PROPERTIES(fitsviewer/fitsview.cpp PROPERTIES COMPILE_FLAGS "-fno-sanitize=address,undefined -fomit-frame-pointer") SET_SOURCE_FILES_PROPERTIES(fitsviewer/hough/houghline.cpp PROPERTIES COMPILE_FLAGS "-fno-sanitize=address,undefined -fomit-frame-pointer") ELSE () SET_SOURCE_FILES_PROPERTIES(fitsviewer/bayer.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align") ENDIF () SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/analyse.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/aperture.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align -Wno-pointer-arith") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/background.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/deblend.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align -Wno-incompatible-pointer-types-discards-qualifiers") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/extract.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/lutz.c PROPERTIES COMPILE_FLAGS "-Wno-cast-align") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/util.c PROPERTIES COMPILE_FLAGS "-Wno-incompatible-pointer-types-discards-qualifiers") SET_SOURCE_FILES_PROPERTIES(fitsviewer/fpack.c PROPERTIES COMPILE_FLAGS "-Wno-error") SET_SOURCE_FILES_PROPERTIES(fitsviewer/fpackutil.c PROPERTIES COMPILE_FLAGS "-Wno-error") ELSEIF (NOT WIN32) SET_SOURCE_FILES_PROPERTIES(fitsviewer/fpack.c PROPERTIES COMPILE_FLAGS "-Wno-error") SET_SOURCE_FILES_PROPERTIES(fitsviewer/fpackutil.c PROPERTIES COMPILE_FLAGS "-Wno-error") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/aperture.c PROPERTIES COMPILE_FLAGS "-Wno-pointer-arith") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/deblend.c PROPERTIES COMPILE_FLAGS "-Wno-discarded-qualifiers") SET_SOURCE_FILES_PROPERTIES(fitsviewer/sep/util.c PROPERTIES COMPILE_FLAGS "-Wno-discarded-qualifiers") ENDIF () ENDIF () if(WCSLIB_FOUND) include_directories( ${WCSLIB_INCLUDE_DIR} ) endif(WCSLIB_FOUND) set(xplanet_SRCS xplanet/opsxplanet.cpp ) set(xplanetui_SRCS xplanet/opsxplanet.ui ) ########### next target ############### set(libkstarstools_SRCS tools/altvstime.cpp tools/avtplotwidget.cpp tools/calendarwidget.cpp tools/conjunctions.cpp tools/eclipsetool.cpp tools/eclipsehandler.cpp tools/eclipsetool/lunareclipsehandler.cpp tools/jmoontool.cpp tools/approachsolver.cpp tools/ksconjunct.cpp tools/eqplotwidget.cpp tools/astrocalc.cpp tools/modcalcangdist.cpp tools/modcalcapcoord.cpp tools/modcalcaltaz.cpp tools/modcalcdaylength.cpp tools/modcalceclipticcoords.cpp tools/modcalcvizequinox.cpp tools/modcalcgalcoord.cpp tools/modcalcgeodcoord.cpp tools/modcalcjd.cpp tools/modcalcplanets.cpp tools/modcalcsidtime.cpp tools/modcalcvlsr.cpp tools/observinglist.cpp tools/obslistpopupmenu.cpp tools/sessionsortfilterproxymodel.cpp tools/obslistwizard.cpp tools/planetviewer.cpp tools/pvplotwidget.cpp tools/scriptargwidgets.cpp tools/scriptbuilder.cpp tools/scriptfunction.cpp tools/skycalendar.cpp tools/wutdialog.cpp tools/flagmanager.cpp tools/horizonmanager.cpp tools/nameresolver.cpp tools/polarishourangle.cpp #FIXME Port to KF5 #tools/moonphasetool.cpp tools/starhopper.cpp tools/eyepiecefield.cpp tools/exporteyepieceview.cpp tools/starhopperdialog.cpp tools/adddeepskyobject.cpp ) if(${KF5_VERSION} VERSION_EQUAL 5.18.0 OR ${KF5_VERSION} VERSION_GREATER 5.18.0) set(libkstarstools_SRCS ${libkstarstools_SRCS} tools/whatsinteresting/skyobjlistmodel.cpp tools/whatsinteresting/wiview.cpp tools/whatsinteresting/modelmanager.cpp tools/whatsinteresting/skyobjitem.cpp tools/whatsinteresting/wilpsettings.cpp tools/whatsinteresting/wiequipsettings.cpp tools/whatsinteresting/obsconditions.cpp tools/whatsinteresting/skyobjdescription.cpp ) endif() ki18n_wrap_ui(libkstarstools_ui_SRCS tools/altvstime.ui tools/argchangeviewoption.ui tools/argexportimage.ui tools/argloadcolorscheme.ui tools/arglooktoward.ui tools/argfindobject.ui tools/argprintimage.ui tools/argsetaltaz.ui tools/argsetcolor.ui tools/argsetgeolocation.ui tools/argsetlocaltime.ui tools/argsetradec.ui tools/argsettrack.ui tools/argtimescale.ui tools/argwaitfor.ui tools/argwaitforkey.ui tools/argzoom.ui tools/conjunctions.ui tools/eclipsetool.ui tools/modcalcangdist.ui tools/modcalcapcoord.ui tools/modcalcaltaz.ui tools/modcalcdaylength.ui tools/modcalceclipticcoords.ui tools/modcalcvizequinox.ui tools/modcalcgalcoord.ui tools/modcalcgeod.ui tools/modcalcjd.ui tools/modcalcplanets.ui tools/modcalcsidtime.ui tools/modcalcvlsr.ui tools/observinglist.ui tools/obslistwizard.ui tools/optionstreeview.ui tools/planetviewer.ui tools/scriptbuilder.ui tools/scriptnamedialog.ui tools/skycalendar.ui tools/wutdialog.ui tools/flagmanager.ui tools/starhopperdialog.ui tools/horizonmanager.ui tools/adddeepskyobject.ui tools/polarishourangle.ui ) if (${KF5_VERSION} VERSION_EQUAL 5.18.0 OR ${KF5_VERSION} VERSION_GREATER 5.18.0) ki18n_wrap_ui(libkstarstools_ui_SRCS tools/whatsinteresting/wilpsettings.ui tools/whatsinteresting/wiequipsettings.ui ) endif() set(libkstarswidgets_SRCS widgets/clicklabel.cpp widgets/dmsbox.cpp widgets/draglistbox.cpp widgets/fovwidget.cpp widgets/logedit.cpp widgets/magnitudespinbox.cpp widgets/mapcanvas.cpp widgets/thumbimage.cpp widgets/timespinbox.cpp widgets/timestepbox.cpp widgets/timeunitbox.cpp widgets/infoboxwidget.cpp # widgets/genericcalendarwidget.cpp # widgets/moonphasecalendarwidget.cpp widgets/kshelplabel.cpp widgets/unitspinboxwidget.cpp ) ki18n_wrap_ui(libkstarswidgets_ui_SRCS # widgets/genericcalendarwidget.ui widgets/unitspinboxwidget.ui ) set(kstars_KCFG_SRCS Options.kcfgc) set(kstars_options_SRCS options/opsadvanced.cpp options/opscatalog.cpp options/opscolors.cpp options/opsguides.cpp options/opssolarsystem.cpp options/opssatellites.cpp options/opssupernovae.cpp ) set(kstars_optionsui_SRCS options/opsadvanced.ui options/opscatalog.ui options/opscolors.ui options/opsguides.ui options/opssolarsystem.ui options/opssatellites.ui options/opssupernovae.ui ) set(kstars_dialogs_SRCS dialogs/addcatdialog.cpp dialogs/addlinkdialog.cpp dialogs/detaildialog.cpp dialogs/finddialog.cpp dialogs/focusdialog.cpp dialogs/fovdialog.cpp dialogs/locationdialog.cpp dialogs/timedialog.cpp dialogs/exportimagedialog.cpp ) set(kstars_dialogsui_SRCS dialogs/addcatdialog.ui dialogs/addlinkdialog.ui dialogs/details_database.ui dialogs/details_data.ui dialogs/details_data_comet.ui dialogs/details_links.ui dialogs/details_log.ui dialogs/details_position.ui dialogs/finddialog.ui dialogs/focusdialog.ui dialogs/fovdialog.ui dialogs/locationdialog.ui dialogs/wizwelcome.ui dialogs/wizlocation.ui dialogs/wizdownload.ui dialogs/wizdata.ui dialogs/newfov.ui dialogs/exportimagedialog.ui ) set(hips_SRCS hips/healpix.cpp hips/hipsrenderer.cpp hips/scanrender.cpp hips/pixcache.cpp hips/urlfiledownload.cpp hips/opships.cpp ) set(hips_manager_SRCS hips/hipsmanager.cpp ) set(oal_SRCS oal/log.cpp oal/observer.cpp oal/site.cpp oal/session.cpp oal/scope.cpp oal/eyepiece.cpp oal/filter.cpp oal/observation.cpp oal/lens.cpp oal/equipmentwriter.cpp oal/observeradd.cpp oal/execute.cpp ) set(printing_SRCS printing/detailstable.cpp printing/finderchart.cpp printing/foveditordialog.cpp printing/fovsnapshot.cpp printing/kstarsdocument.cpp printing/legend.cpp printing/loggingform.cpp printing/printingwizard.cpp printing/pwizchartconfig.cpp printing/pwizchartcontents.cpp printing/pwizfovbrowse.cpp printing/pwizfovconfig.cpp printing/pwizfovmanual.cpp printing/pwizfovsh.cpp printing/pwizfovtypeselection.cpp printing/pwizobjectselection.cpp printing/pwizprint.cpp printing/shfovexporter.cpp printing/simplefovexporter.cpp ) set(printingui_SRCS printing/foveditordialog.ui printing/pwizchartconfig.ui printing/pwizchartcontents.ui printing/pwizfovbrowse.ui printing/pwizfovconfig.ui printing/pwizfovmanual.ui printing/pwizfovsh.ui printing/pwizfovtypeselection.ui printing/pwizobjectselection.ui printing/pwizprint.ui printing/pwizwelcome.ui ) set( kstars_KCFG_SRCS Options.kcfgc ) set(libkstarscomponents_SRCS skycomponents/skylabeler.cpp skycomponents/highpmstarlist.cpp skycomponents/skymapcomposite.cpp skycomponents/skymesh.cpp skycomponents/linelistindex.cpp skycomponents/linelistlabel.cpp skycomponents/noprecessindex.cpp skycomponents/listcomponent.cpp skycomponents/pointlistcomponent.cpp skycomponents/solarsystemsinglecomponent.cpp skycomponents/solarsystemlistcomponent.cpp skycomponents/earthshadowcomponent.cpp skycomponents/asteroidscomponent.cpp skycomponents/cometscomponent.cpp skycomponents/planetmoonscomponent.cpp skycomponents/solarsystemcomposite.cpp skycomponents/satellitescomponent.cpp skycomponents/starcomponent.cpp skycomponents/deepstarcomponent.cpp skycomponents/deepskycomponent.cpp skycomponents/catalogcomponent.cpp skycomponents/syncedcatalogcomponent.cpp skycomponents/constellationartcomponent.cpp skycomponents/constellationboundarylines.cpp skycomponents/constellationlines.cpp skycomponents/constellationnamescomponent.cpp skycomponents/supernovaecomponent.cpp skycomponents/coordinategrid.cpp skycomponents/equatorialcoordinategrid.cpp skycomponents/horizontalcoordinategrid.cpp skycomponents/localmeridiancomponent.cpp skycomponents/ecliptic.cpp skycomponents/equator.cpp skycomponents/artificialhorizoncomponent.cpp skycomponents/hipscomponent.cpp skycomponents/horizoncomponent.cpp skycomponents/milkyway.cpp skycomponents/skycomponent.cpp skycomponents/skycomposite.cpp skycomponents/starblock.cpp skycomponents/starblocklist.cpp skycomponents/starblockfactory.cpp skycomponents/culturelist.cpp skycomponents/flagcomponent.cpp skycomponents/targetlistcomponent.cpp ) #LIST(APPEND libkstarscomponents_SRCS # #skycomponents/notifyupdatesui.cpp # ) IF (BUILD_KSTARS_LITE) set(libkstarstools_ui_klite_SRCS tools/nameresolver.cpp ) ENDIF () set(kstars_skyobjects_SRCS skyobjects/constellationsart.cpp skyobjects/deepskyobject.cpp skyobjects/jupitermoons.cpp skyobjects/planetmoons.cpp skyobjects/ksasteroid.cpp skyobjects/kscomet.cpp skyobjects/ksmoon.cpp skyobjects/ksearthshadow.cpp skyobjects/ksplanetbase.cpp skyobjects/ksplanet.cpp #skyobjects/kspluto.cpp skyobjects/kssun.cpp skyobjects/skyline.cpp skyobjects/skyobject.cpp skyobjects/skypoint.cpp skyobjects/starobject.cpp skyobjects/trailobject.cpp skyobjects/satellite.cpp skyobjects/satellitegroup.cpp skyobjects/supernova.cpp ) set(kstars_projection_SRCS projections/projector.cpp projections/lambertprojector.cpp projections/gnomonicprojector.cpp projections/stereographicprojector.cpp projections/orthographicprojector.cpp projections/azimuthalequidistantprojector.cpp projections/equirectangularprojector.cpp ) set(kstars_extra_SRCS auxiliary/colorscheme.cpp auxiliary/dms.cpp auxiliary/cachingdms.cpp auxiliary/geolocation.cpp auxiliary/ksfilereader.cpp auxiliary/ksuserdb.cpp auxiliary/binfilehelper.cpp auxiliary/ksutils.cpp auxiliary/ksdssimage.cpp auxiliary/ksdssdownloader.cpp auxiliary/nonlineardoublespinbox.cpp auxiliary/profileinfo.cpp auxiliary/filedownloader.cpp auxiliary/kspaths.cpp auxiliary/QRoundProgressBar.cpp auxiliary/skyobjectlistmodel.cpp auxiliary/ksnotification.cpp auxiliary/ksmessagebox.cpp auxiliary/QProgressIndicator.cpp auxiliary/ctkrangeslider.cpp time/simclock.cpp time/kstarsdatetime.cpp time/timezonerule.cpp ksnumbers.cpp kstarsdata.cpp texturemanager.cpp #to minimize number of indef KSTARS_LITE skypainter.cpp ) SET(kstars_extra_kstars_SRCS auxiliary/thememanager.cpp auxiliary/schememanager.cpp auxiliary/imageviewer.cpp auxiliary/xplanetimageviewer.cpp auxiliary/fov.cpp auxiliary/thumbnailpicker.cpp auxiliary/thumbnaileditor.cpp auxiliary/imageexporter.cpp auxiliary/kswizard.cpp auxiliary/qcustomplot.cpp kstarsdbus.cpp kspopupmenu.cpp ksalmanac.cpp kstarsactions.cpp kstarsinit.cpp kstars.cpp kstarssplash.cpp skymap.cpp skymapdrawabstract.cpp skymapqdraw.cpp skymapevents.cpp skyqpainter.cpp ) # Temporary solution to allow use of qml files from source dir DELETE SET(KSTARSLITE_CPP_OPTIONS -DSOURCE_DIR=\"${kstars_SOURCE_DIR}\" -DQML_IMPORT="${CMAKE_CURRENT_SOURCE_DIR}") set(klite_SRCS kstarslite.cpp kstarsliteinit.cpp skymaplite.cpp skymapliteevents.cpp #Wrappers kstarslite/skypointlite.cpp kstarslite/skyobjectlite.cpp #ImageProvider kstarslite/imageprovider.cpp #Dialogs kstarslite/dialogs/detaildialoglite.cpp kstarslite/dialogs/finddialoglite.cpp kstarslite/dialogs/locationdialoglite.cpp #RootNode kstarslite/skyitems/rootnode.cpp kstarslite/skyitems/skyopacitynode.cpp kstarslite/skyitems/typedeflite.h #SkyItems kstarslite/skyitems/skyitem.cpp kstarslite/skyitems/planetsitem.cpp kstarslite/skyitems/asteroidsitem.cpp kstarslite/skyitems/cometsitem.cpp kstarslite/skyitems/horizonitem.cpp kstarslite/skyitems/labelsitem.cpp kstarslite/skyitems/constellationnamesitem.cpp kstarslite/skyitems/staritem.cpp kstarslite/skyitems/deepstaritem.cpp kstarslite/skyitems/deepskyitem.cpp kstarslite/skyitems/constellationartitem.cpp kstarslite/skyitems/satellitesitem.cpp kstarslite/skyitems/supernovaeitem.cpp kstarslite/skyitems/fovitem.cpp kstarslite/skyitems/syncedcatalogitem.cpp #Line kstarslite/skyitems/lines/linesitem.cpp kstarslite/skyitems/lines/equatoritem.cpp kstarslite/skyitems/lines/eclipticitem.cpp kstarslite/skyitems/lines/milkywayitem.cpp #SkyNodes kstarslite/skyitems/skynodes/planetnode.cpp kstarslite/skyitems/skynodes/skynode.cpp kstarslite/skyitems/skynodes/pointsourcenode.cpp kstarslite/skyitems/skynodes/planetmoonsnode.cpp kstarslite/skyitems/skynodes/horizonnode.cpp kstarslite/skyitems/skynodes/labelnode.cpp kstarslite/skyitems/skynodes/guidelabelnode.cpp kstarslite/skyitems/skynodes/deepskynode.cpp kstarslite/skyitems/skynodes/dsosymbolnode.cpp kstarslite/skyitems/skynodes/skypolygonnode.cpp kstarslite/skyitems/skynodes/constellationartnode.cpp kstarslite/skyitems/skynodes/satellitenode.cpp kstarslite/skyitems/skynodes/supernovanode.cpp kstarslite/skyitems/skynodes/trixelnode.cpp kstarslite/skyitems/skynodes/fovsymbolnode.cpp #Nodes kstarslite/skyitems/skynodes/nodes/pointnode.cpp kstarslite/skyitems/skynodes/nodes/polynode.cpp kstarslite/skyitems/skynodes/nodes/linenode.cpp kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp kstarslite/skyitems/skynodes/nodes/rectnode.cpp #Other kstarslite/deviceorientation.cpp ) set(kstarslite_libtess_SRC #libtess libtess/gluos.h libtess/priorityq-sort.h libtess/sweep.c libtess/tessmono.c libtess/dict-list.h libtess/glu.h libtess/tessellate.c libtess/dict.c libtess/geom.c libtess/memalloc.c libtess/mesh.c libtess/normal.c libtess/priorityq.c libtess/priorityq-heap.c libtess/render.c libtess/tess.c ) IF (BUILD_KSTARS_LITE) ADD_CUSTOM_TARGET(convert_translations ${CMAKE_SOURCE_DIR}/tools/convert_translations.sh ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ADD_DEPENDENCIES(convert_translations fetch-translations) IF (ANDROID) ADD_CUSTOM_TARGET(convert_translations_to_android ${CMAKE_SOURCE_DIR}/tools/convert_translations.sh ${CMAKE_BINARY_DIR}/packaging/android/export/share/kstars WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) ADD_DEPENDENCIES(convert_translations_to_android fetch-translations) ENDIF () ENDIF () IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") SET_SOURCE_FILES_PROPERTIES(${kstarslite_libtess_SRC} PROPERTIES COMPILE_FLAGS "-Wno-error") ENDIF () #Qml files will be probably moved to user's data dir, but for use #with QtCreator it is more convenient to have them here set(kstarsliteqml_SRCS kstarslite/qml/main.qml kstarslite/qml/constants/Constants.qml kstarslite/qml/modules/SkyMapLiteWrapper.qml kstarslite/qml/modules/BottomMenu.qml kstarslite/qml/modules/KSPage.qml kstarslite/qml/modules/KSListView.qml kstarslite/qml/modules/KSLabel.qml kstarslite/qml/modules/KSText.qml kstarslite/qml/modules/KSTabButton.qml kstarslite/qml/modules/KSTab.qml kstarslite/qml/modules/KSTabBarArrow.qml kstarslite/qml/modules/KSTextField.qml kstarslite/qml/modules/KSButton.qml kstarslite/qml/modules/TopMenu.qml kstarslite/qml/modules/helpers/TopMenuButton.qml kstarslite/qml/modules/helpers/BottomMenuButton.qml kstarslite/qml/modules/Splash.qml kstarslite/qml/modules/helpers/TimeSpinBox.qml kstarslite/qml/modules/TimePage.qml #Popups kstarslite/qml/modules/popups/ProjectionsPopup.qml kstarslite/qml/modules/popups/FOVPopup.qml kstarslite/qml/modules/popups/ColorSchemePopup.qml #Menus kstarslite/qml/modules/menus/ContextMenu.qml #Helpers kstarslite/qml/modules/helpers/PassiveNotification.qml kstarslite/qml/modules/helpers/KSMenuItem.qml kstarslite/qml/modules/helpers/TelescopeControl.qml #Dialogs kstarslite/qml/dialogs/FindDialog.qml kstarslite/qml/dialogs/LocationDialog.qml kstarslite/qml/dialogs/DetailsDialog.qml kstarslite/qml/dialogs/AboutDialog.qml kstarslite/qml/dialogs/helpers/DetailsItem.qml kstarslite/qml/dialogs/helpers/DetailsAddLink.qml kstarslite/qml/dialogs/helpers/LocationEdit.qml kstarslite/qml/dialogs/helpers/LocationLoading.qml kstarslite/qml/dialogs/menus/DetailsLinkMenu.qml kstarslite/qml/dialogs/menus/LocationsGeoMenu.qml #INDI kstarslite/qml/indi/INDIControlPanel.qml kstarslite/qml/indi/DevicePanel.qml kstarslite/qml/indi/ImagePreview.qml kstarslite/qml/indi/modules/MotionControl.qml kstarslite/qml/indi/modules/Led.qml kstarslite/qml/indi/modules/KSLed.qml kstarslite/qml/indi/modules/Property.qml kstarslite/qml/indi/modules/KSComboBox.qml kstarslite/qml/indi/modules/KSButtonSwitch.qml kstarslite/qml/indi/modules/KSCheckBox.qml kstarslite/qml/indi/modules/KSINDIText.qml kstarslite/qml/indi/modules/KSINDITextField.qml kstarslite/qml/indi/modules/KSButtonsSwitchRow.qml #Tutorial kstarslite/qml/modules/tutorial/TutorialPopup.qml kstarslite/qml/modules/tutorial/TutorialExitPopup.qml kstarslite/qml/modules/tutorial/TutorialStep1.qml kstarslite/qml/modules/tutorial/TutorialStep2.qml kstarslite/qml/modules/tutorial/TutorialStep3.qml kstarslite/qml/modules/tutorial/TutorialStep4.qml kstarslite/qml/modules/tutorial/TutorialStep5.qml kstarslite/qml/modules/tutorial/TutorialPane.qml ) add_subdirectory(kstarslite/qml) ADD_CUSTOM_TARGET(kstarsliteqml SOURCES ${kstarsliteqml_SRCS}) if(ANDROID) add_subdirectory(kstarslite/res) endif(ANDROID) set(kstars_SRCS ${indi_SRCS} ${fits_SRCS} ${ekos_SRCS} ${libkstarswidgets_SRCS} ${libkstarscomponents_SRCS} ${libkstarstools_SRCS} ${kstars_extra_SRCS} ${kstars_extra_kstars_SRCS} ${kstars_projection_SRCS} ${xplanet_SRCS} ${kstars_options_SRCS} ${kstars_skyobjects_SRCS} ${kstars_dialogs_SRCS} ${hips_SRCS} ${oal_SRCS} ${printing_SRCS} #KStars Lite ${kstarslite_SRCS} # Generated files ${libkstarstools_ui_SRCS} ${libkstarswidgets_ui_SRCS} ) set(kstarslite_SRCS ${indi_klite_SRCS} ${libkstarscomponents_SRCS} ${kstars_extra_SRCS} ${kstars_projection_SRCS} ${kstars_skyobjects_SRCS} # KStars Lite sources ${klite_SRCS} # Generated files ${libkstarstools_ui_klite_SRCS} ) # Generate all the necessary QLoggingCategory files ecm_qt_declare_logging_category(kstars_SRCS HEADER kstars_debug.h IDENTIFIER KSTARS CATEGORY_NAME org.kde.kstars) ecm_qt_declare_logging_category(kstars_SRCS HEADER indi_debug.h IDENTIFIER KSTARS_INDI CATEGORY_NAME org.kde.kstars.indi) ecm_qt_declare_logging_category(kstars_SRCS HEADER fits_debug.h IDENTIFIER KSTARS_FITS CATEGORY_NAME org.kde.kstars.fits) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_debug.h IDENTIFIER KSTARS_EKOS CATEGORY_NAME org.kde.kstars.ekos) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_capture_debug.h IDENTIFIER KSTARS_EKOS_CAPTURE CATEGORY_NAME org.kde.kstars.ekos.capture) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_focus_debug.h IDENTIFIER KSTARS_EKOS_FOCUS CATEGORY_NAME org.kde.kstars.ekos.focus) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_align_debug.h IDENTIFIER KSTARS_EKOS_ALIGN CATEGORY_NAME org.kde.kstars.ekos.align) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_guide_debug.h IDENTIFIER KSTARS_EKOS_GUIDE CATEGORY_NAME org.kde.kstars.ekos.guide) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_mount_debug.h IDENTIFIER KSTARS_EKOS_MOUNT CATEGORY_NAME org.kde.kstars.ekos.mount) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_scheduler_debug.h IDENTIFIER KSTARS_EKOS_SCHEDULER CATEGORY_NAME org.kde.kstars.ekos.scheduler) ecm_qt_declare_logging_category(kstars_SRCS HEADER ekos_observatory_debug.h IDENTIFIER KSTARS_EKOS_OBSERVATORY CATEGORY_NAME org.kde.kstars.ekos.observatory) kconfig_add_kcfg_files(kstars_SRCS ${kstars_KCFG_SRCS}) ecm_qt_declare_logging_category(kstarslite_SRCS HEADER kstars_debug.h IDENTIFIER KSTARS CATEGORY_NAME org.kde.kstars) ecm_qt_declare_logging_category(kstarslite_SRCS HEADER fits_debug.h IDENTIFIER KSTARS_FITS CATEGORY_NAME org.kde.kstars.fits) kconfig_add_kcfg_files(kstarslite_SRCS ${kstars_KCFG_SRCS}) IF (UNITY_BUILD) ENABLE_UNITY_BUILD(kstars kstars_SRCS 10 cpp) ENABLE_UNITY_BUILD(kstarslite kstarslite_SRCS 10 cpp) ENDIF () set(kstars_SRCS ${kstars_SRCS} ${fits2_SRCS} ${sep_SRCS} ${hough_SRCS} ${hips_manager_SRCS}) set(kstarslite_SRCS ${kstarslite_SRCS} ${fits_klite_SRCS} ${sep_SRCS} ${hough_SRCS} ${fits2_klite_SRCS} ${kstarslite_libtess_SRC}) IF (NOT ANDROID) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.xml kstars.h KStars) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.SimClock.xml simclock.h SimClock) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.FOV.xml fov.h FOV) IF (INDI_FOUND) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.INDI.xml indi/indidbus.h INDIDBus) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.xml ekos/manager.h Ekos::Manager) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Capture.xml ekos/capture/capture.h Ekos::Capture) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Focus.xml ekos/focus/focus.h Ekos::Focus) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Guide.xml ekos/guide/guide.h Ekos::Guide) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Align.xml ekos/align/align.h Ekos::Align) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Mount.xml ekos/mount/mount.h Ekos::Mount) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Dome.xml ekos/auxiliary/dome.h Ekos::Dome) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Weather.xml ekos/auxiliary/weather.h Ekos::Weather) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.DustCap.xml ekos/auxiliary/dustcap.h Ekos::DustCap) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Scheduler.xml ekos/scheduler/scheduler.h Ekos::Scheduler) qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.Ekos.Observatory.xml ekos/observatory/observatory.h Ekos::Observatory) ENDIF () ki18n_wrap_ui(kstars_SRCS ${indiui_SRCS} ${ui_SRCS} ${fitsui_SRCS} ${ekosui_SRCS} ${xplanetui_SRCS} ${kstars_optionsui_SRCS} ${kstars_dialogsui_SRCS} ${printingui_SRCS} auxiliary/thumbnailpicker.ui auxiliary/thumbnaileditor.ui oal/observeradd.ui oal/equipmentwriter.ui oal/execute.ui hips/opships.ui hips/opshipsdisplay.ui hips/opshipscache.ui #skycomponents/notifyupdatesui.ui ) add_library(KStarsLib STATIC ${kstars_SRCS}) include(GenerateExportHeader) generate_export_header(KStarsLib) target_link_libraries(KStarsLib LibKSDataHandlers htmesh KF5::Crash KF5::I18n KF5::NewStuff KF5::KIOFileWidgets KF5::WidgetsAddons KF5::Plotting KF5::Notifications Qt5::Gui Qt5::PrintSupport Qt5::Sql Qt5::Svg Qt5::Qml Qt5::Quick Qt5::Network #Qt5::Positioning Qt5::Concurrent Qt5::WebSockets ${ZLIB_LIBRARIES} ) if (Qt5Keychain_FOUND) target_include_directories(KStarsLib PUBLIC ${QTKEYCHAIN_INCLUDE_DIRS}) target_link_libraries(KStarsLib ${QTKEYCHAIN_LIBRARIES}) endif(Qt5Keychain_FOUND) if (Qt5DataVisualization_FOUND) target_link_libraries(KStarsLib Qt5::DataVisualization) endif(Qt5DataVisualization_FOUND) if (KF5NotifyConfig_FOUND) target_link_libraries(KStarsLib KF5::NotifyConfig) endif(KF5NotifyConfig_FOUND) if(NOT WIN32) target_link_libraries(KStarsLib m) endif(NOT WIN32) ENDIF () if (BUILD_KSTARS_LITE) add_library(KStarsLiteLib STATIC ${kstarslite_SRCS}) target_link_libraries(KStarsLiteLib LibKSDataHandlers htmesh KF5::I18n KF5::Plotting KF5::ConfigGui Qt5::Gui Qt5::Sql Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::Positioning Qt5::PositioningQuick Qt5::Concurrent ${ZLIB_LIBRARIES} ) if (ANDROID) target_link_libraries(KStarsLiteLib Qt5::AndroidExtras) endif () endif () if (CFITSIO_FOUND) if (NOT ANDROID) target_include_directories(KStarsLib PUBLIC ${CFITSIO_INCLUDE_DIR}) target_link_libraries(KStarsLib ${CFITSIO_LIBRARIES}) endif() if (BUILD_KSTARS_LITE) target_include_directories(KStarsLiteLib PUBLIC ${CFITSIO_INCLUDE_DIR}) target_link_libraries(KStarsLiteLib ${CFITSIO_LIBRARIES}) endif() endif(CFITSIO_FOUND) if(INDI_FOUND) if (NOT ANDROID) find_package(Nova REQUIRED) include_directories(${NOVA_INCLUDE_DIR}) endif () ## Support Multiple Platforms. All Require INDI ## WIN32 Desktop: Requires INDI Qt5 Client + GSL ## WIN32 Lite: Requires INDI Qt5 Client ## Linux + MacOS Desktop: Requires INDI Client + GSL ## Linux + MacOS Lite: Requires INDI Qt5 Client ## Android: Requires INDI Qt5 Client built for Android if (NOT ANDROID) find_package(GSL REQUIRED) include_directories(${GSL_INCLUDE_DIRS}) target_link_libraries(KStarsLib ${GSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} KF5::Notifications) endif () if(WIN32 OR ANDROID) if(ANDROID) target_link_libraries(KStarsLiteLib ${INDI_CLIENT_ANDROID_LIBRARIES} ${CFITSIO_LIBRARIES} ${LIBRAW_LIBRARIES}) target_compile_options(KStarsLiteLib PRIVATE ${KSTARSLITE_CPP_OPTIONS} -DUSE_QT5_INDI -DKSTARS_LITE) else(ANDROID) target_link_libraries(KStarsLib ${INDI_CLIENT_LIBRARIES} ${NOVA_LIBRARIES}) endif(ANDROID) else(WIN32 OR ANDROID) if (BUILD_KSTARS_LITE) target_link_libraries(KStarsLiteLib ${INDI_CLIENT_QT_LIBRARIES} ${NOVA_LIBRARIES} z) target_compile_options(KStarsLiteLib PRIVATE ${KSTARSLITE_CPP_OPTIONS} -DUSE_QT5_INDI -DKSTARS_LITE) endif(BUILD_KSTARS_LITE) target_link_libraries(KStarsLib ${INDI_CLIENT_LIBRARIES} ${NOVA_LIBRARIES} z) endif(WIN32 OR ANDROID) endif(INDI_FOUND) if(WCSLIB_FOUND) target_link_libraries(KStarsLib ${WCSLIB_LIBRARIES}) if (BUILD_KSTARS_LITE) target_link_libraries(KStarsLiteLib ${WCSLIB_LIBRARIES}) endif() endif (WCSLIB_FOUND) if(LibRaw_FOUND) if (NOT ANDROID) target_link_libraries(KStarsLib ${LibRaw_LIBRARIES}) endif() if (BUILD_KSTARS_LITE) target_link_libraries(KStarsLiteLib ${LibRaw_LIBRARIES}) endif() endif (LibRaw_FOUND) # Link libnova if found if (NOVA_FOUND) target_link_libraries(KStarsLib ${NOVA_LIBRARIES}) endif() #FIXME Enable OpenGL Later #if( OPENGL_FOUND ) # target_link_libraries(KStarsLib # ${OPENGL_LIBRARIES} # ${QT_QTOPENGL_LIBRARY} # ) #endif( OPENGL_FOUND ) set (KSTARS_APP_SRCS main.cpp ) # add icon to application sources ecm_add_app_icon(KSTARS_APP_SRCS ICONS ${CMAKE_CURRENT_SOURCE_DIR}/icons/16-apps-kstars.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/32-apps-kstars.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/48-apps-kstars.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/64-apps-kstars.png ${CMAKE_CURRENT_SOURCE_DIR}/icons/128-apps-kstars.png ) qt5_add_resources(KSTARS_APP_SRCS data/kstars.qrc) if (ANDROID) add_library(kstars SHARED ${KSTARS_APP_SRCS}) target_compile_options(kstars PRIVATE ${KSTARSLITE_CPP_OPTIONS} -DUSE_QT5_INDI -DKSTARS_LITE) add_dependencies(KStarsLiteLib cfitsio indi raw) target_link_libraries(kstars KStarsLiteLib) else () if (BUILD_KSTARS_LITE) add_executable(kstars_lite ${KSTARS_APP_SRCS}) target_compile_options(kstars_lite PRIVATE ${KSTARSLITE_CPP_OPTIONS} -DUSE_QT5_INDI -DKSTARS_LITE) target_link_libraries(kstars_lite KStarsLiteLib) endif() add_executable(kstars ${KSTARS_APP_SRCS}) target_link_libraries(kstars KStarsLib) endif () install(TARGETS kstars ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) ########### install files ############### install(PROGRAMS org.kde.kstars.desktop DESTINATION ${KDE_INSTALL_APPDIR}) install(FILES kstars.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) install(FILES kstars.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR}) if(INDI_FOUND) #install(FILES ekos/mount/mountbox.qml DESTINATION ${KDE_INSTALL_DATADIR}/kstars/ekos/mount/qml) #install(DIRECTORY ekos/mount/ DESTINATION ${KDE_INSTALL_DATADIR}/kstars/ekos/mount/qml # FILES_MATCHING PATTERN "*.png") endif() if (NOT ANDROID AND BUILD_KSTARS_LITE) install(TARGETS kstars_lite ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) endif() diff --git a/kstars/auxiliary/dms.h b/kstars/auxiliary/dms.h index dd2b2b929..7587b3d1b 100644 --- a/kstars/auxiliary/dms.h +++ b/kstars/auxiliary/dms.h @@ -1,495 +1,501 @@ /*************************************************************************** dms.h - K Desktop Planetarium ------------------- begin : Sun Feb 11 2001 copyright : (C) 2001 by Jason Harris email : jharris@30doradus.org ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #pragma once #include "../nan.h" #include #include #include //#define COUNT_DMS_SINCOS_CALLS true //#define PROFILE_SINCOS true #ifdef PROFILE_SINCOS #include #endif /** @class dms * @short An angle, stored as degrees, but expressible in many ways. * @author Jason Harris * @version 1.0 * * dms encapsulates an angle. The angle is stored as a double, * equal to the value of the angle in degrees. Methods are available * for setting/getting the angle as a floating-point measured in * Degrees or Hours, or as integer triplets (degrees, arcminutes, * arcseconds or hours, minutes, seconds). There is also a method * to set the angle according to a radian value, and to return the * angle expressed in radians. Finally, a SinCos() method computes * the sin and cosine of the angle. */ class dms { public: /** Default constructor. */ dms() : D(NaN::d) #ifdef COUNT_DMS_SINCOS_CALLS , m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** Empty virtual destructor */ virtual ~dms() = default; /** @short Set the floating-point value of the angle according to the four integer arguments. * @param d degree portion of angle (int). Defaults to zero. * @param m arcminute portion of angle (int). Defaults to zero. * @param s arcsecond portion of angle (int). Defaults to zero. * @param ms arcsecond portion of angle (int). Defaults to zero. */ explicit dms(const int &d, const int &m = 0, const int &s = 0, const int &ms = 0) #ifdef COUNT_DMS_SINCOS_CALLS : m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { dms::setD(d, m, s, ms); #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** @short Construct an angle from a double value. * * Creates an angle whose value in Degrees is equal to the argument. * @param x angle expressed as a floating-point number (in degrees) */ explicit dms(const double &x) : D(x) #ifdef COUNT_DMS_SINCOS_CALLS , m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** @short Construct an angle from a string representation. * * Attempt to create the angle according to the string argument. If the string * cannot be parsed as an angle value, the angle is set to zero. * * @warning There is not an unambiguous notification that it failed to parse the string, * since the string could have been a valid representation of zero degrees. * If this is a concern, use the setFromString() function directly instead. * * @param s the string to parse as a dms value. * @param isDeg if true, value is in degrees; if false, value is in hours. * @sa setFromString() */ explicit dms(const QString &s, bool isDeg = true) #ifdef COUNT_DMS_SINCOS_CALLS : m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { setFromString(s, isDeg); #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** @return integer degrees portion of the angle */ inline int degree() const { if (std::isnan(D)) return 0; return int(D); } /** @return integer arcminutes portion of the angle. * @note an arcminute is 1/60 degree. */ int arcmin() const; /** @return integer arcseconds portion of the angle * @note an arcsecond is 1/60 arcmin, or 1/3600 degree. */ int arcsec() const; /** @return integer milliarcseconds portion of the angle * @note a milliarcsecond is 1/1000 arcsecond. */ int marcsec() const; /** @return angle in degrees expressed as a double. */ inline const double &Degrees() const { return D; } /** @return integer hours portion of the angle * @note an angle can be measured in degrees/arcminutes/arcseconds * or hours/minutes/seconds. An hour is equal to 15 degrees. */ inline int hour() const { return int(reduce().Degrees() / 15.0); } /** @return integer minutes portion of the angle * @note a minute is 1/60 hour (not the same as an arcminute) */ int minute() const; /** @return integer seconds portion of the angle * @note a second is 1/3600 hour (not the same as an arcsecond) */ int second() const; /** @return integer milliseconds portion of the angle * @note a millisecond is 1/1000 second (not the same as a milliarcsecond) */ int msecond() const; - /** @return angle in hours expressed as a double. + /** @return angle in hours expressed as a double in the range 0 to 23.999... * @note an angle can be measured in degrees/arcminutes/arcseconds * or hours/minutes/seconds. An hour is equal to 15 degrees. */ inline double Hours() const { return reduce().Degrees() / 15.0; } + /** @return angle in hours expressed as a double in the range -11.999 to 0 to 12.0 + * @note an angle can be measured in degrees/arcminutes/arcseconds + * or hours/minutes/seconds. An hour is equal to 15 degrees. + */ + inline double HoursHa() const { return Hours() <= 12.0 ? Hours() : Hours() - 24.0; } + /** Sets floating-point value of angle, in degrees. * @param x new angle (double) */ inline virtual void setD(const double &x) { #ifdef COUNT_DMS_SINCOS_CALLS m_sinDirty = m_cosDirty = true; #endif D = x; } /** @short Sets floating-point value of angle, in degrees. * * This is an overloaded member function; it behaves essentially * like the above function. The floating-point value of the angle * (D) is determined from the following formulae: * * \f$ fabs(D) = fabs(d) + \frac{(m + (s/60))}{60} \f$ * \f$ sgn(D) = sgn(d) \f$ * * @param d integer degrees portion of angle * @param m integer arcminutes portion of angle * @param s integer arcseconds portion of angle * @param ms integer arcseconds portion of angle */ virtual void setD(const int &d, const int &m, const int &s, const int &ms = 0); /** @short Sets floating-point value of angle, in hours. * * Converts argument from hours to degrees, then * sets floating-point value of angle, in degrees. * @param x new angle, in hours (double) * @sa setD() */ inline virtual void setH(const double &x) { dms::setD(x * 15.0); #ifdef COUNT_DMS_SINCOS_CALLS m_cosDirty = m_sinDirty = true; #endif } /** @short Sets floating-point value of angle, in hours. * * Converts argument values from hours to degrees, then * sets floating-point value of angle, in degrees. * This is an overloaded member function, provided for convenience. It * behaves essentially like the above function. * @param h integer hours portion of angle * @param m integer minutes portion of angle * @param s integer seconds portion of angle * @param ms integer milliseconds portion of angle * @sa setD() */ virtual void setH(const int &h, const int &m, const int &s, const int &ms = 0); /** @short Attempt to parse the string argument as a dms value, and set the dms object * accordingly. * @param s the string to be parsed as a dms value. The string can be an int or * floating-point value, or a triplet of values (d/h, m, s) separated by spaces or colons. * @param isDeg if true, the value is in degrees. Otherwise, it is in hours. * @return true if sting was parsed successfully. Otherwise, set the dms value * to 0.0 and return false. */ virtual bool setFromString(const QString &s, bool isDeg = true); /** @short Compute Sine and Cosine of the angle simultaneously. * On machines using glibc >= 2.1, calling SinCos() is somewhat faster * than calling sin() and cos() separately. * The values are returned through the arguments (passed by reference). * * @param s Sine of the angle * @param c Cosine of the angle * @sa sin() cos() */ inline void SinCos(double &s, double &c) const; /** @short Compute the Angle's Sine. * * @return the Sine of the angle. * @sa cos() */ double sin() const { #ifdef COUNT_DMS_SINCOS_CALLS if (!m_sinCosCalled) { m_sinCosCalled = true; ++dms_with_sincos_called; } if (m_sinDirty) m_sinDirty = false; else ++redundant_trig_function_calls; ++trig_function_calls; #endif #ifdef PROFILE_SINCOS std::clock_t start, stop; double s; start = std::clock(); s = ::sin(D * DegToRad); stop = std::clock(); seconds_in_trig += double(stop - start) / double(CLOCKS_PER_SEC); return s; #else return ::sin(D * DegToRad); #endif } /** @short Compute the Angle's Cosine. * * @return the Cosine of the angle. * @sa sin() */ double cos() const { #ifdef COUNT_DMS_SINCOS_CALLS if (!m_sinCosCalled) { m_sinCosCalled = true; ++dms_with_sincos_called; } if (m_cosDirty) m_cosDirty = false; else ++redundant_trig_function_calls; ++trig_function_calls; #endif #ifdef PROFILE_SINCOS std::clock_t start, stop; double c; start = std::clock(); c = ::cos(D * DegToRad); stop = std::clock(); seconds_in_trig += double(stop - start) / double(CLOCKS_PER_SEC); return c; #else return ::cos(D * DegToRad); #endif } /** @short Express the angle in radians. * @return the angle in radians (double) */ inline double radians() const { return D * DegToRad; } /** @short Set angle according to the argument, in radians. * * This function converts the argument to degrees, then sets the angle * with setD(). * @param Rad an angle in radians */ inline virtual void setRadians(const double &Rad) { dms::setD(Rad / DegToRad); #ifdef COUNT_DMS_SINCOS_CALLS m_cosDirty = m_sinDirty = true; #endif } /** return the equivalent angle between 0 and 360 degrees. * @warning does not change the value of the parent angle itself. */ const dms reduce() const; /** * @brief deltaAngle Return the shortest difference (path) between this angle and the supplied angle. The range is normalized to [-180,+180] * @param angle Angle to subtract from current angle. * @return Normalized angle in the range [-180,+180] */ const dms deltaAngle(dms angle) const; /** * @short an enum defining standard angle ranges */ enum AngleRanges { ZERO_TO_2PI, MINUSPI_TO_PI }; /** * @short Reduce _this_ angle to the given range */ void reduceToRange(enum dms::AngleRanges range); /** @return a nicely-formatted string representation of the angle * in degrees, arcminutes, and arcseconds. * @param forceSign if @c true then adds '+' or '-' to the string * @param machineReadable uses a colon separator and produces +/-dd:mm:ss format instead * @param highPrecision adds milliseconds, if @c false the seconds will be shown as an integer */ const QString toDMSString(const bool forceSign = false, const bool machineReadable = false, const bool highPrecision=false) const; /** @return a nicely-formatted string representation of the angle * in hours, minutes, and seconds. * @param machineReadable uses a colon separator and produces hh:mm:ss format instead * @param highPrecision adds milliseconds, if @c false the seconds will be shown as an integer */ const QString toHMSString(const bool machineReadable = false, const bool highPrecision=false) const; /** PI is a const static member; it's public so that it can be used anywhere, * as long as dms.h is included. */ static constexpr double PI = { M_PI }; /** DegToRad is a const static member equal to the number of radians in * one degree (dms::PI/180.0). */ static constexpr double DegToRad = { M_PI / 180.0 }; /** @short Static function to create a DMS object from a QString. * * There are several ways to specify the angle: * @li Integer numbers ( 5 or -33 ) * @li Floating-point numbers ( 5.0 or -33.0 ) * @li colon-delimited integers ( 5:0:0 or -33:0:0 ) * @li colon-delimited with float seconds ( 5:0:0.0 or -33:0:0.0 ) * @li colon-delimited with float minutes ( 5:0.0 or -33:0.0 ) * @li space-delimited ( 5 0 0; -33 0 0 ) or ( 5 0.0 or -33 0.0 ) * @li space-delimited, with unit labels ( 5h 0m 0s or -33d 0m 0s ) * @param s the string to be parsed as an angle value * @param deg if true, s is expressed in degrees; if false, s is expressed in hours * @return a dms object whose value is parsed from the string argument */ static dms fromString(const QString &s, bool deg); inline dms operator-() { return dms(-D); } #ifdef COUNT_DMS_SINCOS_CALLS static long unsigned dms_constructor_calls; // counts number of DMS constructor calls static long unsigned dms_with_sincos_called; static long unsigned trig_function_calls; // total number of trig function calls static long unsigned redundant_trig_function_calls; // counts number of redundant trig function calls static double seconds_in_trig; // accumulates number of seconds spent in trig function calls #endif protected: double D; private: #ifdef COUNT_DMS_SINCOS_CALLS mutable bool m_sinDirty, m_cosDirty, m_sinCosCalled; #endif friend dms operator+(dms, dms); friend dms operator-(dms, dms); friend QDataStream &operator<<(QDataStream &out, const dms &d); friend QDataStream &operator>>(QDataStream &in, dms &d); }; /// Add two angles inline dms operator+(dms a, dms b) { return dms(a.D + b.D); } /// Subtract angles inline dms operator-(dms a, dms b) { return dms(a.D - b.D); } // Inline sincos inline void dms::SinCos(double &s, double &c) const { #ifdef PROFILE_SINCOS std::clock_t start, stop; start = std::clock(); #endif #ifdef __GLIBC__ #if (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__UCLIBC__)) //GNU version sincos(radians(), &s, &c); #else //For older GLIBC versions s = ::sin(radians()); c = ::cos(radians()); #endif #else //ANSI-compliant version s = ::sin(radians()); c = ::cos(radians()); #endif #ifdef PROFILE_SINCOS stop = std::clock(); seconds_in_trig += double(stop - start) / double(CLOCKS_PER_SEC); #endif #ifdef COUNT_DMS_SINCOS_CALLS if (!m_sinCosCalled) { m_sinCosCalled = true; ++dms_with_sincos_called; } if (m_sinDirty) m_sinDirty = false; else ++redundant_trig_function_calls; if (m_cosDirty) m_cosDirty = false; else ++redundant_trig_function_calls; trig_function_calls += 2; #endif } /** Overloaded equality operator */ inline bool operator==(const dms &a1, const dms &a2) { return a1.Degrees() == a2.Degrees(); } diff --git a/kstars/ekos/align/polaralign.cpp b/kstars/ekos/align/polaralign.cpp new file mode 100644 index 000000000..285b11144 --- /dev/null +++ b/kstars/ekos/align/polaralign.cpp @@ -0,0 +1,65 @@ +/* polaralign.cpp determines the mount polar axis position + + Copyright (C) 2020 Chris Rowland + + This application 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. + */ + +#include "polaralign.h" + +#include + +QVector3D PolarAlign::dirCos(const dms primary, const dms secondary) +{ + return QVector3D( + static_cast(secondary.cos() * primary.cos()), + static_cast(secondary.cos() * primary.sin()), + static_cast(secondary.sin())); +} + +QVector3D PolarAlign::dirCos(const SkyPoint sp) +{ + return dirCos(sp.ra(), sp.dec()); +} + +dms PolarAlign::primary(QVector3D dirCos) +{ + dms p; + p.setRadians(static_cast(std::atan2(dirCos.y(), dirCos.x()))); + return p; +} + +dms PolarAlign::secondary(QVector3D dirCos) +{ + dms p; + p.setRadians(static_cast(std::asin(dirCos.z()))); + return p; +} + +SkyPoint PolarAlign::skyPoint(QVector3D dc) +{ + return SkyPoint(primary(dc), secondary(dc)); +} + +QVector3D PolarAlign::poleAxis(SkyPoint p1, SkyPoint p2, SkyPoint p3) +{ + // convert the three positions to vectors, these define the plane + // of the Ha axis rotation + QVector3D v1 = PolarAlign::dirCos(p1); + QVector3D v2 = PolarAlign::dirCos(p2); + QVector3D v3 = PolarAlign::dirCos(p3); + + // the Ha axis direction is the normal to the plane + QVector3D p = QVector3D::normal(v1, v2, v3); + + // p points to the north or south pole depending on the rotation of the points + // the other pole position can be determined by reversing the sign of the Dec and + // adding 12hrs to the Ha value. + // if we want only the north then this would do it + //if (p.z() < 0) + // p = -p; + return p; +} diff --git a/kstars/ekos/align/polaralign.h b/kstars/ekos/align/polaralign.h new file mode 100644 index 000000000..6d6241e49 --- /dev/null +++ b/kstars/ekos/align/polaralign.h @@ -0,0 +1,76 @@ +/* polaralign.h determines the mount polar axis position + + Copyright (C) 2020 Chris Rowland + + This application 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 POLARALIGN_H +#define POLARALIGN_H + +#include +#include +#include + +/** + *@class PolarAlign + *@short PolarAlign class handles determining the mount Ha axis position given three positions taken with the same mount declination. + * + *@author Chris Rowland + *@version 1.0 + */ +class PolarAlign +{ +public: + /// + /// \brief dirCos converts primary and secondary angles to a directional cosine + /// \param primary angle, can be Ra, Ha, Azimuth or the corresponding axis values + /// \param secondary angle, can be Dec, Altitude. 90 deg is the pole + /// \return QVector3D containing the directional cosine. + static QVector3D dirCos(const dms primary, const dms secondary); + + /// + /// \brief dirCos converts a SkyPoint to a directional cosine + /// \param sp SkyPoint with the position + /// \return QVector3D containing the directional cosine. + /// + static QVector3D dirCos(const SkyPoint sp); + + /// + /// \brief primary returns the primary dms value in the directional cosine + /// \param dirCos + /// \return primary angle, Ra, Ha, Azimuth etc. + /// + static dms primary(QVector3D dirCos); + + /// + /// \brief secondary returns the secondary dms angle in the directional cosine + /// \param dirCos + /// \return + /// + static dms secondary(QVector3D dirCos); + + /// + /// \brief skyPoint returns a skypoint derived from the directional cosine vector + /// \param dc + /// \return + /// + static SkyPoint skyPoint(QVector3D dc); + + /// + /// \brief poleAxis returns the pole axis vector given three SkyPoints with the same mount declination + /// \param p1 + /// \param p2 + /// \param p3 + /// \return vector giving the direction of the pole. The rotation between the three points determines which pole + /// the other pole can be determined either by reversing the sign of the declination and adding 12 hrs to the Ha or + /// by negating the vector + /// + static QVector3D poleAxis(SkyPoint p1, SkyPoint p2, SkyPoint p3); + +}; + +#endif // POLARALIGN_H