Commit 42bb1402 authored by Artem Fedoskin's avatar Artem Fedoskin

Added HorizonItem to SkyMapLite. To render the polygon I used

tessellation method from OpenGL Utility Library (libtess). Added
LinesItem class to display on SkyMapLite LineListIndex derived classes
(Equator, EquatorialCoordinateGrid, HorizontalCoordinateGrid,
ConstellationLines etc.)
parent b284dbc6
......@@ -26,6 +26,7 @@ if(BUILD_KSTARS_LITE)
${kstars_SOURCE_DIR}/kstars/skycomponents
${kstars_SOURCE_DIR}/kstars/auxiliary
${kstars_SOURCE_DIR}/kstars/time
${kstars_SOURCE_DIR}/kstars/triangle
)
else(BUILD_KSTARS_LITE)
include_directories(
......@@ -141,7 +142,6 @@ if(NOT BUILD_KSTARS_LITE)
ekos/guide/rcalibration.cpp
ekos/guide/scroll_graph.cpp
ekos/guide/vect.cpp
)
endif(CFITSIO_FOUND)
......@@ -549,17 +549,48 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/planetsitem.cpp
kstarslite/skyitems/asteroidsitem.cpp
kstarslite/skyitems/cometsitem.cpp
#Root Nodes
kstarslite/skyitems/nodes/rootnode.cpp
kstarslite/skyitems/nodes/planetrootnode.cpp
kstarslite/skyitems/horizonitem.cpp
kstarslite/skyitems/linesitem.cpp
#RootNodes
kstarslite/skyitems/skynodes/rootnodes/rootnode.cpp
kstarslite/skyitems/skynodes/rootnodes/linesrootnode.cpp
#SkyNodes
kstarslite/skyitems/skynodes/planetnode.cpp
kstarslite/skyitems/skynodes/skynode.cpp
kstarslite/skyitems/skynodes/pointsourcenode.cpp
kstarslite/skyitems/skynodes/planetmoonsnode.cpp
kstarslite/skyitems/skynodes/horizonnode.cpp
kstarslite/skyitems/skynodes/trixelnode.cpp
#Nodes
kstarslite/skyitems/nodes/planetnode.cpp
kstarslite/skyitems/nodes/pointnode.cpp
kstarslite/skyitems/nodes/skynode.cpp
kstarslite/skyitems/nodes/pointsourcenode.cpp
kstarslite/skyitems/nodes/planetmoonsnode.cpp
kstarslite/skyitems/skynodes/nodes/pointnode.cpp
kstarslite/skyitems/skynodes/nodes/polynode.cpp
kstarslite/skyitems/skynodes/nodes/linenode.cpp
#libtess
libtess/dict.c
libtess/geom.c
libtess/gluos.h
libtess/memalloc.c
libtess/mesh.c
libtess/normal.c
libtess/priorityq-sort.h
libtess/priorityq.c
libtess/render.c
libtess/sweep.c
libtess/tess.c
libtess/tessmono.c
libtess/priorityq-heap.c
libtess/dict-list.h
libtess/glu.h
libtess/tessellate.c
)
#Qml files will be probably moved to user's data dir, but for use
add_definitions(-DANSI_DECLARATORS) #Needed for Triangle
add_definitions(-DTRILIBRARY)
add_definitions(-DREDUCED)
#add_definitions(-DCDT_ONLY)
if(NOT ANDROID)
add_definitions(-DLINUX)
endif()
#Qml files will be probably moved to user's data dir, but for use
#with QtCreator it is more convenient to have them here
set(kstarsliteqml_SRCS
kstarslite/qml/main.qml
......@@ -630,11 +661,7 @@ if(NOT BUILD_KSTARS_LITE)
)
endif(NOT 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} ${kstarslite_SRCS} ${kstarslite_RESOURCE}
set(kstars_SRCS ${kstarslite_SRCS} ${kstarslite_RESOURCE}
)
if(BUILD_KSTARS_LITE)
kconfig_add_kcfg_files(kstars_SRCS GENERATE_MOC ${kstars_KCFG_SRCS})
......@@ -673,7 +700,13 @@ if(NOT BUILD_KSTARS_LITE)
endif(NOT BUILD_KSTARS_LITE)
add_executable(kstars main.cpp)
add_library( KStarsLib STATIC ${kstars_SRCS})
add_library( KStarsLib STATIC ${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} ${kstars_SRCS} ${kstarslite_RESOURCE})
# FIXME TODO
#target_include_directories(KStarsLib INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR}/>")
if(BUILD_KSTARS_LITE)
......
......@@ -19,6 +19,9 @@
#include "kstarsdata.h"
#include <QQmlContext>
#include <QApplication>
#include <QQuickWindow>
#include <QSurfaceFormat>
#include "kspaths.h"
#include "Options.h"
......@@ -53,7 +56,15 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
m_RootObject = m_Engine.rootObjects()[0];
QQuickItem* skyMapLiteWrapper = m_RootObject->findChild<QQuickItem*>("skyMapLiteWrapper");
QQuickItem *skyMapLiteWrapper = m_RootObject->findChild<QQuickItem*>("skyMapLiteWrapper");
//QQuickWindow *mainWindow = m_RootObject->findChild<QQuickWindow*>("mainWindow");
QQuickWindow *mainWindow = static_cast<QQuickWindow *>(m_Engine.rootObjects()[0]);
QSurfaceFormat format = mainWindow->format();
format.setSamples(4);
format.setSwapBehavior (QSurfaceFormat::TripleBuffer);
mainWindow->setFormat(format);
//Set Geographic Location from Options
m_KStarsData->setLocationFromOptions();
......
......@@ -13,6 +13,7 @@ Window {
property int bgOrder: 1
property int skyMapOrder: 0
property int topMenuOrder: 0
objectName: "mainWindow"
Splash {
z:1
......
......@@ -20,25 +20,23 @@
#include "projections/projector.h"
#include "ksasteroid.h"
#include "nodes/planetnode.h"
#include "nodes/planetrootnode.h"
#include "nodes/pointsourcenode.h"
#include "skynodes/rootnodes/rootnode.h"
#include "skynodes/planetnode.h"
#include "skynodes/pointsourcenode.h"
AsteroidsItem::AsteroidsItem(QQuickItem* parent)
:SkyItem(parent)
:SkyItem(parent), m_asteroidsList(0), m_clear(false)
{
}
void AsteroidsItem::addAsteroid(KSAsteroid * asteroid) {
if(!m_asteroids.contains(asteroid) && !m_toAdd.contains(asteroid))
m_toAdd.append(asteroid);
void AsteroidsItem::setAsteroidsList(QList<SkyObject*> *asteroidsList) {
m_asteroidsList = asteroidsList;
m_addAsteroids = true;
}
void AsteroidsItem::clear() {
m_clear = true;
m_asteroids.clear();
m_toAdd.clear();
}
QSGNode* AsteroidsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
......@@ -53,41 +51,32 @@ QSGNode* AsteroidsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *u
return 0;
}
if(!n) {
n = new RootNode; // If no RootNode exists create one
int pAstLen = m_asteroids.length();
if(pAstLen > 0) {
/* If there are some asteroids that have been already displayed once then recreate them
in new instance of RootNode*/
for(int i = 0; i < pAstLen; ++i) {
if (m_asteroids[i]->image().isNull() == false) {
n->appendSkyNode(new PlanetNode(m_asteroids[i], n));
}
else {
n->appendSkyNode(new PointSourceNode(m_asteroids[i],n));
}
}
}
}
if(m_clear) {
n->removeAllSkyNodes();
if(n) n->removeAllSkyNodes();
m_clear = false;
}
int addLength = m_toAdd.length();
if(addLength > 0) { // If there are some new asteroids to add
for(int i = 0; i < addLength; ++i) {
m_asteroids.append(m_toAdd[i]);
if (m_asteroids[i]->image().isNull() == false) {
n->appendSkyNode(new PlanetNode(m_toAdd[i], n));
if(!n) {
if(!m_asteroidsList) return 0;// AsteroidsComponent is not ready
n = new RootNode; // If no RootNode exists create one
}
if(m_addAsteroids) {
int pAstLen = m_asteroidsList->length();
/* If there are some asteroids that have been already displayed once then recreate them
in new instance of RootNode*/
for(int i = 0; i < pAstLen; ++i) {
KSAsteroid *ast = static_cast<KSAsteroid *>(m_asteroidsList->value(i));
if (ast->image().isNull() == false) {
n->appendSkyNode(new PlanetNode(ast, n));
}
else {
n->appendSkyNode(new PointSourceNode(m_toAdd[i],n));
n->appendSkyNode(new PointSourceNode(ast,n));
}
}
m_toAdd.clear();
m_addAsteroids = false;
}
//Update clipping geometry. If m_clipPoly in SkyMapLite wasn't changed, geometry is not updated
n->updateClipPoly();
//Traverse all children nodes of PlanetRootNode
......
......@@ -19,6 +19,7 @@
#include "skyitem.h"
class KSAsteroid;
class SkyObject;
class AsteroidsItem : public SkyItem {
public:
......@@ -32,7 +33,7 @@ public:
*
* @param KSAsteroid that should be displayed on SkyMapLite
*/
void addAsteroid(KSAsteroid * asteroid);
void setAsteroidsList(QList<SkyObject*> *asteroidsList);
/**
* Sets m_clear to true. On next call to updatePaintNode all SkyNodes in RootNode and
* all KSAsteroids in m_asteroids and m_toAdd will be deleted.
......@@ -43,7 +44,8 @@ protected:
virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
private:
bool m_clear;
QList<KSAsteroid*> m_asteroids;
QList<KSAsteroid*> m_toAdd;
bool m_addAsteroids;
QList<SkyObject*> *m_asteroidsList;
};
#endif
......@@ -20,9 +20,8 @@
#include "projections/projector.h"
#include "kscomet.h"
#include "nodes/planetnode.h"
#include "nodes/planetrootnode.h"
#include "nodes/pointsourcenode.h"
#include "skynodes/rootnodes/rootnode.h"
#include "skynodes/pointsourcenode.h"
CometsItem::CometsItem(QQuickItem* parent)
:SkyItem(parent)
......@@ -90,7 +89,7 @@ QSGNode* CometsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
skyp->setPen( QPen( QColor( "darkcyan" ) ) );
skyp->setBrush( QBrush( QColor( "darkcyan" ) ) );*/
//Traverse all children nodes of PlanetRootNode
//Traverse all children nodes of RootNode
for(int i = 0; i < n->skyNodesCount(); ++i) {
SkyNode* skyNode = static_cast<SkyNode*>(n->skyNodeAtIndex(i));
......
/** *************************************************************************
horizonitem.cpp - K Desktop Planetarium
-------------------
begin : 28/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 "horizonitem.h"
#include "projections/projector.h"
#include "horizoncomponent.h"
#include "skynodes/rootnodes/rootnode.h"
#include "skynodes/horizonnode.h"
#include "Options.h"
HorizonItem::HorizonItem(QQuickItem* parent)
:SkyItem(parent), m_horizonComp(0)
{
Options::setRunClock(false);
Options::setShowGround(false);
}
QSGNode* HorizonItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
RootNode *n = static_cast<RootNode*>(oldNode);
Q_UNUSED(updatePaintNodeData);
QRectF rect = boundingRect();
if (rect.isEmpty()) {
delete n;
return 0;
}
if(!n) {
if(!m_horizonComp) return 0; // HorizonComponent is not ready
n = new RootNode; // If no RootNode exists create one
n->appendSkyNode(new HorizonNode(m_horizonComp->pointList()));
}
//Update clipping geometry. If m_clipPoly in SkyMapLite wasn't changed, geometry is not updated
n->updateClipPoly();
//HorizonNode *hNode = static_cast<HorizonNode *>(n->skyNodeAtIndex(0));
for(int i = 0; i < n->skyNodesCount(); ++i) {
SkyNode *hNode = n->skyNodeAtIndex(i);
if(m_horizonComp->selected()) {
hNode->update();
} else {
hNode->hide();
}
}
return n;
}
/** *************************************************************************
planetrootnode.h - K Desktop Planetarium
horizonitem.h - K Desktop Planetarium
-------------------
begin : 05/05/2016
begin : 28/05/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
......@@ -13,21 +13,22 @@
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef PLANETROOTNODE_H_
#define PLANETROOTNODE_H_
#include "rootnode.h"
class PlanetNode;
#ifndef HORIZONITEM_H_
#define HORIZONITEM_H_
/** @class PlanetRootNode
*@short A RootNode derived class used as a container for holding PlanetNodes.
* Might be deleted soon
*@author Artem Fedoskin
*@version 1.0
*/
#include "skyitem.h"
class PlanetRootNode : public RootNode {
class HorizonComponent;
class HorizonItem : public SkyItem {
public:
PlanetRootNode();
HorizonItem(QQuickItem* parent = 0);
inline void setHorizonComp(HorizonComponent * hComp) { m_horizonComp = hComp; }
protected:
virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
private:
HorizonComponent *m_horizonComp;
};
#endif
/** *************************************************************************
EquatorItem.cpp - K Desktop Planetarium
-------------------
begin : 16/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 "Options.h"
#include "projections/projector.h"
#include "skynodes/trixelnode.h"
#include "linesitem.h"
#include "linelist.h"
#include "skynodes/rootnodes/linesrootnode.h"
LinesItem::LinesItem(QQuickItem* parent)
:SkyItem(parent)
{
Options::setHideCBounds(true);
Options::setShowCBounds(true);
Options::setShowCLines(true);
Options::setHideOnSlew(true);
Options::setHideCLines(false);
Options::setShowSolarSystem(true);
Options::setShowEcliptic(true);
Options::setShowEquator(true);
Options::setShowEquatorialGrid(true);
Options::setShowHorizontalGrid(true);
Options::setHideGrids(false);
}
void LinesItem::addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style) {
m_lineIndexes.append(QPair<bool, LineListIndex *>(true,linesComp));
m_colors.append(color);
m_widths.append(width);
m_styles.append(style);
}
QSGNode* LinesItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
Q_UNUSED(updatePaintNodeData);
LinesRootNode *n = static_cast<LinesRootNode *>(oldNode);
QRectF rect = boundingRect();
if (rect.isEmpty()) {
delete n;
return 0;
}
if(!n) {
n = new LinesRootNode; // If no RootNode exists create one
}
for(int i = 0; i < m_lineIndexes.size(); ++i) {
QPair<bool, LineListIndex *> *p = &m_lineIndexes[i];
if(p->first) {
n->addLinesComponent(p->second,m_colors[i],m_widths[i],m_styles[i]);
p->first = false;
}
}
//Update clipping geometry. If m_clipPoly in SkyMapLite wasn't changed, geometry is not updated
//n->updateClipPoly();
n->update();
return n;
}
/** *************************************************************************
asteroidsitem.h - K Desktop Planetarium
-------------------
begin : 16/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 LINESITEM_H_
#define LINESITEM_H_
#include "skyitem.h"
class KSAsteroid;
class LineListIndex;
class LinesItem : public SkyItem {
public:
LinesItem(QQuickItem* parent = 0);
void addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style);
protected:
virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
private:
QVector<QPair<bool, LineListIndex *>> m_lineIndexes;
QVector<QString> m_colors;
QVector<int> m_widths;
QVector<Qt::PenStyle> m_styles;
};
#endif
#include "planetrootnode.h"
#include "skymaplite.h"
#include <QSGTexture>
#include <QQuickWindow>
PlanetRootNode::PlanetRootNode() {
}
......@@ -20,9 +20,9 @@
#include "ksplanet.h"
#include "planetmoonscomponent.h"
#include "nodes/planetmoonsnode.h"
#include "nodes/planetnode.h"
#include "nodes/rootnode.h"
#include "skynodes/planetmoonsnode.h"
#include "skynodes/planetnode.h"
#include "skynodes/rootnodes/rootnode.h"
#include "Options.h"
......
#include "horizonnode.h"
#include "nodes/polynode.h"
#include "Options.h"
#include "ksutils.h"
HorizonNode::HorizonNode(QList<SkyPoint*>& pointList)
:SkyNode(0),m_pointList(pointList), m_polygonNode(new PolyNode)
{
appendChildNode(m_polygonNode);
}
void HorizonNode::update() {
if(!m_polygonNode->opacity()) {
m_polygonNode->show();
}
QColor color = KStarsData::Instance()->colorScheme()->colorNamed( "HorzColor" );
if(m_polygonNode->getColor() != color) {
m_polygonNode->setColor(color);
}
m_polygonNode->setLineWidth(2);
//QVector<Vector2f> ground = projector()->groundPoly(labelPoint, drawLabel);
QVector<Vector2f> ground = SkyMapLite::Instance()->projector()->groundPoly();
if( ground.size() ) {
QPolygonF groundPoly(ground.size());
for(int i = 0; i < ground.size(); ++i)
groundPoly[i] = KSUtils::vecToPoint(ground[i]);
if( Options::showGround() ) {
m_polygonNode->updateGeometry(groundPoly,true);
} else {
groundPoly.append( groundPoly.first() );
m_polygonNode->updateGeometry(groundPoly,false);
}
} else {
m_polygonNode->hide();
}
m_polygonNode->markDirty(QSGNode::DirtyGeometry);
}
void HorizonNode::hide() {
m_polygonNode->hide();
}
/** *************************************************************************
horizonnode.h - K Desktop Planetarium
-------------------
begin : 28/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 HORIZONNODE_H_
#define HORIZONNODE_H_
#include "skynode.h"
class PolyNode;
/** @class HorizonNode
*
*@version 1.0
*/
class HorizonNode : public SkyNode {
public:
HorizonNode(QList<SkyPoint*>& pointList);
virtual void update() override;
virtual void hide() override;
/**
* @note HorizonNode is not meant to be moved.
*/
virtual void changePos(QPointF pos) { }
private:
PolyNode *m_polygonNode;
QList<SkyPoint*>& m_pointList;
};
#endif
/** *************************************************************************
LineNode.cpp - K Desktop Planetarium
-------------------
begin : 05/05/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
/** *************************************************************************