summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-05-17 13:52:01 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-05-17 13:52:01 (GMT)
commit0a1a6b9a8b98ad08b42da2feed6ff1aad9c0bcc5 (patch)
treef9118fe0d3eacce31ae6438e80bd9c2a763017d2
parent865f7d6d4c2ace8395f644c254f6d1dcd44e8ff8 (diff)
Added AsteroidsItem and CometsItem. Changed the structure of nodes:
added SkyNode that is the base of PlanetNode and PointSourceNode. SkyNode holds SkyObject *, which is used to update coordinates. Added PointSourceNode that handles objects without an image (KSComet, most of KSAsteroid)
-rw-r--r--kstars/CMakeLists.txt6
-rw-r--r--kstars/kstarslite/skyitems/asteroidsitem.cpp119
-rw-r--r--kstars/kstarslite/skyitems/asteroidsitem.h49
-rw-r--r--kstars/kstarslite/skyitems/cometsitem.cpp110
-rw-r--r--kstars/kstarslite/skyitems/cometsitem.h47
-rw-r--r--kstars/kstarslite/skyitems/nodes/planetnode.cpp84
-rw-r--r--kstars/kstarslite/skyitems/nodes/planetnode.h36
-rw-r--r--kstars/kstarslite/skyitems/nodes/planetrootnode.h1
-rw-r--r--kstars/kstarslite/skyitems/nodes/pointnode.cpp23
-rw-r--r--kstars/kstarslite/skyitems/nodes/pointnode.h15
-rw-r--r--kstars/kstarslite/skyitems/nodes/pointsourcenode.cpp70
-rw-r--r--kstars/kstarslite/skyitems/nodes/pointsourcenode.h59
-rw-r--r--kstars/kstarslite/skyitems/nodes/rootnode.cpp20
-rw-r--r--kstars/kstarslite/skyitems/nodes/rootnode.h29
-rw-r--r--kstars/kstarslite/skyitems/nodes/skynode.cpp24
-rw-r--r--kstars/kstarslite/skyitems/nodes/skynode.h76
-rw-r--r--kstars/kstarslite/skyitems/planetsitem.cpp78
-rw-r--r--kstars/kstarslite/skyitems/planetsitem.h5
-rw-r--r--kstars/kstarslite/skyitems/skyitem.cpp2
-rw-r--r--kstars/kstarslite/skyitems/skyitem.h11
-rw-r--r--kstars/skycomponents/asteroidscomponent.cpp14
-rw-r--r--kstars/skycomponents/cometscomponent.cpp6
-rw-r--r--kstars/skymaplite.cpp25
-rw-r--r--kstars/skymaplite.h35
24 files changed, 782 insertions, 162 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index feda232..ec681c7 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -547,14 +547,18 @@ if(BUILD_KSTARS_LITE)
skymaplite.cpp
skymaplitevents.cpp
#SkyItems
- kstarslite/skyitems/planetsitem.cpp
kstarslite/skyitems/skyitem.cpp
+ kstarslite/skyitems/planetsitem.cpp
+ kstarslite/skyitems/asteroidsitem.cpp
+ kstarslite/skyitems/cometsitem.cpp
#Root Nodes
kstarslite/skyitems/nodes/rootnode.cpp
kstarslite/skyitems/nodes/planetrootnode.cpp
#Nodes
kstarslite/skyitems/nodes/planetnode.cpp
kstarslite/skyitems/nodes/pointnode.cpp
+ kstarslite/skyitems/nodes/skynode.cpp
+ kstarslite/skyitems/nodes/pointsourcenode.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
diff --git a/kstars/kstarslite/skyitems/asteroidsitem.cpp b/kstars/kstarslite/skyitems/asteroidsitem.cpp
new file mode 100644
index 0000000..f3d3151
--- /dev/null
+++ b/kstars/kstarslite/skyitems/asteroidsitem.cpp
@@ -0,0 +1,119 @@
+/** *************************************************************************
+ asteroidsitem.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 "asteroidsitem.h"
+
+#include "Options.h"
+#include "projections/projector.h"
+#include "ksasteroid.h"
+
+#include "nodes/planetnode.h"
+#include "nodes/planetrootnode.h"
+#include "nodes/pointsourcenode.h"
+
+AsteroidsItem::AsteroidsItem(QQuickItem* parent)
+ :SkyItem(parent)
+{
+
+}
+
+void AsteroidsItem::addAsteroid(KSAsteroid * asteroid) {
+ if(!m_asteroids.contains(asteroid) && !m_toAdd.contains(asteroid))
+ m_toAdd.append(asteroid);
+}
+
+void AsteroidsItem::clear() {
+ m_clear = true;
+ m_asteroids.clear();
+ m_toAdd.clear();
+}
+
+QSGNode* AsteroidsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
+
+ Q_UNUSED(updatePaintNodeData);
+
+ RootNode *n = static_cast<RootNode*>(oldNode);
+ QRectF rect = boundingRect();
+
+ if (!Options::showAsteroids() || rect.isEmpty()) {
+ delete n;
+ 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();
+ 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));
+ }
+ else {
+ n->appendSkyNode(new PointSourceNode(m_toAdd[i],n));
+ }
+ }
+ m_toAdd.clear();
+ }
+ //Update clipping geometry. If m_clipPoly in SkyMapLite wasn't changed, geometry is not updated
+ n->updateClipPoly();
+ //Traverse all children nodes of PlanetRootNode
+ for(int i = 0; i < n->skyNodesCount(); ++i) {
+ SkyNode* pNode = static_cast<SkyNode*>(n->skyNodeAtIndex(i));
+ //bool hideLabels = ! Options::showAsteroidNames() ||
+ //( SkyMapLite::Instance()->isSlewing() && Options::hideLabels() );
+
+ /*double lgmin = log10(MINZOOM);
+ double lgmax = log10(MAXZOOM);
+ double lgz = log10(Options::zoomFactor());
+ double labelMagLimit = 2.5 + Options::asteroidLabelDensity() / 5.0;
+ labelMagLimit += ( 15.0 - labelMagLimit ) * ( lgz - lgmin) / (lgmax - lgmin );
+ if ( labelMagLimit > 10.0 ) labelMagLimit = 10.0;
+ //printf("labelMagLim = %.1f\n", labelMagLimit );*/
+
+ KSAsteroid *ast = static_cast<KSAsteroid *>(pNode->getSkyObject());
+
+ if ( ast->mag() > Options::magLimitAsteroid() || std::isnan(ast->mag()) != 0) {
+ pNode->hide();
+ continue;
+ }
+ //bool drawn = false;
+ pNode->update();
+ //if ( drawn && !( hideLabels || ast->mag() >= labelMagLimit ) )
+ // SkyLabeler::AddLabel( ast, SkyLabeler::ASTEROID_LABEL );
+ }
+ return n;
+}
diff --git a/kstars/kstarslite/skyitems/asteroidsitem.h b/kstars/kstarslite/skyitems/asteroidsitem.h
new file mode 100644
index 0000000..2b49f35
--- /dev/null
+++ b/kstars/kstarslite/skyitems/asteroidsitem.h
@@ -0,0 +1,49 @@
+/** *************************************************************************
+ 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 ASTEROIDSITEM_H_
+#define ASTEROIDSITEM_H_
+
+#include "skyitem.h"
+
+class KSAsteroid;
+
+class AsteroidsItem : public SkyItem {
+public:
+
+ AsteroidsItem(QQuickItem* parent = 0);
+
+ /** Adds an object of type KSAsteroid to m_toAdd. In the next call to
+ * updatePaintNode() the object of type PlanetNode will be created and asteroid
+ * will be moved to m_asteroids. PlanetNode represents graphically KSAsteroid on SkyMapLite.
+ * This function should be called whenever an object of class KSAsteroid is created.
+ *
+ * @param KSAsteroid that should be displayed on SkyMapLite
+ */
+ void addAsteroid(KSAsteroid * asteroid);
+ /**
+ * 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.
+ */
+ void clear();
+
+protected:
+ virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+private:
+ bool m_clear;
+ QList<KSAsteroid*> m_asteroids;
+ QList<KSAsteroid*> m_toAdd;
+};
+#endif
diff --git a/kstars/kstarslite/skyitems/cometsitem.cpp b/kstars/kstarslite/skyitems/cometsitem.cpp
new file mode 100644
index 0000000..fc36ce8
--- /dev/null
+++ b/kstars/kstarslite/skyitems/cometsitem.cpp
@@ -0,0 +1,110 @@
+/** *************************************************************************
+ cometsitem.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 "cometsitem.h"
+
+#include "Options.h"
+#include "projections/projector.h"
+#include "kscomet.h"
+
+#include "nodes/planetnode.h"
+#include "nodes/planetrootnode.h"
+#include "nodes/pointsourcenode.h"
+
+CometsItem::CometsItem(QQuickItem* parent)
+ :SkyItem(parent)
+{
+
+}
+
+void CometsItem::addComet(KSComet * comet) {
+ if(!m_comets.contains(comet) && !m_toAdd.contains(comet))
+ m_toAdd.append(comet);
+}
+
+void CometsItem::clear() {
+ m_clear = true;
+ m_comets.clear();
+ m_toAdd.clear();
+}
+
+QSGNode* CometsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
+
+ Q_UNUSED(updatePaintNodeData);
+
+ RootNode *n = static_cast<RootNode*>(oldNode);
+ QRectF rect = boundingRect();
+
+ if (!Options::showComets() || Options::zoomFactor() < 10*MINZOOM || rect.isEmpty()) {
+ delete n;
+ return 0;
+ }
+
+ if(!n) {
+ n = new RootNode; // If no RootNode exists create one
+ int pComLen = m_comets.length();
+ if(pComLen > 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 < pComLen; ++i) {
+ n->appendSkyNode(new PointSourceNode(m_comets[i],n));
+ }
+ }
+ }
+
+ if(m_clear) {
+ n->removeAllSkyNodes();
+ m_clear = false;
+ }
+
+ int addLength = m_toAdd.length();
+ if(addLength > 0) { // If there are some new comets to add
+ for(int i = 0; i < addLength; ++i) {
+ m_comets.append(m_toAdd[i]);
+ n->appendSkyNode(new PointSourceNode(m_toAdd[i],n));
+ }
+ m_toAdd.clear();
+ }
+ //Update clipping geometry. If m_clipPoly in SkyMapLite wasn't changed, geometry is not updated
+ n->updateClipPoly();
+
+ /*bool hideLabels = ! Options::showCometNames() ||
+ (SkyMap::Instance()->isSlewing() &&
+ Options::hideLabels() );
+ double rsunLabelLimit = Options::maxRadCometName();
+
+ //FIXME: Should these be config'able?
+ skyp->setPen( QPen( QColor( "darkcyan" ) ) );
+ skyp->setBrush( QBrush( QColor( "darkcyan" ) ) );*/
+
+ //Traverse all children nodes of PlanetRootNode
+ for(int i = 0; i < n->skyNodesCount(); ++i) {
+ SkyNode* skyNode = static_cast<SkyNode*>(n->skyNodeAtIndex(i));
+
+ KSComet *com = static_cast<KSComet *>(skyNode->getSkyObject());
+ double mag = com->mag();
+ if (std::isnan(mag) == 0)
+ {
+ skyNode->update();
+ //bool drawn = skyp->drawPointSource(com,mag);
+ //if ( drawn && !(hideLabels || com->rsun() >= rsunLabelLimit) )
+ // SkyLabeler::AddLabel( com, SkyLabeler::COMET_LABEL );
+ } else {
+ skyNode->hide();
+ }
+ }
+ return n;
+}
diff --git a/kstars/kstarslite/skyitems/cometsitem.h b/kstars/kstarslite/skyitems/cometsitem.h
new file mode 100644
index 0000000..1f79cbe
--- /dev/null
+++ b/kstars/kstarslite/skyitems/cometsitem.h
@@ -0,0 +1,47 @@
+/** *************************************************************************
+ cometsitem.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 COMETSITEM_H_
+#define COMETSITEM_H_
+
+#include "skyitem.h"
+
+class KSComet;
+
+class CometsItem : public SkyItem {
+public:
+ CometsItem(QQuickItem* parent = 0);
+ /** Adds an object of type KSComet to m_toAdd. In the next call to
+ * updatePaintNode() the object of type PointSourceNode will be created and comet
+ * will be moved to m_comets. PointSourceNode represents graphically KSComet on SkyMapLite.
+ * This function should be called whenever an object of class KSComet is
+ * created.
+ *
+ * @param KSComet that should be displayed on SkyMapLite
+ */
+ void addComet(KSComet * comet);
+ /**
+ * @short Sets m_clear to true. On next call to updatePaintNode all child nodes of RootNode will be
+ * deleted. Clears m_comets
+ */
+ void clear();
+protected:
+ virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+private:
+ bool m_clear;
+ QList<KSComet *> m_comets;
+ QList<KSComet *> m_toAdd;
+};
+#endif
diff --git a/kstars/kstarslite/skyitems/nodes/planetnode.cpp b/kstars/kstarslite/skyitems/nodes/planetnode.cpp
index c1e1f4d..c44d38b 100644
--- a/kstars/kstarslite/skyitems/nodes/planetnode.cpp
+++ b/kstars/kstarslite/skyitems/nodes/planetnode.cpp
@@ -20,15 +20,13 @@
#include <QQuickWindow>
#include "skymaplite.h"
#include "ksplanetbase.h"
-#include "solarsystemsinglecomponent.h"
-
+#include "Options.h"
+#include "projections/projector.h"
#include "planetnode.h"
-
-PlanetNode::PlanetNode(SolarSystemSingleComponent* p, RootNode* parentNode)
- :m_planetPic(new QSGSimpleTextureNode), m_planet(p), m_planetOpacity(new QSGOpacityNode)
+PlanetNode::PlanetNode(KSPlanetBase* pb, RootNode* parentNode)
+ :SkyNode(pb), m_planetPic(new QSGSimpleTextureNode), m_planetOpacity(new QSGOpacityNode)
{
- KSPlanetBase* pb = m_planet->planet();
// Draw them as bright stars of appropriate color instead of images
char spType;
//FIXME: do these need i18n?
@@ -40,14 +38,74 @@ PlanetNode::PlanetNode(SolarSystemSingleComponent* p, RootNode* parentNode)
spType = 'B';
}
- m_point = new PointNode(spType, parentNode);
+ m_point = new PointNode(parentNode, spType);
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(
- pb->image(), QQuickWindow::TextureCanUseAtlas));
+ pb->image(), QQuickWindow::TextureCanUseAtlas));
+}
+
+void PlanetNode::update() {
+ if(0) {
+ //if(!pNode->planet()->select) {
+ // pNode->hide(); //TODO
+ } else {
+ KSPlanetBase * planet = static_cast<KSPlanetBase *>(m_skyObject);
+
+ if( !projector()->checkVisibility(planet) ) {
+ hide();
+ return;
+ }
+
+ bool visible = false;
+ QPointF pos = projector()->toScreen(planet,true,&visible);
+ if( !visible || !projector()->onScreen(pos) ) {
+ hide();
+ return;
+ }
+ 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" ) {
+ setPointSize(fakeStarSize);
+ changePos(pos);
+ 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();*/
+ setPlanetPicSize(size);
+ changePos(pos);
+ showPlanetPic();
+ } else { //Otherwise, draw a simple circle.
+ //drawEllipse( pos, size, size );
+ }
+ }
+ }
}
void PlanetNode::setPointSize(float size) {
@@ -64,10 +122,7 @@ void PlanetNode::showPoint() {
m_planetOpacity->setOpacity(0);
m_planetOpacity->markDirty(QSGNode::DirtyOpacity);
}
- if(!m_point->opacity()) {
- m_point->setOpacity(1);
- m_point->markDirty(QSGNode::DirtyOpacity);
- }
+ m_point->show();
}
void PlanetNode::showPlanetPic() {
@@ -75,10 +130,7 @@ void PlanetNode::showPlanetPic() {
m_planetOpacity->setOpacity(1);
m_planetOpacity->markDirty(QSGNode::DirtyOpacity);
}
- if(m_point->opacity()) {
- m_point->setOpacity(0);
- m_point->markDirty(QSGNode::DirtyOpacity);
- }
+ m_point->hide();
}
void PlanetNode::hide() {
diff --git a/kstars/kstarslite/skyitems/nodes/planetnode.h b/kstars/kstarslite/skyitems/nodes/planetnode.h
index 0dc628d..c59fb6c 100644
--- a/kstars/kstarslite/skyitems/nodes/planetnode.h
+++ b/kstars/kstarslite/skyitems/nodes/planetnode.h
@@ -17,44 +17,45 @@
#define PLANETNODE_H_
#include <QSGNode>
#include "pointnode.h"
+#include "skynode.h"
class QSGSimpleTextureNode;
class QImage;
-class SolarSystemSingleComponent;
class KSPlanetBase;
class RootNode;
/** @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)
+ * A SkyNode derived class used as a container for holding two other nodes: PointNode
+ * and QSGSimpleTextureNode(displays object as image) that are displayed depending on the conditions
+ * (zoom level, user options)
*
- *@short A container for PointNode and QSGSimpleTextureNode used for displaying planet
+ *@short A container for PointNode and QSGSimpleTextureNode used for displaying some solar system objects
*@author Artem Fedoskin
*@version 1.0
*/
-class PlanetNode : public QSGTransformNode {
+class PlanetNode : public SkyNode {
public:
/**
* @brief Constructor
* @param planet used in PlanesItem to update position of PlanetNode
* @param parentNode used by PointNode to get textures from cache
*/
- PlanetNode(SolarSystemSingleComponent* planet, RootNode* parentNode);
+ PlanetNode(KSPlanetBase* planet, RootNode* parentNode);
+
/**
- * @short setPointSize updates the size of m_point
+ * @short 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
+ * @short 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
+ * @short hides m_planetPic and shows m_point
*/
void showPoint();
/**
@@ -62,18 +63,13 @@ public:
*/
void showPlanetPic();
/**
- * @short hides both nodes
- */
- void hide();
- /**
- * @short changePos changes the position of both nodes
+ * @short changePos changes the position m_point and m_planetPic
* @param pos new position
*/
void changePos(QPointF pos);
- /**
- * @return the SolarSystemSingleComponent associated with this PlanetNode
- */
- inline SolarSystemSingleComponent* planet() { return m_planet; }
+
+ virtual void update() override;
+ virtual void hide() override;
private:
PointNode* m_point;
@@ -81,8 +77,6 @@ private:
// no explicit opacity node here.
QSGOpacityNode* m_planetOpacity;
QSGSimpleTextureNode* m_planetPic;
-
- SolarSystemSingleComponent* m_planet;
};
diff --git a/kstars/kstarslite/skyitems/nodes/planetrootnode.h b/kstars/kstarslite/skyitems/nodes/planetrootnode.h
index 6f73de8..01de5bb 100644
--- a/kstars/kstarslite/skyitems/nodes/planetrootnode.h
+++ b/kstars/kstarslite/skyitems/nodes/planetrootnode.h
@@ -20,6 +20,7 @@ class PlanetNode;
/** @class PlanetRootNode
*@short A RootNode derived class used as a container for holding PlanetNodes.
+ * Might be deleted soon
*@author Artem Fedoskin
*@version 1.0
*/
diff --git a/kstars/kstarslite/skyitems/nodes/pointnode.cpp b/kstars/kstarslite/skyitems/nodes/pointnode.cpp
index 5bc7896..583c0ac 100644
--- a/kstars/kstarslite/skyitems/nodes/pointnode.cpp
+++ b/kstars/kstarslite/skyitems/nodes/pointnode.cpp
@@ -1,5 +1,5 @@
/** *************************************************************************
- pointnode.h - K Desktop Planetarium
+ pointnode.cpp - K Desktop Planetarium
-------------------
begin : 05/05/2016
copyright : (C) 2016 by Artem Fedoskin
@@ -17,12 +17,11 @@
#include <QImage>
#include <QQuickWindow>
-#include "skymaplite.h"
#include "pointnode.h"
#include "rootnode.h"
-PointNode::PointNode(char sp, RootNode* p, float size)
- :spType(sp), texture(new QSGSimpleTextureNode), parentNode(p), skyMapLite(SkyMapLite::Instance())
+PointNode::PointNode(RootNode* p, char sp, float size)
+ :spType(sp), texture(new QSGSimpleTextureNode), parentNode(p)
{
appendChildNode(texture);
setSize(size);
@@ -37,7 +36,21 @@ void PointNode::setSize(float size) {
texture->setRect(QRect(oldRect.x(),oldRect.y(),tSize.width(),tSize.height()));
}
-void PointNode::changePos(QPointF pos) {
+void PointNode::changePos(QPointF pos) { //TODO move it to SkyNodes
QRectF oldRect = texture->rect();
texture->setRect(QRect(pos.x(),pos.y(),oldRect.width(),oldRect.height()));
}
+
+void PointNode::show() {
+ if(!opacity()) {
+ setOpacity(1);
+ markDirty(QSGNode::DirtyOpacity);
+ }
+}
+
+void PointNode::hide() {
+ if(opacity()) {
+ setOpacity(0);
+ markDirty(QSGNode::DirtyOpacity);
+ }
+}
diff --git a/kstars/kstarslite/skyitems/nodes/pointnode.h b/kstars/kstarslite/skyitems/nodes/pointnode.h
index 86e39a8..a4b664e 100644
--- a/kstars/kstarslite/skyitems/nodes/pointnode.h
+++ b/kstars/kstarslite/skyitems/nodes/pointnode.h
@@ -22,10 +22,10 @@ class SkyMapLite;
/** @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
+ * A QSGOpacityNode derived class used for representing stars and planets as stars. Upon
+ * construction loads the texture of star cached in parentNode
*
- *@short QSGSimpleTextureNode derived class that represents stars and planets using cached QPixmap
+ *@short QSGOpacityNode derived class that represents stars and planets using cached QSGTexture
*@author Artem Fedoskin
*@version 1.0
*/
@@ -37,10 +37,10 @@ public:
/**
* @short Constructor
* @param spType spectral type
- * @param parentNode pointer to top parent node, which holds texture cache
+ * @param parentNode pointer to the top parent node, which holds texture cache
* @param size initial size of PointNode
*/
- PointNode(char spType, RootNode* parentNode, float size = 1);
+ PointNode(RootNode* parentNode, char spType = 'A', float size = 1);
/**
* @short setSize update size of PointNode with the given parameter
* @param size new size of PointNode
@@ -51,12 +51,13 @@ public:
* @param pos new position
*/
void changePos(QPointF pos);
+ void show();
+ void hide();
private:
char spType;
QSGSimpleTextureNode *texture;
- // This pointer is important because parentNode holds texture cache
+ //parentNode holds texture cache
RootNode* parentNode;
- SkyMapLite* skyMapLite;
};
#endif
diff --git a/kstars/kstarslite/skyitems/nodes/pointsourcenode.cpp b/kstars/kstarslite/skyitems/nodes/pointsourcenode.cpp
new file mode 100644
index 0000000..38bb8ed
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/pointsourcenode.cpp
@@ -0,0 +1,70 @@
+/** *************************************************************************
+ pointsourcenode.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 <QImage>
+#include <QQuickWindow>
+
+#include "skymaplite.h"
+#include "pointsourcenode.h"
+#include "skyobject.h"
+#include "pointnode.h"
+#include "Options.h"
+
+PointSourceNode::PointSourceNode(SkyObject * skyObject, RootNode* p, char sp, float size)
+ :SkyNode(skyObject), m_point(0), m_sizeMagLim(10.) // has to be changed when stars will be introduced
+{
+ m_point = new PointNode(p,sp,starWidth(size));
+ appendChildNode(m_point);
+}
+
+float PointSourceNode::starWidth(float mag) const
+{
+ //adjust maglimit for ZoomLevel
+ const double maxSize = 10.0;
+
+ double lgmin = log10(MINZOOM);
+// double lgmax = log10(MAXZOOM);
+ double lgz = log10(Options::zoomFactor());
+
+ float sizeFactor = maxSize + (lgz - lgmin);
+
+ float size = ( sizeFactor*( m_sizeMagLim - mag ) / m_sizeMagLim ) + 1.;
+ if( size <= 1.0 ) size = 1.0;
+ if( size > maxSize ) size = maxSize;
+
+ return size;
+}
+
+void PointSourceNode::update() {
+ if( !projector()->checkVisibility(m_skyObject) ) {
+ m_point->hide();
+ return;
+ }
+
+ bool visible = false;
+ QPointF pos = projector()->toScreen(m_skyObject,true,&visible);
+ if( visible && projector()->onScreen(pos) ) { // FIXME: onScreen here should use canvas size rather than SkyMap size, especially while printing in portrait mode!
+ m_point->setSize(starWidth(m_skyObject->mag()));
+ m_point->changePos(pos);
+ m_point->show();
+ } else {
+ m_point->hide();
+ }
+}
+
+void PointSourceNode::hide() {
+ m_point->hide();
+}
diff --git a/kstars/kstarslite/skyitems/nodes/pointsourcenode.h b/kstars/kstarslite/skyitems/nodes/pointsourcenode.h
new file mode 100644
index 0000000..20ab05b
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/pointsourcenode.h
@@ -0,0 +1,59 @@
+/** *************************************************************************
+ pointsourcenode.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 POINTSOURCENODE_H_
+#define POINTSOURCENODE_H_
+#include <QSGSimpleTextureNode>
+#include "skynode.h"
+
+class PlanetItemNode;
+class SkyMapLite;
+class PointNode;
+
+/** @class PointSourceNode
+ *
+ * A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject.
+ *
+ *@short A SkyNode derived class that represents stars and objects that are drawn as stars
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class RootNode;
+
+class PointSourceNode : public SkyNode {
+public:
+ /**
+ * @short Constructor
+ * @param skyObject pointer to SkyObject that has to be displayed on SkyMapLite
+ * @param parentNode pointer to the top parent node, which holds texture cache
+ * @param spType spectral class of PointNode
+ * @param size initial size of PointNode
+ */
+ PointSourceNode(SkyObject * skyObject, RootNode * parentNode, char spType = 'A', float size = 1);
+
+ /** @short Get the width of a star of magnitude mag */
+ float starWidth(float mag) const;
+
+ virtual void update() override;
+ virtual void hide() override;
+private:
+ PointNode * m_point;
+ //TODO deal setter for this when stars will be introduced
+ float m_sizeMagLim;
+};
+
+#endif
+
diff --git a/kstars/kstarslite/skyitems/nodes/rootnode.cpp b/kstars/kstarslite/skyitems/nodes/rootnode.cpp
index 3c54e09..a909b08 100644
--- a/kstars/kstarslite/skyitems/nodes/rootnode.cpp
+++ b/kstars/kstarslite/skyitems/nodes/rootnode.cpp
@@ -1,12 +1,14 @@
+#include <QSGTexture>
+#include <QQuickWindow>
+
#include "rootnode.h"
#include "skymaplite.h"
#include "projections/projector.h"
-
-#include <QSGTexture>
-#include <QQuickWindow>
+#include "skynode.h"
RootNode::RootNode()
- :m_polyNode(new QSGGeometryNode), m_skyMapLite(SkyMapLite::Instance())
+ :m_polyNode(new QSGGeometryNode), m_skyMapLite(SkyMapLite::Instance()),
+ m_polyGeometry(0)
{
genCachedTextures();
updateClipPoly();
@@ -33,11 +35,19 @@ QSGTexture* RootNode::getCachedTexture(int size, char spType) {
return m_textureCache[SkyMapLite::Instance()->harvardToIndex(spType)][size];
}
-void RootNode::appendSkyNode(QSGNode * skyNode) {
+void RootNode::appendSkyNode(SkyNode * skyNode) {
m_skyNodes.append(skyNode);
appendChildNode(skyNode);
}
+void RootNode::removeAllSkyNodes() {
+ for(int i = 0; i < m_skyNodes.length(); ++i) {
+ removeChildNode(m_skyNodes[i]);
+ delete m_skyNodes[i];
+ }
+ m_skyNodes.clear();
+}
+
void RootNode::updateClipPoly() {
QPolygonF newClip = m_skyMapLite->projector()->clipPoly();
if(m_clipPoly != newClip) {
diff --git a/kstars/kstarslite/skyitems/nodes/rootnode.h b/kstars/kstarslite/skyitems/nodes/rootnode.h
index 70deed9..0c5e210 100644
--- a/kstars/kstarslite/skyitems/nodes/rootnode.h
+++ b/kstars/kstarslite/skyitems/nodes/rootnode.h
@@ -23,11 +23,12 @@ class QSGSimpleTextureNode;
class QImage;
class QSGTexture;
class SkyMapLite;
+class SkyNode;
/** @class RootNode
*
- * A QSGClipNode derived class used as a container for holding nodes and for clipping. Upon construction
- * RootNode generates all textures that are used by stars.
+ * A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
+ * Upon construction RootNode generates all textures that are used by PointNode.
*
*@short A container for nodes that holds collection of textures for stars and provides clipping
*@author Artem Fedoskin
@@ -46,14 +47,7 @@ public:
QSGTexture* getCachedTexture(int size, char spType);
/**
- * @brief Adds node to m_skyNodes and node tree
- * @param skyNode pointer to skyNode that has to be added
- */
- void appendSkyNode(QSGNode * skyNode);
-
- /**
- * Triangulates clipping polygon provided by Projection system
- * @short updates clipping geometry using triangles data in SkyMapLite
+ * @short triangulates clipping polygon provided by Projection system
*/
void updateClipPoly();
@@ -67,8 +61,18 @@ public:
* @param i index of SkyNode
* @return desired SkyNode
*/
- inline QSGNode * skyNodeAtIndex(int i) { return m_skyNodes[i]; }
+ inline SkyNode * skyNodeAtIndex(int i) { return m_skyNodes[i]; }
+
+ /**
+ * @brief Adds node to m_skyNodes and node tree
+ * @param skyNode pointer to skyNode that has to be added
+ */
+ void appendSkyNode(SkyNode * skyNode);
+ /**
+ * @short deletes all SkyNodes from m_skyNodes and node tree
+ */
+ void removeAllSkyNodes();
private:
/**
* @short initializes textureCache with cached images of stars in SkyMapLite
@@ -81,6 +85,7 @@ private:
QSGGeometryNode *m_polyNode;
QSGGeometry *m_polyGeometry;
//To hold nodes that represent sky objects
- QVector<QSGNode *> m_skyNodes;
+ QVector<SkyNode *> m_skyNodes;
+ bool m_hidden;
};
#endif
diff --git a/kstars/kstarslite/skyitems/nodes/skynode.cpp b/kstars/kstarslite/skyitems/nodes/skynode.cpp
new file mode 100644
index 0000000..69ba96a
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/skynode.cpp
@@ -0,0 +1,24 @@
+/** *************************************************************************
+ skynode.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 "skymaplite.h"
+#include "skynode.h"
+
+SkyNode::SkyNode(SkyObject * skyObject)
+ :m_skyObject(skyObject)
+{
+
+}
diff --git a/kstars/kstarslite/skyitems/nodes/skynode.h b/kstars/kstarslite/skyitems/nodes/skynode.h
new file mode 100644
index 0000000..2fd58d3
--- /dev/null
+++ b/kstars/kstarslite/skyitems/nodes/skynode.h
@@ -0,0 +1,76 @@
+/** *************************************************************************
+ skynode.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 SKYNODE_H_
+#define SKYNODE_H_
+#include <QSGTransformNode>
+#include "skymaplite.h"
+#include "projections/projector.h"
+
+class Projector;
+class SkyMapLite;
+
+/** @class SkyNode
+ *
+ * A QSGTransformNode derived class that has to be subclassed by node containers like PlanetNode and
+ * PointSourceNode. SkyObject * that is passed as parameter to constructor is used in subclasses
+ * to calculate new coordinates in update(). Subclasses have to implement hide() so that each of
+ * their child nodes can be hidden.
+ *
+ *@short Provides virtual functions for update of coordinates and nodes hiding
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class SkyNode : public QSGTransformNode {
+public:
+ /**
+ * @brief Constructor
+ * @param skyObject that is represented on the SkyMapLIte
+ */
+ SkyNode(SkyObject * skyObject);
+ /** @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 to access SkyMapLite
+ * @return pointer to instance of SkyMapLite class
+ */
+ inline const SkyMapLite* map() { return SkyMapLite::Instance(); }
+
+ /**
+ * @short updates coordinate of the object on SkyMapLite
+ */
+ virtual void update() =0;
+ /**
+ * @short hides all child nodes
+ */
+ virtual void hide() =0;
+
+ /**
+ * @short returns SkyObject associated with this SkyNode
+ * @return pointer to the object of type SkyObject
+ */
+ SkyObject * getSkyObject() const { return m_skyObject; }
+protected:
+ SkyObject * m_skyObject;
+private:
+ //SkyMapLite * m_skyMapLite;
+ //const Projector * m_proj;
+};
+
+
+#endif
diff --git a/kstars/kstarslite/skyitems/planetsitem.cpp b/kstars/kstarslite/skyitems/planetsitem.cpp
index 536a348..f6fa094 100644
--- a/kstars/kstarslite/skyitems/planetsitem.cpp
+++ b/kstars/kstarslite/skyitems/planetsitem.cpp
@@ -1,5 +1,5 @@
/** *************************************************************************
- PlanetsItem.cpp - K Desktop Planetarium
+ planetsitem.cpp - K Desktop Planetarium
-------------------
begin : 02/05/2016
copyright : (C) 2016 by Artem Fedoskin
@@ -19,21 +19,15 @@
#include "solarsystemsinglecomponent.h"
#include "ksplanet.h"
-#include <QSGSimpleTextureNode>
-#include <QQuickWindow>
#include "nodes/planetnode.h"
-#include "nodes/planetrootnode.h"
+#include "nodes/rootnode.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) {
@@ -42,7 +36,7 @@ void PlanetsItem::addPlanet(SolarSystemSingleComponent* planetComp) {
}
QSGNode* PlanetsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
- PlanetRootNode *n = static_cast<PlanetRootNode*>(oldNode);
+ RootNode *n = static_cast<RootNode*>(oldNode);
Q_UNUSED(updatePaintNodeData);
QRectF rect = boundingRect();
@@ -52,13 +46,13 @@ QSGNode* PlanetsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upd
}
if(!n) {
- n = new PlanetRootNode; // If no PlanetRootNode exists create one
+ n = new RootNode; // If no RootNode 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 PlanetRootNode*/
for(int i = 0; i < pCompLen; ++i) {
- n->appendSkyNode(new PlanetNode(m_planetComponents[i], n));
+ n->appendSkyNode(new PlanetNode(m_planetComponents[i]->planet(), n));
}
}
}
@@ -67,7 +61,7 @@ QSGNode* PlanetsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upd
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->appendSkyNode(new PlanetNode(m_toAdd[i], n));
+ n->appendSkyNode(new PlanetNode(m_toAdd[i]->planet(), n));
}
m_toAdd.clear();
}
@@ -76,63 +70,7 @@ QSGNode* PlanetsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upd
//Traverse all children nodes of PlanetRootNode
for(int i = 0; i < n->skyNodesCount(); ++i) {
PlanetNode* pNode = static_cast<PlanetNode*>(n->skyNodeAtIndex(i));
- if(!pNode->planet()->selected()) {
- pNode->hide();
- } else {
- KSPlanetBase* planet = pNode->planet()->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 );
- }
- }
- }
+ pNode->update();
}
return n;
}
diff --git a/kstars/kstarslite/skyitems/planetsitem.h b/kstars/kstarslite/skyitems/planetsitem.h
index 00ef613..89a8b7f 100644
--- a/kstars/kstarslite/skyitems/planetsitem.h
+++ b/kstars/kstarslite/skyitems/planetsitem.h
@@ -1,5 +1,5 @@
/** *************************************************************************
- planetsitems.h - K Desktop Planetarium
+ planetsitem.h - K Desktop Planetarium
-------------------
begin : 02/05/2016
copyright : (C) 2016 by Artem Fedoskin
@@ -24,7 +24,7 @@ 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
+ /** Adds an object of type SolarSystemSingleComponent to 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
@@ -32,6 +32,7 @@ public:
*
* @param SolarSystemSingleComponent that should be displayed on SkyMapLite
*/
+ //TODO change it to KSPlanetBase
void addPlanet(SolarSystemSingleComponent* planetComp);
protected:
virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
diff --git a/kstars/kstarslite/skyitems/skyitem.cpp b/kstars/kstarslite/skyitems/skyitem.cpp
index 4692101..11b2378 100644
--- a/kstars/kstarslite/skyitems/skyitem.cpp
+++ b/kstars/kstarslite/skyitems/skyitem.cpp
@@ -24,6 +24,8 @@ SkyItem::SkyItem(QQuickItem* parent)
// 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);
+
+ connect(m_skyMapLite, &SkyMapLite::zoomChanged, this, &QQuickItem::update);
setWidth(1);
setHeight(1);
}
diff --git a/kstars/kstarslite/skyitems/skyitem.h b/kstars/kstarslite/skyitems/skyitem.h
index 68482ca..06bb651 100644
--- a/kstars/kstarslite/skyitems/skyitem.h
+++ b/kstars/kstarslite/skyitems/skyitem.h
@@ -19,7 +19,7 @@
#include <QSGNode>
#include <QQuickItem>
-#include "skymaplite.h"
+//#include "skymaplite.h"
class SkyComponent;
class Projector;
@@ -52,15 +52,6 @@ protected:
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.
diff --git a/kstars/skycomponents/asteroidscomponent.cpp b/kstars/skycomponents/asteroidscomponent.cpp
index 726ab45..239be9f 100644
--- a/kstars/skycomponents/asteroidscomponent.cpp
+++ b/kstars/skycomponents/asteroidscomponent.cpp
@@ -25,12 +25,16 @@
#include "asteroidscomponent.h"
+#include "kstarslite/skyitems/asteroidsitem.h"
+
#include "auxiliary/filedownloader.h"
#include "projections/projector.h"
#include "solarsystemcomposite.h"
#include "skycomponent.h"
#include "skylabeler.h"
-#ifndef KSTARS_LITE
+#ifdef KSTARS_LITE
+#include "skymaplite.h"
+#else
#include "skymap.h"
#endif
#include "skypainter.h"
@@ -87,13 +91,16 @@ void AsteroidsComponent::loadData()
double q, a, e, dble_i, dble_w, dble_N, dble_M, H, G, earth_moid;
long double JD;
float diameter, albedo, rot_period, period;
- bool neo;
+ bool neo;
emitProgressText( i18n("Loading asteroids") );
+ AsteroidsItem * asteroidsItem = SkyMapLite::Instance()->getAsteroidsItem();
+
// Clear lists
m_ObjectList.clear();
objectNames( SkyObject::ASTEROID ).clear();
+ asteroidsItem->clear();
QList< QPair<QString, KSParser::DataTypes> > sequence;
sequence.append(qMakePair(QString("full name"), KSParser::D_QSTRING));
@@ -184,6 +191,7 @@ void AsteroidsComponent::loadData()
//new_asteroid->setAngularSize(0.005);
m_ObjectList.append(new_asteroid);
+ asteroidsItem->addAsteroid(new_asteroid);
// Add name to the list of object names
objectNames(SkyObject::ASTEROID).append(name);
@@ -284,7 +292,7 @@ void AsteroidsComponent::downloadReady()
// Reload asteroids
loadData();
#ifdef KSTARS_LITE
- KStarsLite::Instance();
+ KStarsLite::Instance()->data()->setFullTimeUpdate();
#else
KStars::Instance()->data()->setFullTimeUpdate();
#endif
diff --git a/kstars/skycomponents/cometscomponent.cpp b/kstars/skycomponents/cometscomponent.cpp
index 2183984..4edefd4 100644
--- a/kstars/skycomponents/cometscomponent.cpp
+++ b/kstars/skycomponents/cometscomponent.cpp
@@ -25,6 +25,8 @@
#include "cometscomponent.h"
#include "solarsystemcomposite.h"
+#include "kstarslite/skyitems/cometsitem.h"
+
#include "Options.h"
#include "skyobjects/kscomet.h"
#include "ksutils.h"
@@ -87,8 +89,11 @@ void CometsComponent::loadData() {
long double JD;
float M1, M2, K1, K2, diameter, albedo, rot_period, period;
+ CometsItem * cometsItem = SkyMapLite::Instance()->getCometsItem();
+
emitProgressText(i18n("Loading comets"));
objectNames(SkyObject::COMET).clear();
+ cometsItem->clear();
QList< QPair<QString, KSParser::DataTypes> > sequence;
sequence.append(qMakePair(QString("full name"), KSParser::D_QSTRING));
@@ -172,6 +177,7 @@ void CometsComponent::loadData() {
// Add *short* name to the list of object names
objectNames( SkyObject::COMET ).append( com->name() );
+ cometsItem->addComet(com);
}
}
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index b022561..724e5da 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -29,7 +29,11 @@
#include "solarsystemsinglecomponent.h"
#include "Options.h"
+//SkyItems
#include "kstarslite/skyitems/planetsitem.h"
+#include "kstarslite/skyitems/asteroidsitem.h"
+#include "kstarslite/skyitems/cometsitem.h"
+
#include "ksplanetbase.h"
#include "ksutils.h"
@@ -82,7 +86,8 @@ 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))
+ nStarSizes(15), nSPclasses(7), m_planetsItem(new PlanetsItem(this)),
+ m_asteroidsItem(new AsteroidsItem(this)), m_cometsItem(new CometsItem(this))
{
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::AllButtons);
@@ -199,6 +204,17 @@ void SkyMapLite::setFocusObject( SkyObject *o ) {
Options::setFocusObject( i18n( "nothing" ) );
}
+void SkyMapLite::slotClockSlewing() {
+ //If the current timescale exceeds slewTimeScale, set clockSlewing=true, and stop the clock.
+ if( (fabs( data->clock()->scale() ) > Options::slewTimeScale()) ^ clockSlewing ) {
+ data->clock()->setManualMode( !clockSlewing );
+ clockSlewing = !clockSlewing;
+ // don't change automatically the DST status
+ KStarsLite* kstars = KStarsLite::Instance();
+ if( kstars )
+ kstars->updateTime( false );
+ }
+}
/*void SkyMapLite::updateFocus() {
if( slewing )
@@ -266,6 +282,8 @@ void SkyMapLite::setZoomFactor(double factor) {
void SkyMapLite::forceUpdate() {
setupProjector();
m_planetsItem->update();
+ m_asteroidsItem->update();
+ m_cometsItem->update();
}
void SkyMapLite::setupProjector() {
@@ -278,6 +296,7 @@ void SkyMapLite::setupProjector() {
p.useRefraction = Options::useRefraction();
p.zoomFactor = Options::zoomFactor();
p.fillGround = Options::showGround();
+ Options::setProjection(Projector::Lambert);
//Check if we need a new projector
if( m_proj && Options::projection() == m_proj->type() )
m_proj->setViewParams(p);
@@ -332,6 +351,10 @@ void SkyMapLite::setMouseMoveCursor()
}
}
+bool SkyMapLite::isSlewing() const {
+ return (slewing || ( clockSlewing && data->clock()->isActive() ) );
+}
+
int SkyMapLite::harvardToIndex(char c) {
// Convert spectral class to numerical index.
// If spectral class is invalid return index for white star (A class)
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 2a7bf10..8a83832 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -25,6 +25,7 @@
#include <config-kstars.h>
#include <QQuickItem>
#include <QPolygonF>
+#include "kstarsdata.h"
class dms;
class KStarsData;
@@ -32,6 +33,8 @@ class SkyObject;
class Projector;
class SolarSystemSingleComponent;
class PlanetsItem;
+class AsteroidsItem;
+class CometsItem;
class QSGTexture;
@@ -73,7 +76,7 @@ public:
Gnomonic,
UnknownProjection };*/
- //static bool IsSlewing() { return pinstance->isSlewing(); }
+ static bool IsSlewing() { return pinstance->isSlewing(); }
/** Destructor (empty) */
~SkyMapLite();
@@ -225,8 +228,8 @@ public:
*/
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
+ /** @short Adds object of type KSPlanetBase to the PlanetsItem
+ *@param parentComp pointer to the KSPlanetBase that is to be displayed on SkyMapLite
*/
void addPlanetItem(SolarSystemSingleComponent* parentComp);
@@ -252,7 +255,7 @@ public:
*/
QSGTexture* getCachedTexture(int size, char spType);
- //bool isSlewing() const;
+ bool isSlewing() const;
// NOTE: This method is draw-backend independent.
/** @short update the geometry of the angle ruler. */
@@ -285,7 +288,17 @@ public:
SkyPoint getCenterPoint();*/
- Projector* m_proj;
+ /**
+ * @brief Get AsteroidsItem object
+ * @return const pointer to m_asteroidsItem
+ */
+ inline AsteroidsItem * getAsteroidsItem() { return m_asteroidsItem; }
+
+ /**
+ * @brief Get CometsItem
+ * @return const pointer to m_cometsItem
+ */
+ inline CometsItem * getCometsItem() { return m_cometsItem; }
public slots:
/** Called whenever wrappers' width or height are changed. Probably will be used to
@@ -366,7 +379,7 @@ public slots:
/** Checks whether the timestep exceeds a threshold value. If so, sets
* ClockSlewing=true and sets the SimClock to ManualMode.
*/
-// void slotClockSlewing();
+ void slotClockSlewing();
// void slotBeginStarHop(); // TODO: Add docs
@@ -557,11 +570,15 @@ private:
bool m_objPointingMode;
bool m_fovCaptureMode;
- static SkyMapLite* pinstance;
+ Projector* m_proj;
+
+ static SkyMapLite *pinstance;
QQuickItem *m_SkyMapLiteWrapper;
- //SkyItem
- PlanetsItem* m_planetsItem;
+ //SkyItems
+ PlanetsItem *m_planetsItem;
+ AsteroidsItem *m_asteroidsItem;
+ CometsItem *m_cometsItem;
static int starColorMode;