summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-05-07 01:15:13 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-05-07 01:15:13 (GMT)
commitc0fcc1e421e62b3c64c017ab3046d61009b40b7e (patch)
treeb4a41da0d910b2d7f5b9015ad2f713b62a781678
parentc01ade6f9d4a434de88a54216a9749e02f541cdf (diff)
Added new classes KStarsLite, SkyMapLite, SkyItem, PlanetsItem and nodes
for displaying planets and stars. Copied support for mouse control (pan, zoom) from SkyMap to SkyMapLite. Adopted star images caching for use with QtQuick. Created QML version of splash screen.
-rw-r--r--CMakeLists.txt6
-rw-r--r--datahandlers/CMakeLists.txt1
-rw-r--r--kstars/CMakeLists.txt167
-rw-r--r--kstars/kstarsdata.h2
-rw-r--r--kstars/kstarslite.cpp143
-rw-r--r--kstars/kstarslite.h123
-rw-r--r--kstars/kstarslite/qml/constants/Constants.qml31
-rw-r--r--kstars/kstarslite/qml/main.qml221
-rw-r--r--kstars/kstarslite/qml/modules/BottomMenu.qml201
-rw-r--r--kstars/kstarslite/qml/modules/ContextDrawer.qml122
-rw-r--r--kstars/kstarslite/qml/modules/GlobalDrawer.qml122
-rw-r--r--kstars/kstarslite/qml/modules/Splash.qml51
-rw-r--r--kstars/kstarslite/qml/modules/TopMenu.qml190
-rw-r--r--kstars/kstarslite/qml/modules/helpers/DrawerColorScheme.qml106
-rw-r--r--kstars/kstarslite/qml/modules/helpers/DrawerElem.qml26
-rw-r--r--kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml38
-rw-r--r--kstars/kstarslite/skyitems/nodes/planetitemnode.cpp30
-rw-r--r--kstars/kstarslite/skyitems/nodes/planetitemnode.h51
-rw-r--r--kstars/kstarslite/skyitems/nodes/planetnode.cpp86
-rw-r--r--kstars/kstarslite/skyitems/nodes/planetnode.h88
-rw-r--r--kstars/kstarslite/skyitems/nodes/pointnode.cpp43
-rw-r--r--kstars/kstarslite/skyitems/nodes/pointnode.h58
-rw-r--r--kstars/kstarslite/skyitems/planetsitem.cpp132
-rw-r--r--kstars/kstarslite/skyitems/planetsitem.h42
-rw-r--r--kstars/kstarslite/skyitems/skyitem.cpp34
-rw-r--r--kstars/kstarslite/skyitems/skyitem.h84
-rw-r--r--kstars/kstarsliteinit.cpp119
-rw-r--r--kstars/main.cpp14
-rw-r--r--kstars/projections/projector.cpp10
-rw-r--r--kstars/projections/projector.h8
-rw-r--r--kstars/skycomponents/solarsystemsinglecomponent.cpp11
-rw-r--r--kstars/skymaplite.cpp412
-rw-r--r--kstars/skymaplite.h571
-rw-r--r--kstars/skymaplitevents.cpp283
34 files changed, 3556 insertions, 70 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 537751a..cd62a30 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,12 @@ include(ECMInstallIcons)
include(FeatureSummary)
include(ECMAddAppIcon)
+#Build KStars Lite with -DBUILD_KSTARS_LITE=ON
+option(BUILD_KSTARS_LITE "Build KStars Lite" OFF)
+if(BUILD_KSTARS_LITE)
+ add_definitions(-DKSTARS_LITE)
+endif(BUILD_KSTARS_LITE)
+
# Load the frameworks we need
find_package(KF5 REQUIRED COMPONENTS
Config
diff --git a/datahandlers/CMakeLists.txt b/datahandlers/CMakeLists.txt
index c799072..6a9b53c 100644
--- a/datahandlers/CMakeLists.txt
+++ b/datahandlers/CMakeLists.txt
@@ -4,6 +4,7 @@ include_directories(
${kstars_SOURCE_DIR}/kstars/skycomponents
${kstars_SOURCE_DIR}/kstars/auxiliary
${kstars_SOURCE_DIR}/kstars/time
+ ${kstars_SOURCE_DIR}/kstars/kstarslite
)
set(LibKSDataHandlers_SRCS
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 1d0f7e3..908891a 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -25,6 +25,12 @@ include_directories(
${kstars_SOURCE_DIR}/kstars/time
)
+#Temporary solution to allow use of qml files from source dir
+add_definitions( -DSOURCE_DIR=\"${kstars_SOURCE_DIR}\" )
+
+if(BUILD_KSTARS_LITE)
+endif(BUILD_KSTARS_LITE)
+
if (CFITSIO_FOUND)
set (fits_SRCS
fitsviewer/fitshistogram.cpp
@@ -155,12 +161,12 @@ endif ( XPLANET_FOUND )
########### next target ###############
set(libkstarstools_SRCS
- tools/altvstime.cpp
- tools/avtplotwidget.cpp
- tools/calendarwidget.cpp
- tools/conjunctions.cpp
- tools/jmoontool.cpp
- tools/ksconjunct.cpp
+ tools/altvstime.cpp
+ tools/avtplotwidget.cpp
+ tools/calendarwidget.cpp
+ tools/conjunctions.cpp
+ tools/jmoontool.cpp
+ tools/ksconjunct.cpp
tools/eqplotwidget.cpp
tools/astrocalc.cpp
tools/modcalcangdist.cpp
@@ -177,26 +183,26 @@ set(libkstarstools_SRCS
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/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
#FIXME Port to KF5
#tools/moonphasetool.cpp
- tools/starhopper.cpp
- tools/eyepiecefield.cpp
- tools/exporteyepieceview.cpp
+ tools/starhopper.cpp
+ tools/eyepiecefield.cpp
+ tools/exporteyepieceview.cpp
tools/starhopperdialog.cpp
- )
+ )
if (${KF5_VERSION} VERSION_EQUAL 5.18.0 OR ${KF5_VERSION} VERSION_GREATER 5.18.0)
set(libkstarstools_SRCS
@@ -213,24 +219,24 @@ set(libkstarstools_SRCS
endif()
ki18n_wrap_ui(libkstarstools_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/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/modcalcangdist.ui
tools/modcalcapcoord.ui
tools/modcalcaltaz.ui
@@ -243,15 +249,15 @@ ki18n_wrap_ui(libkstarstools_SRCS
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/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
)
@@ -309,21 +315,21 @@ set(libkstarscomponents_SRCS
)
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/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/kshelplabel.cpp
widgets/unitspinboxwidget.cpp
)
@@ -453,7 +459,7 @@ set(kstars_extra_SRCS
skymapevents.cpp
skypainter.cpp
skyqpainter.cpp
- texturemanager.cpp
+ texturemanager.cpp
)
set(oal_SRCS
@@ -507,11 +513,42 @@ set(printingui_SRCS
printing/pwizwelcome.ui
)
+if(BUILD_KSTARS_LITE)
+ set(kstarslite_SRCS
+ kstarslite.cpp
+ kstarsliteinit.cpp
+ skymaplite.cpp
+ skymaplitevents.cpp
+ #SkyItems
+ kstarslite/skyitems/planetsitem.cpp
+ kstarslite/skyitems/skyitem.cpp
+ #Nodes
+ kstarslite/skyitems/nodes/planetnode.cpp
+ kstarslite/skyitems/nodes/pointnode.cpp
+ kstarslite/skyitems/nodes/planetitemnode.cpp
+ )
+ #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/BottomMenu.qml
+ kstarslite/qml/modules/ContextDrawer.qml
+ kstarslite/qml/modules/GlobalDrawer.qml
+ kstarslite/qml/modules/TopMenu.qml
+ kstarslite/qml/modules/helpers/DrawerColorScheme.qml
+ kstarslite/qml/modules/helpers/DrawerElem.qml
+ kstarslite/qml/modules/helpers/TopMenuButton.qml
+ kstarslite/qml/modules/Splash.qml
+ )
+ ADD_CUSTOM_TARGET(kstarsliteqml SOURCES ${kstarsliteqml_SRCS})
+endif(BUILD_KSTARS_LITE)
+
set(kstars_SRCS ${indi_SRCS} ${fits_SRCS} ${ekos_SRCS} ${onlineparser_SRCS}
- ${libkstarswidgets_SRCS} ${libkstarscomponents_SRCS} ${libkstarstools_SRCS}
- ${kstars_extra_SRCS} ${kstars_gl_SRCS} ${kstars_projection_SRCS} ${xplanet_SRCS}
- ${kstars_options_SRCS} ${kstars_skyobjects_SRCS} ${kstars_dialogs_SRCS} ${oal_SRCS}
- ${printing_SRCS}
+ ${libkstarswidgets_SRCS} ${libkstarscomponents_SRCS} ${libkstarstools_SRCS}
+ ${kstars_extra_SRCS} ${kstars_gl_SRCS} ${kstars_projection_SRCS} ${xplanet_SRCS}
+ ${kstars_options_SRCS} ${kstars_skyobjects_SRCS} ${kstars_dialogs_SRCS} ${oal_SRCS}
+ ${printing_SRCS} ${kstarslite_SRCS} ${kstarslite_RESOURCE}
)
qt5_add_dbus_adaptor(kstars_SRCS org.kde.kstars.xml kstars.h KStars)
@@ -570,7 +607,7 @@ target_link_libraries(KStarsLib
Qt5::Svg
Qt5::Qml
Qt5::Quick
- ${ZLIB_LIBRARIES}
+ ${ZLIB_LIBRARIES}
)
if(NOT WIN32)
diff --git a/kstars/kstarsdata.h b/kstars/kstarsdata.h
index 7723599..d5c05e6 100644
--- a/kstars/kstarsdata.h
+++ b/kstars/kstarsdata.h
@@ -231,7 +231,7 @@ public:
signals:
/** Signal that specifies the text that should be drawn in the KStarsSplash window. */
- void progressText( const QString& );
+ void progressText( const QString& text );
/** Should be used to refresh skymap. */
void skyUpdate( bool );
diff --git a/kstars/kstarslite.cpp b/kstars/kstarslite.cpp
new file mode 100644
index 0000000..18165f2
--- /dev/null
+++ b/kstars/kstarslite.cpp
@@ -0,0 +1,143 @@
+/** *************************************************************************
+ kstarslite.cpp - K Desktop Planetarium
+ -------------------
+ begin : 30/04/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "kstarslite.h"
+#include "skymaplite.h"
+#include "kstarsdata.h"
+#include <QQmlContext>
+
+#include "Options.h"
+#include "ksutils.h"
+
+KStarsLite *KStarsLite::pinstance = 0;
+
+KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDateString) {
+ // Initialize logging settings
+ if (Options::disableLogging())
+ KSUtils::Logging::Disable();
+ else if (Options::logToFile() && Options::verboseLogFile().isEmpty() == false)
+ KSUtils::Logging::UseFile(Options::verboseLogFile());
+ else
+ KSUtils::Logging::UseDefault();
+
+ //Register SkyMapLite for use within QML
+ qmlRegisterType<SkyMapLite>("skymaplite",1,0,"SkyMapLite");
+ QString main = QString(SOURCE_DIR) + "/kstars/kstarslite/qml/main.qml";
+
+ m_Engine.load(QUrl(main));
+
+ m_RootObject = m_Engine.rootObjects()[0];
+ Q_ASSERT(m_RootObject);
+ if(!m_RootObject) qDebug() << "Please, check QML files for syntax errors";
+
+ QQuickItem* skyMapLiteWrapper = m_RootObject->findChild<QQuickItem*>("skyMapLiteWrapper");
+ //Once KStarsData is loaded we are ready to show the SkyMapLite
+
+ m_KStarsData = KStarsData::Create();
+ Q_ASSERT( m_KStarsData );
+
+ //Make instance of KStarsLite and KStarsData available to QML
+ m_Engine.rootContext()->setContextProperty("KStarsLite", this);
+ m_Engine.rootContext()->setContextProperty("KStarsData", m_KStarsData);
+
+ //Set Geographic Location from Options
+ m_KStarsData->setLocationFromOptions();
+
+ /*SkyMapLite has to be loaded before KStarsData is initialized because SkyComponents derived classes
+ have to add SkyItems to the SkyMapLite*/
+ m_SkyMapLite = SkyMapLite::createInstance(skyMapLiteWrapper);
+
+ // Set pinstance to yourself
+ pinstance = this;
+
+ //Initialize Time and Date
+ if (startDateString.isEmpty() == false)
+ {
+ KStarsDateTime startDate = KStarsDateTime::fromString( startDateString );
+ if (startDate.isValid() )
+ data()->changeDateTime( data()->geo()->LTtoUT( startDate ) );
+ else
+ data()->changeDateTime( KStarsDateTime::currentDateTimeUtc() );
+ }
+ else data()->changeDateTime( KStarsDateTime::currentDateTimeUtc() );
+
+ // Initialize clock. If --paused is not in the comand line, look in options
+ if ( startClock ) StartClockRunning = Options::runClock();
+
+ // Setup splash screen
+ if ( doSplash ) {
+ //connect( m_KStarsData, SIGNAL( progressText(QString) ), splash, SLOT( setMessage(QString) ));
+ //splash->show();
+ } else {
+ connect( m_KStarsData, SIGNAL( progressText(QString) ), m_KStarsData, SLOT( slotConsoleMessage(QString) ) );
+ }
+
+ //set up Dark color scheme for application windows
+ //TODO: Move that to QML
+ DarkPalette = QPalette(QColor("darkred"), QColor("darkred"));
+ DarkPalette.setColor( QPalette::Normal, QPalette::Base, QColor( "black" ) );
+ DarkPalette.setColor( QPalette::Normal, QPalette::Text, QColor( 238, 0, 0 ) );
+ DarkPalette.setColor( QPalette::Normal, QPalette::Highlight, QColor( 238, 0, 0 ) );
+ DarkPalette.setColor( QPalette::Normal, QPalette::HighlightedText, QColor( "black" ) );
+ DarkPalette.setColor( QPalette::Inactive, QPalette::Text, QColor( 238, 0, 0 ) );
+ DarkPalette.setColor( QPalette::Inactive, QPalette::Base, QColor( 30, 10, 10 ) );
+ //store original color scheme
+ OriginalPalette = QApplication::palette();
+ if( !m_KStarsData->initialize() ) return;
+ datainitFinished();
+
+#if ( __GLIBC__ >= 2 &&__GLIBC_MINOR__ >= 1 && !defined(__UCLIBC__) )
+ qDebug() << "glibc >= 2.1 detected. Using GNU extension sincos()";
+#else
+ qDebug() << "Did not find glibc >= 2.1. Will use ANSI-compliant sin()/cos() functions.";
+#endif
+}
+
+KStarsLite *KStarsLite::createInstance( bool doSplash, bool clockrunning, const QString &startDateString) {
+ delete pinstance;
+ // pinstance is set directly in constructor.
+ new KStarsLite( doSplash, clockrunning, startDateString );
+ Q_ASSERT( pinstance && "pinstance must be non NULL");
+ return nullptr;
+}
+
+void KStarsLite::updateTime( const bool automaticDSTchange ) {
+ // Due to frequently use of this function save data and map pointers for speedup.
+ // Save options and geo() to a pointer would not speedup because most of time options
+ // and geo will accessed only one time.
+ KStarsData *Data = data();
+ // dms oldLST( Data->lst()->Degrees() );
+
+ Data->updateTime( Data->geo(), automaticDSTchange );
+
+ //We do this outside of kstarsdata just to get the coordinates
+ //displayed in the infobox to update every second.
+ // if ( !Options::isTracking() && LST()->Degrees() > oldLST.Degrees() ) {
+ // int nSec = int( 3600.*( LST()->Hours() - oldLST.Hours() ) );
+ // Map->focus()->setRA( Map->focus()->ra().Hours() + double( nSec )/3600. );
+ // if ( Options::useAltAz() ) Map->focus()->EquatorialToHorizontal( LST(), geo()->lat() );
+ // Map->showFocusCoords();
+ // }
+
+ //If time is accelerated beyond slewTimescale, then the clock's timer is stopped,
+ //so that it can be ticked manually after each update, in order to make each time
+ //step exactly equal to the timeScale setting.
+ //Wrap the call to manualTick() in a singleshot timer so that it doesn't get called until
+ //the skymap has been completely updated.
+ if ( Data->clock()->isManualMode() && Data->clock()->isActive() ) {
+ QTimer::singleShot( 0, Data->clock(), SLOT( manualTick() ) );
+ }
+}
diff --git a/kstars/kstarslite.h b/kstars/kstarslite.h
new file mode 100644
index 0000000..9d264c3
--- /dev/null
+++ b/kstars/kstarslite.h
@@ -0,0 +1,123 @@
+/** *************************************************************************
+ kstarslite.h - K Desktop Planetarium
+ -------------------
+ begin : 30/04/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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 KSTARSLITE_H_
+#define KSTARSLITE_H_
+
+#include <config-kstars.h>
+#include <QString>
+#include <QQmlApplicationEngine>
+#include <QPalette>
+
+// forward declaration is enough. We only need pointers
+class KStarsData;
+class SkyMapLite;
+class SkyPoint;
+class GeoLocation;
+
+class QQuickItem;
+
+class OpsCatalog;
+class OpsGuides;
+class OpsSolarSystem;
+class OpsSatellites;
+class OpsSupernovae;
+class OpsColors;
+class OpsAdvanced;
+class OpsINDI;
+class OpsEkos;
+
+/**
+ *@class KStarsLite
+ *@short This class loads QML files and connects SkyMapLite and KStarsData
+ *Unlike KStars class it is not a main Window but a root object that contains the program clock and holds pointers on SkyMapLite and KStarsData objects.
+ *KStarsLite is a singleton, use KStarsLite::createInstance() to create an instance and KStarsLite::Instance() to get a pointer to the instance
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class KStarsLite : public QObject
+{
+ Q_OBJECT
+
+private:
+ /**
+ * @short Constructor.
+ * @param doSplash should the splash panel be displayed during
+ * initialization.
+ * @param startClockRunning should the clock be running on startup?
+ * @param startDateString date (in string representation) to start running from.
+ */
+ explicit KStarsLite( bool doSplash, bool startClockRunning = true, const QString &startDateString = QString() );
+
+ static KStarsLite *pinstance; // Pointer to an instance of KStarsLite
+
+public:
+ /**
+ * @short Create an instance of this class. Destroy any previous instance
+ * @param doSplash
+ * @param clockrunning
+ * @param startDateString
+ * @note See KStarsLite::KStarsLite for details on parameters
+ * @return a pointer to the instance
+ */
+ static KStarsLite *createInstance( bool doSplash, bool clockrunning = true, const QString &startDateString = QString() );
+
+ /** @return a pointer to the instance of this class */
+ inline static KStarsLite *Instance() { return pinstance; }
+
+ /** Destructor. Does nothing yet*/
+ virtual ~KStarsLite() { }
+
+ /** @return pointer to SkyMapLite object which contains application data. */
+ inline SkyMapLite* map() const { return m_SkyMapLite; }
+
+ /** @return pointer to KStarsData object which contains application data. */
+ inline KStarsData* data() const { return m_KStarsData; }
+
+signals:
+ /** Sent when KStarsData finishes loading data */
+ void dataLoadFinished();
+
+public Q_SLOTS:
+ /**
+ * Update time-dependent data and (possibly) repaint the sky map.
+ * @param automaticDSTchange change DST status automatically?
+ */
+ void updateTime( const bool automaticDSTchange = true );
+private slots:
+ /** finish setting up after the KStarsData has finished
+ */
+ void datainitFinished();
+
+private:
+ /** Initialize focus position */
+ void initFocus();
+
+
+ QQmlApplicationEngine m_Engine;
+ SkyMapLite *m_SkyMapLite;
+ QPalette OriginalPalette, DarkPalette;
+
+ QObject *m_RootObject;
+ //QQuickItem *m_SkyMapLiteWrapper;
+ bool StartClockRunning;
+
+ KStarsData* m_KStarsData;
+};
+
+#endif
+
diff --git a/kstars/kstarslite/qml/constants/Constants.qml b/kstars/kstarslite/qml/constants/Constants.qml
new file mode 100644
index 0000000..82d8be9
--- /dev/null
+++ b/kstars/kstarslite/qml/constants/Constants.qml
@@ -0,0 +1,31 @@
+pragma Singleton
+import QtQuick 2.0
+import QtQuick.Window 2.0
+
+QtObject {
+ property double dpi: Screen.pixelDensity * 25.4
+ property double dpmm: Screen.pixelDensity
+ property double dp: dpi < 160 ? 1 : dpi/160
+ property string density: {
+ if(dpi <= 120) {
+ return "ldpi"
+ }
+ else if(dpi <=160) {
+ return "mdpi"
+ }
+ else if(dpi <= 240) {
+ return "hdpi"
+ }
+ else if(dpi <= 320) {
+ return "xhdpi"
+ }
+ else if(dpi <= 480) {
+ return "xxhdpi"
+ }
+ else if(dpi <=640) {
+ return "xxxhdpi"
+ }
+ }
+ property string iconpath: "../" + "images/" + density + "/icons/"
+ property string imagesPath: "images/" + density + "/"
+}
diff --git a/kstars/kstarslite/qml/main.qml b/kstars/kstarslite/qml/main.qml
new file mode 100644
index 0000000..4faf717
--- /dev/null
+++ b/kstars/kstarslite/qml/main.qml
@@ -0,0 +1,221 @@
+import QtQuick 2.4
+import QtQuick.Window 2.2
+import "modules"
+import "constants" 1.0
+import skymaplite 1.0
+
+Window {
+ id: mainWindow
+ visible: false
+ width: Screen.desktopAvailableWidth
+ height: Screen.desktopAvailableHeight
+ property double shadowBgOpacity
+ property int drawersOrder: 2
+ property int bgOrder: 1
+ property int skyMapOrder: 0
+ property int topMenuOrder: 0
+
+ property Splash splash: Splash {
+ onTimeout: mainWindow.visible = true
+ }
+
+ Rectangle {
+ id: skyMapLiteWrapper
+ color: "#000"
+ objectName: "skyMapLiteWrapper"
+ anchors.fill: parent
+ }
+
+ GlobalDrawer{
+ id: globalDrawer
+ width: parent.width < parent.height ? parent.width * 0.65 + dragWidth: parent.width * 0.4 + dragWidth
+ z: drawersOrder
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ }
+ }
+
+ /*Image {
+ anchors.fill: parent
+ z: skyMapOrder
+ source: "modules/images/SkyMap.png"
+ fillMode: Image.PreserveAspectCrop
+
+ Connections {
+ target: mainWindow
+ onWidthChanged: {
+ if (width > height) {
+ source = "images/SkyMap-port.png"
+ }
+ else source = "images/SkyMap.png"
+ }
+ }
+ }*/
+
+ // The instance of SkyMapLite is reparanted to this item and fill it
+
+ //SkyMapLite {
+ //anchors.fill: parent
+ //}
+
+ MouseArea {
+ property int posY
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ }
+ height: parent.height * 0.25
+
+ onPressed: {
+ posY = mouseY
+ }
+
+ onPositionChanged: {
+ var ratio = 0.05
+ var delta = mouseY - posY
+ if (delta > parent.height * ratio) {
+ if(topMenu.state != "open") topMenu.state = "open"
+ } else if (delta < - (parent.height * ratio)) {
+ if(topMenu.state != "") topMenu.state = ""
+ }
+
+ }
+ TopMenu {
+ z: topMenuOrder
+ id: topMenu
+ anchors.horizontalCenter: parent.horizontalCenter
+ Connections {
+ target: mainWindow
+
+ function setOrientation() {
+ if (width < topMenu.width) {
+ topMenu.state = "portrait"
+ }
+ else topMenu.state = "landscape"
+ }
+
+ Component.onCompleted: {
+ setOrientation()
+ }
+
+ onWidthChanged: {
+ setOrientation()
+ }
+ }
+ }
+ }
+ Rectangle {
+ id: shadowBg
+ z: bgOrder
+ anchors.fill: parent
+ color: "black"
+ opacity: 0
+ property double minOpacity: 0.35
+
+ Connections {
+ target: globalDrawer
+ onBgOpacityChanged: {
+ var bgOpacity = globalDrawer.bgOpacity
+ if (bgOpacity < shadowBg.minOpacity && contextDrawer.state != "open") shadowBg.opacity = bgOpacity
+ }
+ onStateChanged: {
+ if(globalDrawer.state == "open") contextDrawer.state = ""
+ }
+ }
+
+ Connections {
+ target: contextDrawer
+ onBgOpacityChanged: {
+ var bgOpacity = contextDrawer.bgOpacity
+ if (bgOpacity < shadowBg.minOpacity && globalDrawer.state != "open") shadowBg.opacity = bgOpacity
+ }
+ onStateChanged: {
+ if(contextDrawer.state == "open") globalDrawer.state = ""
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ if(globalDrawer.state == "open") {
+ globalDrawer.state = ""
+ mouse.accepted = true
+ return
+ }
+ if(contextDrawer.state == "open") {
+ contextDrawer.state = ""
+ mouse.accepted = true
+ return
+ }
+ mouse.accepted = false
+ }
+ }
+
+ Behavior on opacity {
+ PropertyAnimation {
+ duration: 300
+ }
+ }
+ }
+
+ MouseArea {
+ property int posY
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+ height: parent.height *0.25
+
+ onPressed: {
+ posY = mouseY
+ }
+
+ onPositionChanged: {
+ var ratio = 0.05
+ var delta = mouseY - posY
+ if (delta < parent.height * ratio) {
+ if(bottomMenu.state != "open") bottomMenu.state = "open"
+ } else if (delta > - (parent.height * ratio)) {
+ if(bottomMenu.state != "") bottomMenu.state = ""
+ }
+
+ }
+ BottomMenu {
+ z: topMenuOrder
+ id: bottomMenu
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ Connections {
+ target: mainWindow
+
+ function setOrientation() {
+ if (width < topMenu.width) {
+ bottomMenu.state = "portrait"
+ }
+ else bottomMenu.state = "landscape"
+ }
+
+ Component.onCompleted: {
+ setOrientation()
+ }
+
+ onWidthChanged: {
+ setOrientation()
+ }
+ }
+ }
+ }
+
+ ContextDrawer{
+ id: contextDrawer
+ width: parent.width < parent.height ? parent.width * 0.65 + dragWidth: parent.width * 0.4 + dragWidth
+ z: drawersOrder
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ }
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/BottomMenu.qml b/kstars/kstarslite/qml/modules/BottomMenu.qml
new file mode 100644
index 0000000..5e756cd
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/BottomMenu.qml
@@ -0,0 +1,201 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles 1.4
+import "../constants" 1.0
+import "helpers"
+
+ColumnLayout {
+ id: bottomMenu
+ property int padding: num.dp * 10
+ property int minY: - menuRect.height
+ property int maxY: -menuRect.radius
+
+ anchors{
+ bottom: parent.bottom
+ bottomMargin: minY
+ }
+
+ states: [
+ State {
+ name: "open"
+ PropertyChanges {
+ target: bottomMenu
+ anchors.bottomMargin: maxY
+ }
+ PropertyChanges {
+ target: arrowUp
+ state:""
+ }
+ },
+ State {
+ name: ""
+ PropertyChanges {
+ target: bottomMenu
+ y: minY
+ }
+ PropertyChanges {
+ target: arrowUp
+ state:"visible"
+ }
+ }
+ ]
+
+ Behavior on anchors.bottomMargin {
+ PropertyAnimation {
+ duration: 500
+ }
+ }
+
+ Image {
+ id: arrowUp
+ anchors {
+ bottom: menuRect.top
+ horizontalCenter: menuRect.horizontalCenter
+ bottomMargin: num.dp * 10
+ }
+ source: num.imagesPath + "arrow_up.png"
+
+ Component.onCompleted: {
+ state = "visible"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ bottomMenu.state = bottomMenu.state == "open" ? "" : "open"
+ }
+ }
+
+ states: [
+ State {
+ name:"visible"
+ PropertyChanges {
+ target: arrowUp
+ opacity: 1
+ visible: true
+ }
+ },
+ State {
+ name:""
+ PropertyChanges {
+ target: arrowUp
+ opacity: 0
+ visible: false
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "visible"
+ to: ""
+
+ SequentialAnimation {
+ NumberAnimation {
+ target: arrowUp
+ property: "opacity"
+ duration: 300
+ }
+ NumberAnimation {
+ target: arrowUp
+ property: "visible"
+ duration: 0
+ }
+ }
+ },
+ Transition {
+ from: ""
+ to: "visible"
+ SequentialAnimation {
+ NumberAnimation {
+ target: arrowUp
+ property: "visible"
+ duration: 0
+ }
+ NumberAnimation {
+ target: arrowUp
+ property: "opacity"
+ duration: 300
+ }
+ }
+ }
+ ]
+ }
+
+ Rectangle {
+ id: menuRect
+
+ width: menuGrid.width + padding*3
+ height: menuGrid.height + padding*3 + radius
+ color: "#000033"
+ border {
+ width: num.dp * 3
+ color: "gray"
+ }
+ radius: num.dp * 20
+
+ Grid {
+ spacing: num.dp * 10
+ id: menuGrid
+ state: "landscape"
+ anchors{
+ bottom: parent.bottom
+ bottomMargin: padding + parent.radius
+ horizontalCenter: parent.horizontalCenter
+ }
+
+ states: [
+ State {
+ name: "portrait"
+ PropertyChanges {
+ target: menuGrid
+ columns: 5
+ }
+ },
+ State {
+ name: "landscape"
+ PropertyChanges {
+ target: menuGrid
+ columns: 9
+ }
+ }
+ ]
+
+ TopMenuButton {
+ id: icon
+ iconSrc: num.iconpath + "media-skip-backward.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "media-playback-start.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "media-skip-forward.png"
+ }
+
+ TextField {
+ text: "1 sec."
+ style: TextFieldStyle {
+ background: Rectangle {
+ color: "#000"
+ radius: 2
+ implicitWidth: 100
+ implicitHeight: 24
+ border.color: "gray"
+ border.width: 1
+ }
+ }
+ height: icon.height
+ width: num.dp * 75
+ }
+
+ TopMenuButton {
+ iconSrc: num.iconpath + "arrow-up.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "arrow-down.png"
+ }
+ }
+
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/ContextDrawer.qml b/kstars/kstarslite/qml/modules/ContextDrawer.qml
new file mode 100644
index 0000000..41aad2d
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/ContextDrawer.qml
@@ -0,0 +1,122 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import QtGraphicalEffects 1.0
+import "helpers"
+import "../constants" 1.0
+
+Item {
+ id: contextDrawer
+ property int dragWidth: num.dp * 50
+ property int minX: parent.width - width
+ property int maxX: parent.width - globShadow.anchors.leftMargin - dragWidth
+ property double bgOpacity: 1 + (x - minX)/(minX-maxX)
+ x: maxX
+
+ states: [
+ State {
+ name: "open"
+ PropertyChanges {
+ target: contextDrawer
+ x: minX
+ }
+ },
+ State {
+ name: ""
+ PropertyChanges {
+ target: contextDrawer
+ x: maxX
+ }
+ }
+ ]
+
+ Behavior on x {
+ PropertyAnimation {
+ duration: 150
+ }
+ }
+
+ MouseArea {
+ id: globDrag
+ anchors.fill: parent
+ drag {
+ target: contextDrawer
+ axis: Drag.XAxis
+ minimumX: contextDrawer.minX
+ maximumX: contextDrawer.maxX
+ onActiveChanged: {
+ if (contextDrawer.state == "") {
+ if (contextDrawer.x < maxX*0.8) {
+ contextDrawer.state = "open"
+ }
+ else contextDrawer.x = maxX
+ }
+ else if (contextDrawer.state == "open"){
+ if (contextDrawer.x > minX + maxX*0.15) {
+ contextDrawer.state = ""
+ }
+ else contextDrawer.x = minX
+ }
+ }
+ }
+
+ }
+
+ BorderImage {
+ id: globShadow
+ anchors {
+ top: parentRect.top
+ bottom: parentRect.bottom
+ left: parentRect.left
+ }
+ anchors { topMargin: -2; leftMargin: -8; bottomMargin: -2 }
+ border { top: 10; right: 10; bottom: 10 }
+ source: "images/shadow.png"
+ }
+
+ Rectangle {
+ anchors {
+ fill: parent
+ leftMargin: contextDrawer.dragWidth
+ }
+
+ id: parentRect
+
+ ColumnLayout {
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ topMargin: num.dp * 10
+ leftMargin: num.dp * 10
+ }
+ spacing: num.dp * 10
+
+ Text {
+ id: contextHeader
+ text: "Mars"
+ font.family: "Oxygen Normal"
+ font.pixelSize: num.dp * 44
+ color: "#31363b"
+ }
+
+ ColumnLayout {
+ anchors {
+ top: contextHeader.bottom
+ topMargin: num.dp * 30
+ }
+ spacing: num.dp * 30
+
+
+ DrawerElem {
+ iconSrc: num.iconpath + "/compass.png"
+ title: "Center & Track"
+ }
+
+ DrawerElem {
+ iconSrc: num.iconpath + "/games-config-custom.png"
+ title: "Details"
+ }
+ }
+ }
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/GlobalDrawer.qml b/kstars/kstarslite/qml/modules/GlobalDrawer.qml
new file mode 100644
index 0000000..e327a91
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/GlobalDrawer.qml
@@ -0,0 +1,122 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import QtGraphicalEffects 1.0
+import "helpers"
+import "../constants" 1.0
+
+Item {
+ id: globalDrawer
+ property int dragWidth: num.dp * 50
+ property int maxX: 0
+ property int minX: dragWidth - width + globShadow.anchors.rightMargin
+ property double bgOpacity: 1 - (x/minX)
+ x: minX
+
+ states: [
+ State {
+ name: "open"
+ PropertyChanges {
+ target: globalDrawer
+ x: maxX
+ }
+ },
+ State {
+ name: ""
+ PropertyChanges {
+ target: globalDrawer
+ x: minX
+ }
+ }
+ ]
+
+ Behavior on x {
+ PropertyAnimation {
+ duration: 150
+ }
+ }
+
+ MouseArea {
+ id: globDrag
+ anchors {
+ fill: parent
+ }
+
+ drag {
+ target: globalDrawer
+ axis: Drag.XAxis
+ minimumX: globalDrawer.minX
+ maximumX: globalDrawer.maxX
+ onActiveChanged: {
+ if (globalDrawer.state == "") {
+ if (globalDrawer.x > minX*0.8) {
+ globalDrawer.state = "open"
+ }
+ else globalDrawer.x = minX
+ }
+ else if (globalDrawer.state == "open"){
+ if (globalDrawer.x < minX*0.3) {
+ globalDrawer.state = ""
+ }
+ else globalDrawer.x = maxX
+ }
+ }
+ }
+
+
+ BorderImage {
+ id: globShadow
+ anchors {
+ top: parentRect.top
+ bottom: parentRect.bottom
+ right: parentRect.right
+ }
+ anchors { topMargin: -2; rightMargin: -8; bottomMargin: -2 }
+ border { top: 10; right: 10; bottom: 10 }
+ source: "images/shadow.png"
+ }
+
+ Rectangle {
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ }
+ width: parent.width - dragWidth
+
+ id: parentRect
+
+ Image {
+ id: contextHeader
+ source: "images/kstars.png"
+ fillMode: Image.PreserveAspectFit
+ width: parentRect.width
+ }
+
+ ColumnLayout {
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: contextHeader.bottom
+ topMargin: num.dp * 10
+ leftMargin: num.dp * 10
+ }
+ spacing: num.dp * 30
+
+ DrawerElem {
+ iconSrc: num.iconpath + "/system-search.png"
+ title: "Search"
+ }
+
+ DrawerColorScheme {
+
+ }
+
+ DrawerElem {
+ iconSrc: num.iconpath + "/applications-system.png"
+ title: "Settings"
+ }
+ }
+
+ }
+
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/Splash.qml b/kstars/kstarslite/qml/modules/Splash.qml
new file mode 100644
index 0000000..b4b1505
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/Splash.qml
@@ -0,0 +1,51 @@
+import QtQuick 2.4
+import QtQuick.Window 2.2
+
+Window {
+ id: splash
+ color: "transparent"
+ title: "Splash Window"
+ modality: Qt.ApplicationModal
+ flags: Qt.SplashScreen
+ signal timeout
+
+ x: (Screen.width - splashImage.width) / 2
+ y: (Screen.height - splashImage.height) / 2
+
+ width: splashImage.width
+ height: splashImage.height
+
+ Image {
+ id: splashImage
+ source: "images/kstars.png"
+
+ Text {
+ id: progress
+ color: "#FFF"
+
+ anchors {
+ top: parent.top
+ left: parent.left
+ margins: 10
+ }
+ }
+ }
+
+ Connections {
+ target: KStarsData
+ onProgressText: {
+ progress.text = text
+ }
+ }
+
+ Connections {
+ target: KStarsLite
+ onDataLoadFinished: {
+ visible = false
+ splash.timeout()
+ }
+ }
+
+ Component.onCompleted: visible = true
+}
+
diff --git a/kstars/kstarslite/qml/modules/TopMenu.qml b/kstars/kstarslite/qml/modules/TopMenu.qml
new file mode 100644
index 0000000..a189abb
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/TopMenu.qml
@@ -0,0 +1,190 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import "../constants" 1.0
+import "helpers"
+
+ColumnLayout {
+ id: topMenu
+ property int padding: num.dp * 10
+ property int minY: - menuRect.radius
+ property int maxY: - menuRect.height
+ y: maxY
+
+ states: [
+ State {
+ name: "open"
+ PropertyChanges {
+ target: topMenu
+ y: minY
+ }
+ PropertyChanges {
+ target: arrowDown
+ state:""
+ }
+ },
+ State {
+ name: ""
+ PropertyChanges {
+ target: topMenu
+ y: maxY
+ }
+ PropertyChanges {
+ target: arrowDown
+ state:"visible"
+ }
+ }
+ ]
+
+ Behavior on y {
+ PropertyAnimation {
+ duration: 500
+ }
+ }
+
+ Rectangle {
+ id: menuRect
+
+ width: menuGrid.width + padding*3
+ height: menuGrid.height + padding*3 + radius
+ y: maxY
+ color: "#000033"
+ border {
+ width: num.dp * 3
+ color: "gray"
+ }
+ radius: num.dp * 20
+
+ Grid {
+ spacing: num.dp * 10
+ id: menuGrid
+ state: "landscape"
+ anchors{
+ top: parent.top
+ topMargin: padding + parent.radius
+ horizontalCenter: parent.horizontalCenter
+ }
+
+ states: [
+ State {
+ name: "portrait"
+ PropertyChanges {
+ target: menuGrid
+ columns: 5
+ }
+ },
+ State {
+ name: "landscape"
+ PropertyChanges {
+ target: menuGrid
+ columns: 9
+ }
+ }
+ ]
+
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_stars.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_deepsky.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_planets.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_clines.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_cnames.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_cbound.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_mw.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_grid.png"
+ }
+ TopMenuButton {
+ iconSrc: num.iconpath + "/sc-actions-kstars_horizon.png"
+ }
+ }
+
+ }
+
+ Image {
+ id: arrowDown
+ anchors {
+ top: menuRect.bottom
+ horizontalCenter: menuRect.horizontalCenter
+ topMargin: num.dp * 10
+ }
+ source: num.imagesPath + "arrow_down.png"
+
+ Component.onCompleted: {
+ state = "visible"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ topMenu.state = topMenu.state == "open" ? "" : "open"
+ }
+ }
+
+ states: [
+ State {
+ name:"visible"
+ PropertyChanges {
+ target: arrowDown
+ opacity: 1
+ visible: true
+ }
+ },
+ State {
+ name:""
+ PropertyChanges {
+ target: arrowDown
+ opacity: 0
+ visible: false
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "visible"
+ to: ""
+
+ SequentialAnimation {
+ NumberAnimation {
+ target: arrowDown
+ property: "opacity"
+ duration: 300
+ }
+ NumberAnimation {
+ target: arrowDown
+ property: "visible"
+ duration: 0
+ }
+ }
+ },
+ Transition {
+ from: ""
+ to: "visible"
+ SequentialAnimation {
+ NumberAnimation {
+ target: arrowDown
+ property: "visible"
+ duration: 0
+ }
+ NumberAnimation {
+ target: arrowDown
+ property: "opacity"
+ duration: 300
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/helpers/DrawerColorScheme.qml b/kstars/kstarslite/qml/modules/helpers/DrawerColorScheme.qml
new file mode 100644
index 0000000..e4e985d
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/helpers/DrawerColorScheme.qml
@@ -0,0 +1,106 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import "../../constants" 1.0
+
+ColumnLayout {
+ property var iconSrc: ""
+ property string title: ""
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ DrawerElem {
+ iconSrc: num.iconpath + "/color-management.png"
+ title: "Color Scheme"
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ if (!colorSchemes.Layout.minimumHeight) colorSchemes.Layout.minimumHeight = colorsFlow.childrenRect.height
+ else colorSchemes.Layout.minimumHeight = 0
+ }
+
+ Image {
+ source: num.iconpath + "/arrow-right.png"
+ anchors.right: parent.right
+ }
+ }
+
+ }
+
+ Rectangle {
+ id:colorSchemes
+ Layout.minimumHeight: 0
+ Layout.fillWidth: true
+
+ Behavior on Layout.minimumHeight {
+ NumberAnimation {
+ duration: 400
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ transitions: Transition {
+ NumberAnimation {
+ properties: "Layout.minimumHeight"
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ Flow {
+ id: colorsFlow
+ height: parent.height
+ anchors {
+ left: parent.left
+ leftMargin: num.dp * 55
+ top: parent.top
+ topMargin: num.dp * 10
+ right: parent.right
+ rightMargin: num.dp * 20
+ }
+
+ clip: true
+ property double rectSize: num.dp * 80
+ spacing: num.dp * 20
+ Rectangle {
+ width: parent.rectSize
+ height: parent.rectSize
+ color: "#000022"
+ border {
+ width: 1
+ color: "black"
+ }
+ }
+
+ Rectangle {
+ width: parent.rectSize
+ height: parent.rectSize
+ color: "#ffffff"
+ border {
+ width: 1
+ color: "black"
+ }
+ }
+
+ Rectangle {
+ width: parent.rectSize
+ height: parent.rectSize
+ color: "#880000"
+ border {
+ width: 1
+ color: "black"
+ }
+ }
+
+ Rectangle {
+ width: parent.rectSize
+ height: parent.rectSize
+ color: "black"
+ border {
+ width: 1
+ color: "black"
+ }
+ }
+ }
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/helpers/DrawerElem.qml b/kstars/kstarslite/qml/modules/helpers/DrawerElem.qml
new file mode 100644
index 0000000..441ecf5
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/helpers/DrawerElem.qml
@@ -0,0 +1,26 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import "../../constants" 1.0
+
+RowLayout {
+ property var iconSrc: ""
+ property string title: ""
+ spacing: 25 * num.dp
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+
+ Image {
+ source: iconSrc
+ fillMode: Image.PreserveAspectFit
+ }
+
+ Text {
+ text: title
+ font.family: "Oxygen Normal"
+ font.pixelSize: num.dp * 28
+ color: "#31363b"
+ anchors.verticalCenter: parent.verticalCenter
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml b/kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml
new file mode 100644
index 0000000..47858f1
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml
@@ -0,0 +1,38 @@
+import QtQuick 2.0
+import QtGraphicalEffects 1.0
+import "../../constants/" 1.0
+
+Item {
+ property string iconSrc: ""
+ width: iconRect.width
+ height: iconRect.height
+
+ Image {
+ id: icon
+ source: iconSrc
+ visible: false
+ }
+
+ Rectangle {
+ width: iconRect.width + num.dp * 3
+ height: iconRect.height + num.dp *3
+ color: "gray"
+
+ radius: 5
+ Rectangle {
+ id: iconRect
+ width: icon.width
+ height: icon.height
+ radius: 5
+ anchors.centerIn: parent
+ color: "black"
+ }
+ OpacityMask {
+ anchors.fill: iconRect
+ source: icon
+ maskSource: iconRect
+ }
+ }
+
+
+}
diff --git a/kstars/kstarslite/skyitems/nodes/planetitemnode.cpp b/kstars/kstarslite/skyitems/nodes/planetitemnode.cpp
new file mode 100644
index 0000000..673a2c5
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/planetitemnode.cpp
@@ -0,0 +1,30 @@
+#include "planetitemnode.h"
+#include "skymaplite.h"
+
+#include <QSGTexture>
+#include <QQuickWindow>
+
+PlanetItemNode::PlanetItemNode() {
+ genCachedTextures();
+}
+
+void PlanetItemNode::genCachedTextures() {
+ SkyMapLite* skyMap = SkyMapLite::Instance();
+ QVector<QVector<QPixmap*>> images = skyMap->getImageCache();
+
+ QQuickWindow *win = skyMap->window();
+
+ textureCache = QVector<QVector<QSGTexture*>> (images.length());
+
+ for(int i = 0; i < textureCache.length(); ++i) {
+ int length = images[i].length();
+ textureCache[i] = QVector<QSGTexture *>(length);
+ for(int c = 1; c < length; ++c) {
+ textureCache[i][c] = win->createTextureFromImage(images[i][c]->toImage());
+ }
+ }
+}
+
+QSGTexture* PlanetItemNode::getCachedTexture(int size, char spType) {
+ return textureCache[SkyMapLite::Instance()->harvardToIndex(spType)][size];
+}
diff --git a/kstars/kstarslite/skyitems/nodes/planetitemnode.h b/kstars/kstarslite/skyitems/nodes/planetitemnode.h
new file mode 100644
index 0000000..9e0ffc6
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/planetitemnode.h
@@ -0,0 +1,51 @@
+/** *************************************************************************
+ planetitemnode.h - K Desktop Planetarium
+ -------------------
+ begin : 05/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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 PLANETITEMNODE_H_
+#define PLANETITEMNODE_H_
+#include <QSGNode>
+
+class QSGSimpleTextureNode;
+class QImage;
+class PlanetNode;
+class QSGTexture;
+
+/** @class PlanetItemNode
+ *
+ * A QSGNode derived class used as a container for holding PlanetNodes. Upon construction
+ * PlanetItemNode generates all textures that are used by stars
+ *
+ *@short A container for PlanetNodes that holds collection of textures for stars
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class PlanetItemNode : public QSGNode {
+public:
+ PlanetItemNode();
+ /**
+ * @short returns cached texture from textureCache
+ * @return cached QSGTexture from textureCache
+ */
+ QSGTexture* getCachedTexture(int size, char spType);
+
+private:
+ /**
+ * @short initializes textureCache with cached images of stars in SkyMapLite
+ */
+ void genCachedTextures();
+ QVector<QVector<QSGTexture *>> textureCache;
+};
+#endif
diff --git a/kstars/kstarslite/skyitems/nodes/planetnode.cpp b/kstars/kstarslite/skyitems/nodes/planetnode.cpp
new file mode 100644
index 0000000..0675910
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/planetnode.cpp
@@ -0,0 +1,86 @@
+/** *************************************************************************
+ planetnode.h - K Desktop Planetarium
+ -------------------
+ begin : 05/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include <QSGSimpleTextureNode>
+#include <QImage>
+
+#include <QQuickWindow>
+#include "skymaplite.h"
+#include "ksplanetbase.h"
+
+#include "planetnode.h"
+
+
+PlanetNode::PlanetNode(KSPlanetBase* p, PlanetItemNode* parentNode)
+ :m_planetPic(new QSGSimpleTextureNode), m_planet(p), m_planetOpacity(new QSGOpacityNode)
+{
+ // Draw them as bright stars of appropriate color instead of images
+ char spType;
+ //FIXME: do these need i18n?
+ if( m_planet->name() == i18n("Mars") ) {
+ spType = 'K';
+ } else if( m_planet->name() == i18n("Jupiter") || m_planet->name() == i18n("Mercury") || m_planet->name() == i18n("Saturn") ) {
+ spType = 'F';
+ } else {
+ spType = 'B';
+ }
+
+ m_point = new PointNode(spType, parentNode);
+ appendChildNode(m_point);
+
+ appendChildNode(m_planetOpacity);
+ //Add planet to opacity node so that we could hide the planet
+ m_planetOpacity->appendChildNode(m_planetPic);
+ m_planetPic->setTexture(SkyMapLite::Instance()->window()->createTextureFromImage(
+ m_planet->image(), QQuickWindow::TextureCanUseAtlas));
+}
+
+void PlanetNode::setPointSize(float size) {
+ m_point->setSize(size);
+}
+
+void PlanetNode::setPlanetPicSize(float size) {
+ m_planetPic->setRect(QRect(0,0,size,size));
+ markDirty(QSGNode::DirtyGeometry);
+}
+
+void PlanetNode::showPoint() {
+ m_planetOpacity->setOpacity(0);
+ m_point->setOpacity(1);
+}
+
+void PlanetNode::showPlanetPic() {
+ m_point->setOpacity(0);
+ m_planetOpacity->setOpacity(1);
+}
+
+void PlanetNode::hide() {
+ m_point->setOpacity(0);
+ m_planetOpacity->setOpacity(0);
+}
+
+void PlanetNode::changePos(QPointF pos) {
+ //TODO: port it to transform matrix
+ /*QMatrix4x4 m (1,0,0,pos.x(),
+ 0,1,0,pos.y(),
+ 0,0,0,1,
+ 0,0,0,1);
+ setMatrix(m);
+ markDirty(QSGNode::DirtyMatrix);*/
+ m_planetPic->setRect(QRect(pos.x(),pos.y(),m_planetPic->rect().size().width(),m_planetPic->rect().size().width()));
+ m_point->changePos(pos);
+
+}
diff --git a/kstars/kstarslite/skyitems/nodes/planetnode.h b/kstars/kstarslite/skyitems/nodes/planetnode.h
new file mode 100644
index 0000000..a9f3964
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/planetnode.h
@@ -0,0 +1,88 @@
+/** *************************************************************************
+ planetnode.h - K Desktop Planetarium
+ -------------------
+ begin : 05/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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 PLANETNODE_H_
+#define PLANETNODE_H_
+#include <QSGNode>
+#include "pointnode.h"
+
+class QSGSimpleTextureNode;
+class QImage;
+class KSPlanetBase;
+class PlanetItemNode;
+
+/** @class PlanetNode
+ *
+ * A QSGNode derived class used as a container for holding two other nodes PointNode
+ * and QSGSimpleTextureNode that are displayed depending on the conditions (zoom level,
+ * user options)
+ *
+ *@short A container for PointNode and QSGSimpleTextureNode used for displaying planet
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class PlanetNode : public QSGTransformNode {
+public:
+ /**
+ * @brief Constructor
+ * @param planet used in PlanesItem to update position of PlanetNode
+ * @param parentNode used by PointNode to get textures from cache
+ */
+ PlanetNode(KSPlanetBase* planet, PlanetItemNode* parentNode);
+ /**
+ * @short setPointSize updates the size of m_point
+ * @param size new size of m_point
+ */
+ void setPointSize(float size);
+ /**
+ * @short setPlanetPicSize updates the size of m_planetPic
+ * @param size new size of m_planetPic
+ */
+ void setPlanetPicSize(float size);
+ /**
+ * @short makes m_planetPic invisible and m_point visible
+ */
+ void showPoint();
+ /**
+ * @short hides m_point and shows m_planetPic
+ */
+ void showPlanetPic();
+ /**
+ * @short hides both nodes
+ */
+ void hide();
+ /**
+ * @short changePos changes the position of both nodes
+ * @param pos new position
+ */
+ void changePos(QPointF pos);
+ /**
+ * @return the planet associated with this PlanetNode
+ */
+ inline KSPlanetBase* planet() { return m_planet; }
+private:
+ PointNode* m_point;
+
+ // This opacity node is used to hide m_planetPic. m_point is subclass of QSGOpacityNode so it needs
+ // no explicit opacity node here.
+ QSGOpacityNode* m_planetOpacity;
+ QSGSimpleTextureNode* m_planetPic;
+
+ KSPlanetBase* m_planet;
+};
+
+
+#endif
diff --git a/kstars/kstarslite/skyitems/nodes/pointnode.cpp b/kstars/kstarslite/skyitems/nodes/pointnode.cpp
new file mode 100644
index 0000000..f20b176
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/pointnode.cpp
@@ -0,0 +1,43 @@
+/** *************************************************************************
+ pointnode.h - K Desktop Planetarium
+ -------------------
+ begin : 05/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include <QImage>
+#include <QQuickWindow>
+
+#include "skymaplite.h"
+#include "pointnode.h"
+#include "planetitemnode.h"
+
+PointNode::PointNode(char sp, PlanetItemNode* p, float size)
+ :spType(sp), texture(new QSGSimpleTextureNode), parentNode(p)
+{
+ appendChildNode(texture);
+ setSize(size);
+}
+
+void PointNode::setSize(float size) {
+ int isize = qMin(static_cast<int>(size), 14);
+ texture->setTexture(parentNode->getCachedTexture(isize, spType));
+
+ QSize tSize = texture->texture()->textureSize();
+ QRectF oldRect = texture->rect();
+ texture->setRect(QRect(oldRect.x(),oldRect.y(),tSize.width(),tSize.height()));
+}
+
+void PointNode::changePos(QPointF pos) {
+ QRectF oldRect = texture->rect();
+ texture->setRect(QRect(pos.x(),pos.y(),oldRect.width(),oldRect.height()));
+}
diff --git a/kstars/kstarslite/skyitems/nodes/pointnode.h b/kstars/kstarslite/skyitems/nodes/pointnode.h
new file mode 100644
index 0000000..7567bfe
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/pointnode.h
@@ -0,0 +1,58 @@
+/** *************************************************************************
+ pointnode.h - K Desktop Planetarium
+ -------------------
+ begin : 05/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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 POINTNODE_H_
+#define POINTNODE_H_
+#include <QSGSimpleTextureNode>
+
+class PlanetItemNode;
+
+/** @class PointNode
+ *
+ * A QSGSimpleTextureNode derived class used for representing stars and planets as stars. Upon
+ * construction loads the texture of star, cached as a QPixmap in SkyMapLite
+ *
+ *@short QSGSimpleTextureNode derived class that represents stars and planets using cached QPixmap
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class PointNode : public QSGOpacityNode {
+public:
+ /**
+ * @short Constructor
+ * @param spType spectral type
+ * @param parentNode pointer to top parent node, which holds texture cache
+ * @param size initial size of PointNode
+ */
+ PointNode(char spType, PlanetItemNode* parentNode, float size = 1);
+ /**
+ * @short setSize update size of PointNode with the given parameter
+ * @param size new size of PointNode
+ */
+ void setSize(float size);
+ /**
+ * @short changePos changes position of PointNode to the one specified by pos
+ * @param pos new position
+ */
+ void changePos(QPointF pos);
+private:
+ char spType;
+ QSGSimpleTextureNode *texture;
+ // This pointer is important because parentNode holds texture cache
+ PlanetItemNode* parentNode;
+};
+
+#endif
diff --git a/kstars/kstarslite/skyitems/planetsitem.cpp b/kstars/kstarslite/skyitems/planetsitem.cpp
new file mode 100644
index 0000000..4aa67a8
--- /dev/null
+++ b/kstars/kstarslite/skyitems/planetsitem.cpp
@@ -0,0 +1,132 @@
+/** *************************************************************************
+ PlanetsItem.cpp - K Desktop Planetarium
+ -------------------
+ begin : 02/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "planetsitem.h"
+#include "projections/projector.h"
+#include "solarsystemsinglecomponent.h"
+#include "ksplanet.h"
+
+#include <QSGSimpleTextureNode>
+#include <QQuickWindow>
+#include "nodes/planetnode.h"
+#include "nodes/planetitemnode.h"
+
+#include "Options.h"
+
+
+#include <QSGSimpleRectNode>
+
+PlanetsItem::PlanetsItem(QQuickItem* parent)
+ :SkyItem(parent)
+{
+ const SkyMapLite* skyMapLite = map();
+ connect(skyMapLite, &SkyMapLite::zoomChanged, this, &QQuickItem::update);
+}
+
+void PlanetsItem::addPlanet(SolarSystemSingleComponent* planetComp) {
+ if(!m_planetComponents.contains(planetComp) && !m_toAdd.contains(planetComp))
+ m_toAdd.append(planetComp);
+}
+
+QSGNode* PlanetsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
+ PlanetItemNode *n = static_cast<PlanetItemNode*>(oldNode);
+ QRectF rect = boundingRect();
+
+ if (rect.isEmpty()) {
+ delete n;
+ return 0;
+ }
+
+ if(!n) {
+ n = new PlanetItemNode; // If no PlanetItemNode exists create one
+ int pCompLen = m_planetComponents.length();
+ if(pCompLen > 0) {
+ /* If there are some planets that have been already displayed once then recreate them
+ in new instance of PlanetItemNode*/
+ for(int i = 0; i < pCompLen; ++i) {
+ n->appendChildNode(new PlanetNode(m_planetComponents[i]->planet(), n));
+ }
+ }
+ }
+
+ int addLength = m_toAdd.length();
+ if(addLength > 0) { // If there are some new planets to add
+ for(int i = 0; i < addLength; ++i) {
+ m_planetComponents.append(m_toAdd[i]);
+ n->appendChildNode(new PlanetNode(m_toAdd[i]->planet(), n));
+ }
+ m_toAdd.clear();
+ }
+
+ //Traverse all children nodes of PlanetItemNode
+ for(int i = 0; i < n->childCount(); ++i) {
+ PlanetNode* pNode = static_cast<PlanetNode*>(n->childAtIndex(i));
+ KSPlanetBase* planet = pNode->planet();
+
+ if( !projector()->checkVisibility(planet) ) {
+ pNode->hide();
+ continue;
+ }
+
+ bool visible = false;
+ QPointF pos = projector()->toScreen(planet,true,&visible);
+ if( !visible || !projector()->onScreen(pos) ) {
+ pNode->hide();
+ continue;
+ }
+
+ float fakeStarSize = ( 10.0 + log10( Options::zoomFactor() ) - log10( MINZOOM ) ) * ( 10 - planet->mag() ) / 10;
+ if( fakeStarSize > 15.0 )
+ fakeStarSize = 15.0;
+
+ float size = planet->angSize() * dms::PI * Options::zoomFactor()/10800.0;
+ if( size < fakeStarSize && planet->name() != "Sun" && planet->name() != "Moon" ) {
+ pNode->setPointSize(fakeStarSize);
+ pNode->changePos(pos);
+ pNode->showPoint();
+ } else {
+ float sizemin = 1.0;
+ if( planet->name() == "Sun" || planet->name() == "Moon" )
+ sizemin = 8.0;
+
+ float size = planet->angSize() * dms::PI * Options::zoomFactor()/10800.0;
+ if( size < sizemin )
+ size = sizemin;
+
+ if( Options::showPlanetImages() && !planet->image().isNull() ) {
+ //Because Saturn has rings, we inflate its image size by a factor 2.5
+ if( planet->name() == "Saturn" )
+ size = int(2.5*size);
+ // Scale size exponentially so it is visible at large zooms
+ else if (planet->name() == "Pluto")
+ size = int(size*exp(1.5*size));
+
+ /*save();
+ translate(pos);
+ rotate( projector()->findPA( planet, pos.x(), pos.y() ) );
+ drawImage( QRect(-0.5*size, -0.5*size, size, size),
+ planet->image() );
+ restore();*/
+ pNode->setPlanetPicSize(size);
+ pNode->changePos(pos);
+ pNode->showPlanetPic();
+ } else { //Otherwise, draw a simple circle.
+ //drawEllipse( pos, size, size );
+ }
+ }
+ }
+ return n;
+}
diff --git a/kstars/kstarslite/skyitems/planetsitem.h b/kstars/kstarslite/skyitems/planetsitem.h
new file mode 100644
index 0000000..00ef613
--- /dev/null
+++ b/kstars/kstarslite/skyitems/planetsitem.h
@@ -0,0 +1,42 @@
+/** *************************************************************************
+ planetsitems.h - K Desktop Planetarium
+ -------------------
+ begin : 02/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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 PLANETSITEM_H_
+#define PLANETSITEM_H_
+
+#include "skyitem.h"
+
+class SolarSystemSingleComponent;
+
+
+class PlanetsItem : public SkyItem {
+public:
+ PlanetsItem(QQuickItem* parent = 0);
+ /** Adds an object of type SolarSystemSingleComponent to QList m_toAdd. In the next call to
+ * updatePaintNode() the object of type PlanetNode will be created and planetComponent
+ * will be moved to m_planetComponents. PlanetNode represents graphically KSPlanetBase on SkyMapLite.
+ * This function should be called whenever an object of class SolarSystemSingleComponent is
+ * created.
+ *
+ * @param SolarSystemSingleComponent that should be displayed on SkyMapLite
+ */
+ void addPlanet(SolarSystemSingleComponent* planetComp);
+protected:
+ virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+private:
+ QList<SolarSystemSingleComponent*> m_planetComponents;
+ QList<SolarSystemSingleComponent*> m_toAdd;
+};
+#endif
diff --git a/kstars/kstarslite/skyitems/skyitem.cpp b/kstars/kstarslite/skyitems/skyitem.cpp
new file mode 100644
index 0000000..4692101
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skyitem.cpp
@@ -0,0 +1,34 @@
+/** *************************************************************************
+ skyitem.cpp - K Desktop Planetarium
+ -------------------
+ begin : 02/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#include "skyitem.h"
+#include "../../skymaplite.h"
+
+SkyItem::SkyItem(QQuickItem* parent)
+ :QQuickItem(parent), m_skyMapLite(SkyMapLite::Instance())
+{
+ setFlag(ItemHasContents, true);
+ //TODO: Dirty hack to allow call to updatePaintNode
+ // Whenever the parent's dimensions changed, change dimensions of this item too
+ connect(parent, &QQuickItem::widthChanged, this, &SkyItem::resizeItem);
+ connect(parent, &QQuickItem::heightChanged, this, &SkyItem::resizeItem);
+ setWidth(1);
+ setHeight(1);
+}
+
+void SkyItem::resizeItem() {
+ setWidth(parentItem()->width());
+ setHeight(parentItem()->height());
+}
diff --git a/kstars/kstarslite/skyitems/skyitem.h b/kstars/kstarslite/skyitems/skyitem.h
new file mode 100644
index 0000000..68482ca
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skyitem.h
@@ -0,0 +1,84 @@
+/** *************************************************************************
+ skyitem.h - K Desktop Planetarium
+ -------------------
+ begin : 02/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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 SKYITEM_H_
+#define SKYITEM_H_
+
+#include <QSGNode>
+#include <QQuickItem>
+#include "skymaplite.h"
+
+class SkyComponent;
+class Projector;
+class SkyMapLite;
+class QQuickItem;
+
+/** @class SkyItem
+ *
+ *This is an interface for implementing SkyItems that are used to display SkyComponent
+ *derived objects on the SkyMapLite.
+ *
+ *@short A base class that is used for displaying SkyComponents on SkyMapLite.
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class SkyItem : public QQuickItem {
+
+ Q_OBJECT
+
+protected:
+ /**
+ *Constructor, initializes m_parentComponent (a pointer to SkyComponent, which asked to initialize
+ * this SkyItem).
+ *
+ * @param parent a pointer to SkyItem's data and visual parent
+ */
+ /* @param parentComponent a pointer to SkyComponent, which asked to initialize this SkyItem*/
+
+ explicit SkyItem(QQuickItem* parent = 0);
+
+public:
+ /** @short short function that returns pointer to the current projector
+ * @return pointer to current projector of SkyMapLite
+ */
+ inline const Projector* projector() { return SkyMapLite::Instance()->projector(); }
+
+ /** @short short function for safe access to SkyMapLite
+ * @return pointer to instance of SkyMapLite class
+ */
+ inline const SkyMapLite* map() { return m_skyMapLite; }
+ /* @short Get the component that asked to instantiate this SkyItem
+ *
+ *@return a pointer to the parent component.
+
+ SkyComponent* getParentComponent() const { return m_parentComponent; }
+ */
+ /*/** @short Set the m_parentComponent pointer to the argument.
+ *@param component pointer to the SkyComponent derived object to be assigned as the m_parentComponent
+ void setParentComponent( SkyComponent *component ) { m_parentComponent = component; } */
+
+public slots:
+ /** Called whenever parent's width or height are changed.
+ */
+ void resizeItem();
+
+private:
+ SkyMapLite* m_skyMapLite;
+ //SkyComponent* m_parentComponent;
+};
+
+#endif
diff --git a/kstars/kstarsliteinit.cpp b/kstars/kstarsliteinit.cpp
new file mode 100644
index 0000000..f1d30eb
--- /dev/null
+++ b/kstars/kstarsliteinit.cpp
@@ -0,0 +1,119 @@
+#include "kstarslite.h"
+#include "skymaplite.h"
+#include "kstarsdata.h"
+
+#include "skycomponents/skymapcomposite.h"
+
+#include "Options.h"
+
+void KStarsLite::datainitFinished() {
+ //Time-related connections
+ connect( data()->clock(), SIGNAL( timeAdvanced() ),
+ this, SLOT( updateTime() ) );
+ connect( data()->clock(), SIGNAL( timeChanged() ),
+ this, SLOT( updateTime() ) );
+
+ //Add GUI elements to main window
+ //buildGUI();
+
+ connect( data()->clock(), SIGNAL( scaleChanged( float ) ),
+ map(), SLOT( slotClockSlewing() ) );
+
+ connect( data(), SIGNAL(skyUpdate(bool)), map(), SLOT( forceUpdateNow() ) );
+ //connect( m_TimeStepBox, SIGNAL( scaleChanged(float) ), data(), SLOT( setTimeDirection( float ) ) );
+ //connect( m_TimeStepBox, SIGNAL( scaleChanged(float) ), data()->clock(), SLOT( setClockScale( float )) );
+ //connect( m_TimeStepBox, SIGNAL( scaleChanged(float) ), map(), SLOT( setFocus() ) );
+
+ //Do not start the clock if "--paused" specified on the cmd line
+ if ( StartClockRunning ) data()->clock()->start();
+
+ //Propagate config settings
+ // applyConfig( false );
+
+ //Initialize focus
+ initFocus();
+
+ data()->setFullTimeUpdate();
+ updateTime();
+
+ //If this is the first startup, show the wizard
+ if ( Options::runStartupWizard() ) {
+ }
+
+ //DEBUG
+ qDebug() << "The current Date/Time is: " << KStarsDateTime::currentDateTime().toString();
+
+ //Notify Splash in QML that loading of data is finished
+ dataLoadFinished();
+}
+
+void KStarsLite::initFocus() {
+ //Case 1: tracking on an object
+ if ( Options::isTracking() && Options::focusObject() != i18n("nothing") ) {
+ SkyObject *oFocus;
+ if ( Options::focusObject() == i18n("star") ) {
+ SkyPoint p( Options::focusRA(), Options::focusDec() );
+ double maxrad = 1.0;
+
+ oFocus = data()->skyComposite()->starNearest( &p, maxrad );
+ } else {
+ oFocus = data()->objectNamed( Options::focusObject() );
+ }
+
+ if ( oFocus ) {
+ map()->setFocusObject( oFocus );
+ map()->setClickedObject( oFocus );
+ map()->setFocusPoint( oFocus );
+ } else {
+ qWarning() << "Cannot center on "
+ << Options::focusObject()
+ << ": no object found." << endl;
+ }
+
+ //Case 2: not tracking, and using Alt/Az coords. Set focus point using
+ //FocusRA as the Azimuth, and FocusDec as the Altitude
+ } else if ( ! Options::isTracking() && Options::useAltAz() ) {
+ SkyPoint pFocus;
+ pFocus.setAz( Options::focusRA() );
+ pFocus.setAlt( Options::focusDec() );
+ pFocus.HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
+ map()->setFocusPoint( &pFocus );
+
+ //Default: set focus point using FocusRA as the RA and
+ //FocusDec as the Dec
+ } else {
+ SkyPoint pFocus( Options::focusRA(), Options::focusDec() );
+ pFocus.EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
+ map()->setFocusPoint( &pFocus );
+ }
+ data()->setSnapNextFocus();
+ map()->setDestination( *map()->focusPoint() );
+ map()->setFocus( map()->destination() );
+
+ //map()->showFocusCoords();
+
+ //Check whether initial position is below the horizon.
+ if ( Options::useAltAz() && Options::showGround() &&
+ map()->focus()->alt().Degrees() < -1.0 ) {
+ QString caption = i18n( "Initial Position is Below Horizon" );
+ QString message = i18n( "The initial position is below the horizon.\nWould you like to reset to the default position?" );
+ map()->setClickedObject( NULL );
+ map()->setFocusObject( NULL );
+ Options::setIsTracking( false );
+
+ data()->setSnapNextFocus(true);
+
+ SkyPoint DefaultFocus;
+ DefaultFocus.setAz( 180.0 );
+ DefaultFocus.setAlt( 45.0 );
+ DefaultFocus.HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
+ map()->setDestination( DefaultFocus );
+ }
+
+//If there is a focusObject() and it is a SS body, add a temporary Trail
+/*if ( map()->focusObject() && map()->focusObject()->isSolarSystem()
+ && Options::useAutoTrail() ) {
+ ((KSPlanetBase*)map()->focusObject())->addToTrail();
+ data()->temporaryTrail = true;
+ }*/
+}
diff --git a/kstars/main.cpp b/kstars/main.cpp
index 3ef3f14..428b8c5 100644
--- a/kstars/main.cpp
+++ b/kstars/main.cpp
@@ -25,16 +25,22 @@
#include <KCrash>
#include <KLocalizedString>
+#ifdef KSTARS_LITE
+#include "kstarslite.h"
#include "kstars.h"
+#include "skymap.h"
+#endif
+
#include "kstarsdata.h"
#include "kstarsdatetime.h"
-#include "skymap.h"
#include "simclock.h"
#include "ksnumbers.h"
#include "version.h"
#include "Options.h"
+
+
static const char description[] =
I18N_NOOP("Desktop Planetarium");
static const char notice[] =
@@ -221,7 +227,10 @@ int main(int argc, char *argv[])
QDir writableDir;
writableDir.mkdir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
- KStars::createInstance( true, ! parser.isSet( "paused" ), datestring );
+#ifdef KSTARS_LITE
+ KStarsLite::createInstance( true, ! parser.isSet( "paused" ), datestring );
+#else
+ KStars::createInstance( true, ! parser.isSet( "paused" ), datestring );
// no session.. just start up normally
const QStringList urls = parser.positionalArguments();
@@ -238,6 +247,7 @@ int main(int argc, char *argv[])
KStars::Instance()->openFITS(u);
}
}
+#endif
QObject::connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));
return app.exec();
diff --git a/kstars/projections/projector.cpp b/kstars/projections/projector.cpp
index 205bde7..c3abc49 100644
--- a/kstars/projections/projector.cpp
+++ b/kstars/projections/projector.cpp
@@ -277,7 +277,11 @@ QVector< Vector2f > Projector::groundPoly(SkyPoint* labelpoint, bool *drawLabel)
double daz = 90.;
if ( m_vp.useAltAz ) {
daz = 0.5*m_vp.width*57.3/m_vp.zoomFactor; //center to edge, in degrees
- if ( type() == SkyMap::Orthographic ) {
+ #if 0
+ if ( type() == SkyMapLite::Orthographic ) {
+ #else
+ if ( type() == SkyMap::Orthographic ) {
+ #endif
daz = daz * 1.4;
}
daz = qMin(qreal(90.0), daz);
@@ -327,7 +331,11 @@ QVector< Vector2f > Projector::groundPoly(SkyPoint* labelpoint, bool *drawLabel)
//In Gnomonic projection, or if sufficiently zoomed in, we can complete
//the ground polygon by simply adding offscreen points
//FIXME: not just gnomonic
+ #if 0
+ if ( daz < 25.0 || type() == SkyMapLite::Gnomonic) {
+ #else
if ( daz < 25.0 || type() == SkyMap::Gnomonic) {
+ #endif
ground.append( Vector2f( m_vp.width + 10.f, ground.last().y() ) );
ground.append( Vector2f( m_vp.width + 10.f, m_vp.height + 10.f ) );
ground.append( Vector2f( -10.f, m_vp.height + 10.f ) );
diff --git a/kstars/projections/projector.h b/kstars/projections/projector.h
index 8b80b40..abb358f 100644
--- a/kstars/projections/projector.h
+++ b/kstars/projections/projector.h
@@ -29,6 +29,10 @@ using namespace Eigen;
#include <QPointF>
#include "skyobjects/skypoint.h"
+#ifdef KSTARS_LITE
+#include "skymaplite.h"
+#endif
+
#include "skymap.h"
class KStarsData;
@@ -64,7 +68,11 @@ public:
void setViewParams( const ViewParams& p );
/** Return the type of this projection */
+ #if 0
+ virtual SkyMapLite::Projection type() const = 0;
+ #else
virtual SkyMap::Projection type() const = 0;
+ #endif
/** Return the FOV of this projection */
double fov() const;
diff --git a/kstars/skycomponents/solarsystemsinglecomponent.cpp b/kstars/skycomponents/solarsystemsinglecomponent.cpp
index 5db10ae..a5e8ebd 100644
--- a/kstars/skycomponents/solarsystemsinglecomponent.cpp
+++ b/kstars/skycomponents/solarsystemsinglecomponent.cpp
@@ -25,7 +25,13 @@
#include "skyobjects/starobject.h"
#include "skyobjects/ksplanetbase.h"
#include "skyobjects/ksplanet.h"
+#ifdef KSTARS_LITE
+#include "skymaplite.h"
+#include "kstarslite/skyitems/planetsitem.h"
+#else
#include "skymap.h"
+#endif
+
#include "Options.h"
#include "skylabeler.h"
@@ -43,6 +49,10 @@ SolarSystemSingleComponent::SolarSystemSingleComponent(SolarSystemComposite *par
objectNames(m_Planet->type()).append( m_Planet->name() );
if ( ! m_Planet->longname().isEmpty() && m_Planet->longname() != m_Planet->name() )
objectNames(m_Planet->type()).append( m_Planet->longname() );
+ //Draw planet on the SkyMapLite
+ #ifdef KSTARS_LITE
+ SkyMapLite::Instance()->addPlanetItem(this);
+ #endif
}
SolarSystemSingleComponent::~SolarSystemSingleComponent()
@@ -101,7 +111,6 @@ void SolarSystemSingleComponent::draw( SkyPainter *skyp ) {
SkyLabeler::AddLabel( m_Planet, SkyLabeler::PLANET_LABEL );
}
-
void SolarSystemSingleComponent::drawTrails( SkyPainter *skyp ) {
if( selected() )
m_Planet->drawTrail(skyp);
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
new file mode 100644
index 0000000..7bb4c0b
--- /dev/null
+++ b/kstars/skymaplite.cpp
@@ -0,0 +1,412 @@
+/** *************************************************************************
+ skymaplite.cpp - K Desktop Planetarium
+ -------------------
+ begin : 30/04/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "skymaplite.h"
+#include "kstarsdata.h"
+#include "kstarslite.h"
+
+#include "projections/projector.h"
+#include "projections/lambertprojector.h"
+#include "solarsystemsinglecomponent.h"
+#include "Options.h"
+
+#include "kstarslite/skyitems/planetsitem.h"
+#include "ksplanetbase.h"
+#include "ksutils.h"
+
+#include <QSGSimpleRectNode>
+#include <QSGNode>
+#include <QBitmap>
+
+namespace {
+
+ // Draw bitmap for zoom cursor. Width is size of pen to draw with.
+ QBitmap zoomCursorBitmap(int width) {
+ QBitmap b(32, 32);
+ b.fill(Qt::color0);
+ int mx = 16, my = 16;
+ // Begin drawing
+ QPainter p;
+ p.begin( &b );
+ p.setPen( QPen( Qt::color1, width ) );
+ p.drawEllipse( mx - 7, my - 7, 14, 14 );
+ p.drawLine( mx + 5, my + 5, mx + 11, my + 11 );
+ p.end();
+ return b;
+ }
+
+ // Draw bitmap for default cursor. Width is size of pen to draw with.
+ QBitmap defaultCursorBitmap(int width) {
+ QBitmap b(32, 32);
+ b.fill(Qt::color0);
+ int mx = 16, my = 16;
+ // Begin drawing
+ QPainter p;
+ p.begin( &b );
+ p.setPen( QPen( Qt::color1, width ) );
+ // 1. diagonal
+ p.drawLine (mx - 2, my - 2, mx - 8, mx - 8);
+ p.drawLine (mx + 2, my + 2, mx + 8, mx + 8);
+ // 2. diagonal
+ p.drawLine (mx - 2, my + 2, mx - 8, mx + 8);
+ p.drawLine (mx + 2, my - 2, mx + 8, mx - 8);
+ p.end();
+ return b;
+ }
+}
+
+SkyMapLite *SkyMapLite::pinstance = 0;
+
+int SkyMapLite::starColorMode = 0;
+
+SkyMapLite::SkyMapLite(QQuickItem* parent)
+ :QQuickItem(parent), m_proj(0), count(0), data(KStarsData::Instance()),
+ nStarSizes(15), nSPclasses(7), m_planetsItem(new PlanetsItem(this))
+{
+ setAcceptHoverEvents(true);
+ setAcceptedMouseButtons(Qt::AllButtons);
+ setFlag(ItemHasContents, true);
+
+ // Whenever the wrapper's(parent) dimensions changed, change SkyMapLite too
+ connect(parent, &QQuickItem::widthChanged, this, &SkyMapLite::resizeItem);
+ connect(parent, &QQuickItem::heightChanged, this, &SkyMapLite::resizeItem);
+
+ //Initialize images for stars
+ initStarImages();
+ // Set pinstance to yourself
+ pinstance = this;
+}
+
+SkyMapLite* SkyMapLite::createInstance(QQuickItem* parent) {
+ delete pinstance;
+ pinstance = new SkyMapLite(parent);
+ return pinstance;
+}
+
+SkyMapLite::~SkyMapLite() {
+
+}
+
+void SkyMapLite::setFocus( SkyPoint *p ) {
+ setFocus( p->ra(), p->dec() );
+}
+
+void SkyMapLite::setFocus( const dms &ra, const dms &dec ) {
+ Options::setFocusRA( ra.Hours() );
+ Options::setFocusDec( dec.Degrees() );
+
+ focus()->set( ra, dec );
+ focus()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+}
+
+void SkyMapLite::setFocusAltAz( const dms &alt, const dms &az) {
+ Options::setFocusRA( focus()->ra().Hours() );
+ Options::setFocusDec( focus()->dec().Degrees() );
+ focus()->setAlt(alt);
+ focus()->setAz(az);
+ focus()->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
+
+ slewing = false;
+ forceUpdate(); //need a total update, or slewing with the arrow keys doesn't work.
+}
+
+void SkyMapLite::setDestination( const SkyPoint& p ) {
+ setDestination( p.ra(), p.dec() );
+}
+
+void SkyMapLite::setDestination( const dms &ra, const dms &dec ) {
+ destination()->set( ra, dec );
+ destination()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ emit destinationChanged();
+}
+
+void SkyMapLite::setDestinationAltAz( const dms &alt, const dms &az) {
+ destination()->setAlt(alt);
+ destination()->setAz(az);
+ destination()->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
+ emit destinationChanged();
+}
+
+void SkyMapLite::setClickedPoint( SkyPoint *f ) {
+ ClickedPoint = *f;
+}
+
+void SkyMapLite::setClickedObject( SkyObject *o ) {
+ ClickedObject = o;
+}
+
+void SkyMapLite::setFocusObject( SkyObject *o ) {
+ FocusObject = o;
+ if ( FocusObject )
+ Options::setFocusObject( FocusObject->name() );
+ else
+ Options::setFocusObject( i18n( "nothing" ) );
+}
+
+
+/*void SkyMapLite::updateFocus() {
+ if( slewing )
+ return;
+
+ //Tracking on an object
+ if ( Options::isTracking() && focusObject() != NULL ) {
+ if ( Options::useAltAz() ) {
+ //Tracking any object in Alt/Az mode requires focus updates
+ focusObject()->EquatorialToHorizontal(data->lst(), data->geo()->lat());
+ setFocusAltAz( focusObject()->altRefracted(), focusObject()->az() );
+ focus()->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
+ setDestination( *focus() );
+ } else {
+ //Tracking in equatorial coords
+ setFocus( focusObject() );
+ focus()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ setDestination( *focus() );
+ }
+
+ //Tracking on empty sky
+ } else if ( Options::isTracking() && focusPoint() != NULL ) {
+ if ( Options::useAltAz() ) {
+ //Tracking on empty sky in Alt/Az mode
+ setFocus( focusPoint() );
+ focus()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ setDestination( *focus() );
+ }
+
+ // Not tracking and not slewing, let sky drift by
+ // This means that horizontal coordinates are constant.
+ } else {
+ focus()->HorizontalToEquatorial(data->lst(), data->geo()->lat() );
+ }
+}*/
+
+void SkyMapLite::addPlanetItem(SolarSystemSingleComponent* parentComp) {
+ m_planetsItem->addPlanet(parentComp);
+}
+
+void SkyMapLite::resizeItem() {
+ setWidth(parentItem()->width());
+ setHeight(parentItem()->height());
+ forceUpdate();
+}
+
+void SkyMapLite::slotZoomIn() {
+ setZoomFactor( Options::zoomFactor() * DZOOM );
+}
+
+void SkyMapLite::slotZoomOut() {
+ setZoomFactor( Options::zoomFactor() / DZOOM );
+}
+
+void SkyMapLite::slotZoomDefault() {
+ setZoomFactor( DEFAULTZOOM );
+}
+
+void SkyMapLite::setZoomFactor(double factor) {
+ Options::setZoomFactor( KSUtils::clamp(factor, MINZOOM, MAXZOOM) );
+ forceUpdate();
+ emit zoomChanged();
+}
+
+void SkyMapLite::forceUpdate() {
+ setupProjector();
+ m_planetsItem->update();
+}
+
+void SkyMapLite::setupProjector() {
+ //Update View Parameters for projection
+ ViewParams p;
+ p.focus = focus();
+ p.height = height();
+ p.width = width();
+ p.useAltAz = Options::useAltAz();
+ p.useRefraction = Options::useRefraction();
+ p.zoomFactor = Options::zoomFactor();
+ p.fillGround = Options::showGround();
+ if(!m_proj) m_proj = new LambertProjector(p);
+ else m_proj->setViewParams(p);
+ //Check if we need a new projector
+ /*if( m_proj && Options::projection() == m_proj->type() )
+ m_proj->setViewParams(p);
+ else {
+ delete m_proj;
+ switch( Options::projection() ) {
+ case Gnomonic:
+ m_proj = new GnomonicProjector(p);
+ break;
+ case Stereographic:
+ m_proj = new StereographicProjector(p);
+ break;
+ case Orthographic:
+ m_proj = new OrthographicProjector(p);
+ break;
+ case AzimuthalEquidistant:
+ m_proj = new AzimuthalEquidistantProjector(p);
+ break;
+ case Equirectangular:
+ m_proj = new EquirectangularProjector(p);
+ break;
+ case Lambert: default:
+ //TODO: implement other projection classes
+ m_proj = new LambertProjector(p);
+ break;
+ }
+ }*/
+}
+
+void SkyMapLite::setZoomMouseCursor()
+{
+ mouseMoveCursor = false; // no mousemove cursor
+ QBitmap cursor = zoomCursorBitmap(2);
+ QBitmap mask = zoomCursorBitmap(4);
+ setCursor( QCursor(cursor, mask) );
+}
+
+void SkyMapLite::setDefaultMouseCursor()
+{
+ mouseMoveCursor = false; // no mousemove cursor
+ QBitmap cursor = defaultCursorBitmap(2);
+ QBitmap mask = defaultCursorBitmap(3);
+ setCursor( QCursor(cursor, mask) );
+}
+
+void SkyMapLite::setMouseMoveCursor()
+{
+ if (mouseButtonDown)
+ {
+ setCursor(Qt::SizeAllCursor); // cursor shape defined in qt
+ mouseMoveCursor = true;
+ }
+}
+
+int SkyMapLite::harvardToIndex(char c) {
+ // Convert spectral class to numerical index.
+ // If spectral class is invalid return index for white star (A class)
+
+ switch( c ) {
+ case 'o': case 'O': return 0;
+ case 'b': case 'B': return 1;
+ case 'a': case 'A': return 2;
+ case 'f': case 'F': return 3;
+ case 'g': case 'G': return 4;
+ case 'k': case 'K': return 5;
+ case 'm': case 'M': return 6;
+ // For unknown spectral class assume A class (white star)
+ default: return 2;
+ }
+}
+
+QVector<QVector<QPixmap*>> SkyMapLite::getImageCache()
+{
+ return imageCache;
+}
+
+void SkyMapLite::initStarImages()
+{
+ imageCache = QVector<QVector<QPixmap*>>(nSPclasses);
+
+ QMap<char, QColor> ColorMap;
+ const int starColorIntensity = Options::starColorIntensity();
+
+ switch( Options::starColorMode() ) {
+ case 1: // Red stars.
+ ColorMap.insert( 'O', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
+ break;
+ case 2: // Black stars.
+ ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 0, 0, 0 ) );
+ break;
+ case 3: // White stars
+ ColorMap.insert( 'O', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 255, 255, 255 ) );
+ case 0: // Real color
+ default: // And use real color for everything else
+ ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 255 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 0, 200, 255 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 0, 255, 255 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 200, 255, 100 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 0 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 255, 100, 0 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
+ }
+
+ foreach( char color, ColorMap.keys() ) {
+ //Add new spectral class
+
+ QPixmap BigImage( 15, 15 );
+ BigImage.fill( Qt::transparent );
+
+ QPainter p;
+ p.begin( &BigImage );
+
+ if ( Options::starColorMode() == 0 ) {
+ qreal h, s, v, a;
+ p.setRenderHint( QPainter::Antialiasing, false );
+ QColor starColor = ColorMap[color];
+ starColor.getHsvF(&h, &s, &v, &a);
+ for (int i = 0; i < 8; i++ ) {
+ for (int j = 0; j < 8; j++ ) {
+ qreal x = i - 7;
+ qreal y = j - 7;
+ qreal dist = sqrt( x*x + y*y ) / 7.0;
+ starColor.setHsvF(h,
+ qMin( qreal(1), dist < (10-starColorIntensity)/10.0 ? 0 : dist ),
+ v,
+ qMax( qreal(0), dist < (10-starColorIntensity)/20.0 ? 1 : 1-dist ) );
+ p.setPen( starColor );
+ p.drawPoint( i, j );
+ p.drawPoint( 14-i, j );
+ p.drawPoint( i, 14-j );
+ p.drawPoint (14-i, 14-j);
+ }
+ }
+ } else {
+ p.setRenderHint(QPainter::Antialiasing, true );
+ p.setPen( QPen(ColorMap[color], 2.0 ) );
+ p.setBrush( p.pen().color() );
+ p.drawEllipse( QRectF( 2, 2, 10, 10 ) );
+ }
+ p.end();
+//[nSPclasses][nStarSizes];
+ // Cache array slice
+
+ QVector<QPixmap *> pmap = imageCache[ harvardToIndex(color) ];
+ pmap.append(new QPixmap());
+ for( int size = 1; size < nStarSizes; size++ ) {
+ //if( !pmap[size] ) {
+ pmap.append(new QPixmap());
+ *pmap[size] = BigImage.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
+ //}
+ }
+ imageCache[ harvardToIndex(color) ] = pmap;
+ }
+ starColorMode = Options::starColorMode();
+}
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
new file mode 100644
index 0000000..34d300a
--- /dev/null
+++ b/kstars/skymaplite.h
@@ -0,0 +1,571 @@
+/** *************************************************************************
+ skymaplite.h - K Desktop Planetarium
+ -------------------
+ begin : 30/04/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * 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 SKYMAPLITE_H_
+#define SKYMAPLITE_H_
+
+#include "skyobjects/skypoint.h"
+#include "skyobjects/skyline.h"
+
+#include <QTimer>
+
+#include <config-kstars.h>
+#include <QQuickItem>
+
+class dms;
+class KStarsData;
+class SkyObject;
+class Projector;
+class SolarSystemSingleComponent;
+class PlanetsItem;
+
+/** @class SkyMapLite
+ *
+ *This is the main item that displays all SkyItems. After its instantiation it is reparanted
+ *to an object with objectName SkyMapLiteWrapper in main.qml. To display SkyItems they are reparanted
+ *to instance of SkyMapLite.
+ *
+ *SkyMapLite handles most user interaction events (both mouse and keyboard).
+ *
+ *@short Item for displaying sky objects; also handles user interaction events.
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class SkyMapLite : public QQuickItem {
+
+ Q_OBJECT
+
+protected:
+ /**
+ *Constructor.
+ */
+ explicit SkyMapLite(QQuickItem* parent = 0);
+
+ //virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
+
+public:
+ static SkyMapLite* createInstance(QQuickItem* parent = 0);
+
+ static SkyMapLite* Instance() { return pinstance; }
+
+ /*enum Projection { Lambert,
+ AzimuthalEquidistant,
+ Orthographic,
+ Equirectangular,
+ Stereographic,
+ Gnomonic,
+ UnknownProjection };*/
+
+ //static bool IsSlewing() { return pinstance->isSlewing(); }
+
+ /** Destructor (empty) */
+ ~SkyMapLite();
+
+ /*enum Projection { Lambert,
+ AzimuthalEquidistant,
+ Orthographic,
+ Equirectangular,
+ Stereographic,
+ Gnomonic,
+ UnknownProjection };*/
+
+ /** @short Retrieve the Focus point; the position on the sky at the
+ *center of the skymap.
+ *@return a pointer to the central focus point of the sky map
+ */
+
+ /** @return the angular field of view of the sky map, in degrees.
+ *@note it must use either the height or the width of the window to calculate the
+ *FOV angle. It chooses whichever is larger.
+ */
+ //float fov();
+
+ /** @short Update the focus position according to current options. */
+ //void updateFocus();
+
+ /** @short Retrieve the Focus point; the position on the sky at the
+ *center of the skymap.
+ *@return a pointer to the central focus point of the sky map
+ */
+ SkyPoint* focus() { return &Focus; }
+
+ /** @short retrieve the Destination position.
+ *
+ *The Destination is the point on the sky to which the focus will
+ *be moved.
+ *
+ *@return a pointer to the destination point of the sky map
+ */
+ SkyPoint* destination() { return &Destination; }
+
+ /** @short retrieve the FocusPoint position.
+ *
+ *The FocusPoint stores the position on the sky that is to be
+ *focused next. This is not exactly the same as the Destination
+ *point, because when the Destination is set, it will begin slewing
+ *immediately.
+ *
+ *@return a pointer to the sky point which is to be focused next.
+ */
+ SkyPoint* focusPoint() { return &FocusPoint; }
+
+ /** @short sets the central focus point of the sky map.
+ *@param f a pointer to the SkyPoint the map should be centered on
+ */
+ void setFocus( SkyPoint *f );
+
+ /** @short sets the focus point of the skymap, using ra/dec coordinates
+ *
+ *@note This function behaves essentially like the above function.
+ *It differs only in the data types of its arguments.
+ *
+ *@param ra the new right ascension
+ *@param dec the new declination
+ */
+ void setFocus( const dms &ra, const dms &dec );
+
+ /** @short sets the focus point of the sky map, using its alt/az coordinates
+ *@param alt the new altitude
+ *@param az the new azimuth
+ */
+ void setFocusAltAz( const dms &alt, const dms & az);
+
+ /** @short sets the destination point of the sky map.
+ *@note setDestination() emits the destinationChanged() SIGNAL,
+ *which triggers the SLOT function SkyMap::slewFocus(). This
+ *function iteratively steps the Focus point toward Destination,
+ *repainting the sky at each step (if Options::useAnimatedSlewing()==true).
+ *@param f a pointer to the SkyPoint the map should slew to
+ */
+ void setDestination( const SkyPoint& f );
+
+ /** @short sets the destination point of the skymap, using ra/dec coordinates.
+ *
+ *@note This function behaves essentially like the above function.
+ *It differs only in the data types of its arguments.
+ *
+ *@param ra the new right ascension
+ *@param dec the new declination
+ */
+ void setDestination( const dms &ra, const dms &dec );
+
+ /** @short sets the destination point of the sky map, using its alt/az coordinates.
+ *@param alt the new altitude
+ *@param az the new azimuth
+ */
+ void setDestinationAltAz( const dms &alt, const dms & az);
+
+ /** @short set the FocusPoint; the position that is to be the next Destination.
+ *@param f a pointer to the FocusPoint SkyPoint.
+ */
+ void setFocusPoint( SkyPoint *f ) { if ( f ) FocusPoint = *f; }
+
+ /** @short Retrieve the ClickedPoint position.
+ *
+ *When the user clicks on a point in the sky map, the sky coordinates of the mouse
+ *cursor are stored in the private member ClickedPoint. This function retrieves
+ *a pointer to ClickedPoint.
+ *@return a pointer to ClickedPoint, the sky coordinates where the user clicked.
+ */
+ SkyPoint* clickedPoint() { return &ClickedPoint; }
+
+ /** @short Set the ClickedPoint to the skypoint given as an argument.
+ *@param f pointer to the new ClickedPoint.
+ */
+ void setClickedPoint( SkyPoint *f );
+
+ /** @short Retrieve the object nearest to a mouse click event.
+ *
+ *If the user clicks on the sky map, a pointer to the nearest SkyObject is stored in
+ *the private member ClickedObject. This function returns the ClickedObject pointer,
+ *or NULL if there is no CLickedObject.
+ *@return a pointer to the object nearest to a user mouse click.
+ */
+ SkyObject* clickedObject() const { return ClickedObject; }
+
+ /** @short Set the ClickedObject pointer to the argument.
+ *@param o pointer to the SkyObject to be assigned as the ClickedObject
+ */
+ void setClickedObject( SkyObject *o );
+
+ /** @short Retrieve the object which is centered in the sky map.
+ *
+ *If the user centers the sky map on an object (by double-clicking or using the
+ *Find Object dialog), a pointer to the "focused" object is stored in
+ *the private member FocusObject. This function returns a pointer to the
+ *FocusObject, or NULL if there is not FocusObject.
+ *@return a pointer to the object at the center of the sky map.
+ */
+ SkyObject* focusObject() const { return FocusObject; }
+
+ /** @short Set the FocusObject pointer to the argument.
+ *@param o pointer to the SkyObject to be assigned as the FocusObject
+ */
+ void setFocusObject( SkyObject *o );
+
+ /** @ Set zoom factor.
+ *@param factor zoom factor
+ */
+ void setZoomFactor(double factor);
+
+ /** @short Adds object of type PlanetItem to the SkyMapLite
+ *@param parentComp pointer to the SolarSystemSingleComponent that is to be displayed on SkyMapLite
+ */
+ void addPlanetItem(SolarSystemSingleComponent* parentComp);
+
+ /** @short Call to set up the projector before update of SkyItems positions begins. */
+ void setupProjector();
+
+ /** @short Returns index for a Harvard spectral classification */
+ int harvardToIndex(char c);
+
+ /** @short Initializes images of Stars and put it in cache (copied from SkyQPainter)*/
+ void initStarImages();
+
+ /** @short returns cache of star images
+ * @return star images cache
+ */
+ QVector<QVector<QPixmap*>> getImageCache();
+
+ //bool isSlewing() const;
+
+ // NOTE: This method is draw-backend independent.
+ /** @short update the geometry of the angle ruler. */
+ //void updateAngleRuler();
+
+ /*@*@short Convenience function for shutting off tracking mode. Just calls KStars::slotTrack().
+ */
+ //void stopTracking();
+
+ /** Get the current projector.
+ @return a pointer to the current projector. */
+ inline const Projector * projector() const { return m_proj; }
+
+ /**
+ *@short Proxy method for SkyMapDrawAbstract::drawObjectLabels()
+ */
+ //inline void drawObjectLabels( QList< SkyObject* >& labelObjects ) { dynamic_cast<SkyMapDrawAbstract *>(m_SkyMapDraw)->drawObjectLabels( labelObjects ); }
+
+ /*void setPreviewLegend(bool preview) { m_previewLegend = preview; }
+
+ void setLegend(const Legend &legend) { m_legend = legend; }
+
+ bool isInObjectPointingMode() const { return m_objPointingMode; }
+
+ void setObjectPointingMode(bool enabled) { m_objPointingMode = enabled; }
+
+ void setFovCaptureMode(bool enabled) { m_fovCaptureMode = enabled; }
+
+ bool isInFovCaptureMode() const { return m_fovCaptureMode; }
+
+ SkyPoint getCenterPoint();*/
+
+ // This can be later changed
+ // Total number of sizes of stars.
+ const int nStarSizes;
+ // Total number of specatral classes
+ // N.B. Must be in sync with harvardToIndex
+ const int nSPclasses;
+
+ Projector* m_proj;
+
+public slots:
+ /** Called whenever wrappers' width or height are changed. Probably will be used to
+ * update positions of items.
+ */
+ void resizeItem();
+
+ /** Recalculates the positions of objects in the sky, and then repaints the sky map.
+ * If the positions don't need to be recalculated, use update() instead of forceUpdate().
+ * This saves a lot of CPU time.
+ * @param now if true, paintEvent() is run immediately. Otherwise, it is added to the event queue
+ */
+ void forceUpdate();
+
+ /** @short Convenience function; simply calls forceUpdate(true).
+ * @see forceUpdate()
+ */
+ void forceUpdateNow() { forceUpdate(); }
+
+ /**
+ * @short Update the focus point and call forceUpdate()
+ * @param now is passed on to forceUpdate()
+ */
+ void slotUpdateSky( bool now ) { }
+
+ /** Toggle visibility of geo infobox */
+ //void slotToggleGeoBox(bool);
+
+ /** Toggle visibility of focus infobox */
+ //void slotToggleFocusBox(bool);
+
+ /** Toggle visibility of time infobox */
+ //void slotToggleTimeBox(bool);
+
+ /** Toggle visibility of all infoboxes */
+ //void slotToggleInfoboxes(bool);
+
+ /** Step the Focus point toward the Destination point. Do this iteratively, redrawing the Sky
+ * Map after each step, until the Focus point is within 1 step of the Destination point.
+ * For the final step, snap directly to Destination, and redraw the map.
+ */
+ //void slewFocus();
+
+ /** @short Center the display at the point ClickedPoint.
+ *
+ * The essential part of the function is to simply set the Destination point, which will emit
+ * the destinationChanged() SIGNAL, which triggers the slewFocus() SLOT. Additionally, this
+ * function performs some bookkeeping tasks, such updating whether we are tracking the new
+ * object/position, adding a Planet Trail if required, etc.
+ *
+ * @see destinationChanged()
+ * @see slewFocus()
+ */
+ //void slotCenter();
+
+ /** @short Popup menu function: Display 1st-Generation DSS image with the Image Viewer.
+ * @note the URL is generated using the coordinates of ClickedPoint.
+ */
+ //void slotDSS();
+
+ /** @short Popup menu function: Display Sloan Digital Sky Survey image with the Image Viewer.
+ * @note the URL is generated using the coordinates of ClickedPoint.
+ */
+ //void slotSDSS();
+
+ /** @short Popup menu function: Show webpage about ClickedObject
+ * (only available for some objects).
+ */
+ //void slotInfo();
+
+ /** @short Popup menu function: Show image of ClickedObject
+ * (only available for some objects).
+ */
+ //void slotImage();
+
+ /** @short Popup menu function: Show the Detailed Information window for ClickedObject. */
+ //void slotDetail();
+
+ /** Checks whether the timestep exceeds a threshold value. If so, sets
+ * ClockSlewing=true and sets the SimClock to ManualMode.
+ */
+// void slotClockSlewing();
+
+ // void slotBeginStarHop(); // TODO: Add docs
+
+ /** Render eyepiece view */
+ //void slotEyepieceView();
+
+ /** Zoom in one step. */
+ void slotZoomIn();
+
+ /** Zoom out one step. */
+ void slotZoomOut();
+
+ /** Set default zoom. */
+ void slotZoomDefault();
+
+ /** Object pointing for Printing Wizard done */
+ //void slotObjectSelected();
+
+ //void slotCancelLegendPreviewMode();
+
+signals:
+ /** Emitted by setDestination(), and connected to slewFocus(). Whenever the Destination
+ * point is changed, slewFocus() will iteratively step the Focus toward Destination
+ * until it is reached.
+ * @see SkyMap::setDestination()
+ * @see SkyMap::slewFocus()
+ */
+ void destinationChanged();
+
+ /** Emitted when zoom level is changed. */
+ void zoomChanged();
+
+ /** Emitted when current object changed. */
+ void objectChanged(SkyObject*);
+
+ /** Emitted when pointing changed. (At least should) */
+ void positionChanged(SkyPoint*);
+
+ /** Emitted when position under mouse changed. */
+ void mousePointChanged(SkyPoint*);
+
+ /** Emitted when a position is clicked */
+ void positionClicked(SkyPoint*);
+
+protected:
+ /** Process keystrokes:
+ * @li arrow keys Slew the map
+ * @li +/- keys Zoom in and out
+ * @li <i>Space</i> Toggle between Horizontal and Equatorial coordinate systems
+ * @li 0-9 Go to a major Solar System body (0=Sun; 1-9 are the major planets, except 3=Moon)
+ * @li [ Place starting point for measuring an angular distance
+ * @li ] End point for Angular Distance; display measurement.
+ * @li <i>Escape</i> Cancel Angular measurement
+ * @li ,/< Step backward one time step
+ * @li ./> Step forward one time step
+ */
+ //virtual void keyPressEvent( QKeyEvent *e );
+
+ /** When keyRelease is triggered, just set the "slewing" flag to false,
+ * and update the display (to draw objects that are hidden when slewing==true). */
+ //virtual void keyReleaseEvent( QKeyEvent *e );
+
+ /** Determine RA, Dec coordinates of clicked location. Find the SkyObject
+ * which is nearest to the clicked location.
+ *
+ * If left-clicked: Set set mouseButtonDown==true, slewing==true; display
+ * nearest object name in status bar.
+ * If right-clicked: display popup menu appropriate for nearest object.
+ */
+ virtual void mousePressEvent( QMouseEvent *e );
+
+ /** set mouseButtonDown==false, slewing==false */
+ virtual void mouseReleaseEvent( QMouseEvent *e );
+
+ /** Center SkyMap at double-clicked location */
+ virtual void mouseDoubleClickEvent( QMouseEvent *e );
+
+ /** This function does several different things depending on the state of the program:
+ * @li If Angle-measurement mode is active, update the end-ruler point to the mouse cursor,
+ * and continue this function.
+ * @li If we are defining a ZoomBox, update the ZoomBox rectangle, redraw the screen,
+ * and return.
+ * @li If dragging the mouse in the map, update focus such that RA, Dec under the mouse
+ * cursor remains constant.
+ * @li If just moving the mouse, simply update the curso coordinates in the status bar.
+ */
+ virtual void mouseMoveEvent( QMouseEvent *e );
+
+ /** Zoom in and out with the mouse wheel. */
+ virtual void wheelEvent( QWheelEvent *e );
+
+ /** If the skymap will be resized, the sky must be new computed. So this
+ * function calls explicitly new computing of the skymap.
+ */
+ //virtual void resizeEvent( QResizeEvent * );
+
+private slots:
+ /** @short display tooltip for object under cursor. It's called by m_HoverTimer.
+ * if mouse didn't moved for last HOVER_INTERVAL milliseconds.
+ */
+ //void slotTransientLabel();
+
+ /** Set the shape of mouse cursor to a cross with 4 arrows. */
+ void setMouseMoveCursor();
+
+private:
+
+ /** @short Sets the shape of the default mouse cursor to a cross. */
+ void setDefaultMouseCursor();
+
+ /** @short Sets the shape of the mouse cursor to a magnifying glass. */
+ void setZoomMouseCursor();
+
+ /** Calculate the zoom factor for the given keyboard modifier
+ */
+ double zoomFactor( const int modifier );
+
+ /** calculate the magnitude factor (1, .5, .2, or .1) for the given
+ * keyboard modifier.
+ */
+ double magFactor( const int modifier );
+
+ /** Decrease the magnitude limit by a step size determined by the
+ * keyboard modifier.
+ * @param modifier
+ */
+ void decMagLimit( const int modifier );
+
+ /** Increase the magnitude limit by a step size determined by the
+ * keyboard modifier.
+ * @param modifier
+ */
+ void incMagLimit( const int modifier );
+
+ /** Convenience routine to either zoom in or increase mag limit
+ * depending on the Alt modifier. The Shift and Control modiifers
+ * will adjust the size of the zoom or the mag step.
+ * @param modifier
+ */
+ void zoomInOrMagStep( const int modifier );
+
+ /** Convenience routine to either zoom out or decraase mag limit
+ * depending on the Alt modifier. The Shift and Control modiifers
+ * will adjust the size of the zoom or the mag step.
+ * @param modifier
+ */
+ void zoomOutOrMagStep( const int modifier );
+
+ bool mouseButtonDown, midMouseButtonDown;
+ // true if mouseMoveEvent; needed by setMouseMoveCursor
+ bool mouseMoveCursor;
+ bool slewing, clockSlewing;
+ //if false only old pixmap will repainted with bitBlt(), this
+ // saves a lot of cpu usage
+ bool computeSkymap;
+ // True if we are either looking for angular distance or star hopping directions
+ //bool rulerMode;
+ // True only if we are looking for star hopping directions. If
+ // false while rulerMode is true, it means we are measuring angular
+ // distance. FIXME: Find a better way to do this
+ //bool starHopDefineMode;
+ //double y0;
+
+ //double m_Scale;
+ int count;
+
+ KStarsData *data;
+
+ /** @short Coordinates of point under cursor. It's update in
+ * function mouseMoveEvent
+ */
+ SkyPoint m_MousePoint;
+
+ SkyPoint Focus, ClickedPoint, FocusPoint, Destination;
+ SkyObject *ClickedObject, *FocusObject;
+
+ //SkyLine AngularRuler; //The line for measuring angles in the map
+ QRect ZoomRect; //The manual-focus circle.
+
+ // Mouse should not move for that interval to display tooltip
+ static const int HOVER_INTERVAL = 500;
+ // Timer for tooltips
+ QTimer m_HoverTimer;
+
+ bool m_objPointingMode;
+ bool m_fovCaptureMode;
+
+ static SkyMapLite* pinstance;
+ QQuickItem *m_SkyMapLiteWrapper;
+
+ //SkyItem
+ PlanetsItem* m_planetsItem;
+
+ static int starColorMode;
+
+ const SkyPoint *m_rulerStartPoint; // Good to keep the original ruler start-point for purposes of dynamic_cast
+
+
+ //This can be later changed
+ // Cache for star images.
+ QVector<QVector<QPixmap*>> imageCache;
+
+};
+
+#endif
diff --git a/kstars/skymaplitevents.cpp b/kstars/skymaplitevents.cpp
new file mode 100644
index 0000000..97e1c7a
--- /dev/null
+++ b/kstars/skymaplitevents.cpp
@@ -0,0 +1,283 @@
+#include "skymaplite.h"
+#include "kstarsdata.h"
+#include "kstarslite.h"
+
+#include "kstarslite/skyitems/planetsitem.h"
+#include "Options.h"
+#include "projections/projector.h"
+#include "skymapcomposite.h"
+#include "ksutils.h"
+
+void SkyMapLite::mouseMoveEvent( QMouseEvent *e ) {
+ if ( Options::useHoverLabel() ) {
+ //Start a single-shot timer to monitor whether we are currently hovering.
+ //The idea is that whenever a moveEvent occurs, the timer is reset. It
+ //will only timeout if there are no move events for HOVER_INTERVAL ms
+ m_HoverTimer.start( HOVER_INTERVAL );
+ //DELETE? QToolTip::hideText();
+ }
+
+ //Are we defining a ZoomRect?
+ /*if ( ZoomRect.center().x() > 0 && ZoomRect.center().y() > 0 ) {
+ //cancel operation if the user let go of CTRL
+ if ( !( e->modifiers() & Qt::ControlModifier ) ) {
+ ZoomRect = QRect(); //invalidate ZoomRect
+ update();
+ } else {
+ //Resize the rectangle so that it passes through the cursor position
+ QPoint pcenter = ZoomRect.center();
+ int dx = abs(e->x() - pcenter.x());
+ int dy = abs(e->y() - pcenter.y());
+ if ( dx == 0 || float(dy)/float(dx) > float(height())/float(width()) ) {
+ //Size rect by height
+ ZoomRect.setHeight( 2*dy );
+ ZoomRect.setWidth( 2*dy*width()/height() );
+ } else {
+ //Size rect by height
+ ZoomRect.setWidth( 2*dx );
+ ZoomRect.setHeight( 2*dx*height()/width() );
+ }
+ ZoomRect.moveCenter( pcenter ); //reset center
+
+ update();
+ return;
+ }
+ }
+*/
+ if ( projector()->unusablePoint( e->pos() ) ) return; // break if point is unusable
+
+ //determine RA, Dec of mouse pointer
+ m_MousePoint = projector()->fromScreen( e->pos(), data->lst(), data->geo()->lat() );
+ double dyPix = 0.5*height() - e->y();
+ /*if ( midMouseButtonDown ) { //zoom according to y-offset
+ float yoff = dyPix - y0;
+ if (yoff > 10 ) {
+ y0 = dyPix;
+ slotZoomIn();
+ }
+ if (yoff < -10 ) {
+ y0 = dyPix;
+ slotZoomOut();
+ }
+ }*/
+
+ if ( mouseButtonDown ) {
+ // set the mouseMoveCursor and set slewing=true, if they are not set yet
+ if( !mouseMoveCursor )
+ //setMouseMoveCursor();
+ if( !slewing ) {
+ slewing = true;
+ //stopTracking(); //toggle tracking off
+ }
+
+ //Update focus such that the sky coords at mouse cursor remain approximately constant
+ if ( Options::useAltAz() ) {
+ m_MousePoint.EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ clickedPoint()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ dms dAz = m_MousePoint.az() - clickedPoint()->az();
+ dms dAlt = m_MousePoint.alt() - clickedPoint()->alt();
+ focus()->setAz( focus()->az().Degrees() - dAz.Degrees() ); //move focus in opposite direction
+ focus()->setAz( focus()->az().reduce() );
+ focus()->setAlt(
+ KSUtils::clamp( focus()->alt().Degrees() - dAlt.Degrees() , -90.0 , 90.0 ) );
+ focus()->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
+ } else {
+ dms dRA = m_MousePoint.ra() - clickedPoint()->ra();
+ dms dDec = m_MousePoint.dec() - clickedPoint()->dec();
+ focus()->setRA( focus()->ra().Hours() - dRA.Hours() ); //move focus in opposite direction
+ focus()->setRA( focus()->ra().reduce() );
+ focus()->setDec(
+ KSUtils::clamp( focus()->dec().Degrees() - dDec.Degrees() , -90.0 , 90.0 ) );
+ focus()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ }
+ //showFocusCoords();
+
+ //redetermine RA, Dec of mouse pointer, using new focus
+ m_MousePoint = projector()->fromScreen( e->pos(), data->lst(), data->geo()->lat() );
+ setClickedPoint( &m_MousePoint );
+
+ forceUpdate(); // must be new computed
+
+ } else { //mouse button not down
+ if ( Options::useAltAz() )
+ m_MousePoint.EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ emit mousePointChanged( &m_MousePoint );
+ }
+}
+
+/*void SkyMapLite::wheelEvent( QWheelEvent *e ) {
+ if ( e->delta() > 0 )
+ zoomInOrMagStep ( e->modifiers() );
+ else if ( e->delta() < 0 )
+ zoomOutOrMagStep( e->modifiers() );
+}*/
+
+void SkyMapLite::wheelEvent( QWheelEvent *e ) {
+ if ( e->delta() > 0 )
+ zoomInOrMagStep ( e->modifiers() );
+ else if ( e->delta() < 0 )
+ zoomOutOrMagStep( e->modifiers() );
+}
+
+void SkyMapLite::mouseReleaseEvent( QMouseEvent * ) {
+ /*if ( ZoomRect.isValid() ) {
+ //stopTracking();
+ SkyPoint newcenter = projector()->fromScreen( ZoomRect.center(), data->lst(), data->geo()->lat() );
+ setFocus( &newcenter );
+ setDestination( newcenter );
+
+ //Zoom in on center of Zoom Circle, by a factor equal to the ratio
+ //of the sky pixmap's width to the Zoom Circle's diameter
+ float factor = float(width()) / float(ZoomRect.width());
+ setZoomFactor( Options::zoomFactor() * factor );
+ }*/
+ //setDefaultMouseCursor();
+ ZoomRect = QRect(); //invalidate ZoomRect
+
+ /*if(m_previewLegend) {
+ slotCancelLegendPreviewMode();
+ }*/
+
+ //false if double-clicked, because it's unset there.
+ if (mouseButtonDown) {
+ mouseButtonDown = false;
+ if ( slewing ) {
+ slewing = false;
+ if ( Options::useAltAz() )
+ setDestinationAltAz( focus()->alt(), focus()->az() );
+ else
+ setDestination( *focus() );
+ }
+ forceUpdate(); // is needed because after moving the sky not all stars are shown
+ }
+ // if middle button was pressed unset here
+ midMouseButtonDown = false;
+}
+
+void SkyMapLite::mousePressEvent( QMouseEvent *e ) {
+ KStarsLite* kstars = KStarsLite::Instance();
+
+ /*if ( ( e->modifiers() & Qt::ControlModifier ) && (e->button() == Qt::LeftButton) ) {
+ ZoomRect.moveCenter( e->pos() );
+ setZoomMouseCursor();
+ update(); //refresh without redrawing skymap
+ return;
+ }*/
+
+ // if button is down and cursor is not moved set the move cursor after 500 ms
+ QTimer::singleShot(500, this, SLOT (setMouseMoveCursor()));
+
+ // break if point is unusable
+ if ( projector()->unusablePoint( e->pos() ) )
+ return;
+
+ if ( !midMouseButtonDown && e->button() == Qt::MidButton ) {
+ //y0 = 0.5*height() - e->y(); //record y pixel coordinate for middle-button zooming
+ midMouseButtonDown = true;
+ }
+
+ if ( !mouseButtonDown ) {
+ if ( e->button() == Qt::LeftButton ) {
+ mouseButtonDown = true;
+ }
+
+ //determine RA, Dec of mouse pointer
+ m_MousePoint = projector()->fromScreen( e->pos(), data->lst(), data->geo()->lat() );
+ setClickedPoint( &m_MousePoint );
+
+ //Find object nearest to clickedPoint()
+ double maxrad = 1000.0/Options::zoomFactor();
+ SkyObject* obj = data->skyComposite()->objectNearest( clickedPoint(), maxrad );
+ setClickedObject( obj );
+ if( obj )
+ setClickedPoint( obj );
+
+ switch( e->button() ) {
+ case Qt::LeftButton:
+ {
+ QString name;
+ if( clickedObject() )
+ name = clickedObject()->translatedLongName();
+ else
+ name = i18n( "Empty sky" );
+ //kstars->statusBar()->changeItem(name, 0 );
+ //kstars->statusBar()->showMessage(name, 0 );
+
+ emit positionClicked(&m_MousePoint);
+ }
+
+ break;
+ case Qt::RightButton:
+ /*if( rulerMode ) {
+ // Compute angular distance.
+ slotEndRulerMode();
+ } else {*/
+ // Show popup menu
+ if( clickedObject() ) {
+ //clickedObject()->showPopupMenu( pmenu, QCursor::pos() );
+ } else {
+ /* pmenu->createEmptyMenu( clickedPoint() );
+ pmenu->popup( QCursor::pos() );*/
+ }
+ //}
+ break;
+ default: ;
+ }
+ }
+}
+
+void SkyMapLite::mouseDoubleClickEvent( QMouseEvent *e ) {
+ /*if ( e->button() == Qt::LeftButton && !projector()->unusablePoint( e->pos() ) ) {
+ mouseButtonDown = false;
+ if( e->x() != width()/2 || e->y() != height()/2 )
+ slotCenter();
+ }*/
+}
+
+
+double SkyMapLite::zoomFactor( const int modifier ) {
+ double factor = ( modifier & Qt::ControlModifier) ? DZOOM : 2.0;
+ if ( modifier & Qt::ShiftModifier )
+ factor = sqrt( factor );
+ return factor;
+}
+
+void SkyMapLite::zoomInOrMagStep( const int modifier ) {
+ if ( modifier & Qt::AltModifier )
+ incMagLimit( modifier );
+ else
+ setZoomFactor( Options::zoomFactor() * zoomFactor( modifier ) );
+}
+
+
+void SkyMapLite::zoomOutOrMagStep( const int modifier ) {
+ if ( modifier & Qt::AltModifier )
+ decMagLimit( modifier );
+ else
+ setZoomFactor( Options::zoomFactor() / zoomFactor (modifier ) );
+}
+
+double SkyMapLite::magFactor( const int modifier ) {
+ double factor = ( modifier & Qt::ControlModifier) ? 0.1 : 0.5;
+ if ( modifier & Qt::ShiftModifier )
+ factor *= 2.0;
+ return factor;
+}
+
+void SkyMapLite::incMagLimit( const int modifier ) {
+ double limit = 2.222 * log10(static_cast<double>( Options::starDensity() )) + 0.35;
+ limit += magFactor( modifier );
+ if ( limit > 5.75954 ) limit = 5.75954;
+ Options::setStarDensity( pow( 10, ( limit - 0.35 ) / 2.222) );
+ //printf("maglim set to %3.1f\n", limit);
+ forceUpdate();
+}
+
+void SkyMapLite::decMagLimit( const int modifier ) {
+ double limit = 2.222 * log10(static_cast<double>( Options::starDensity() )) + 0.35;
+ limit -= magFactor( modifier );
+ if ( limit < 1.18778 ) limit = 1.18778;
+ Options::setStarDensity( pow( 10, ( limit - 0.35 ) / 2.222) );
+ //printf("maglim set to %3.1f\n", limit);
+ forceUpdate();
+}