Commit c0fcc1e4 authored by Artem Fedoskin's avatar Artem Fedoskin

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.
parent c01ade6f
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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 );
......
/** *************************************************************************
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() ) );
}
}
/** *************************************************************************
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
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 + "/"
}
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 </