summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-06-09 06:33:34 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-06-09 06:33:34 (GMT)
commit1aa79365420ac3374183e1945a939e4391d4d8d9 (patch)
tree56d2d5c246dd9a44d193207bcf0074180c093ab5
parentca0182dcaf05556468de942e6a5a2cac5f65b018 (diff)
Optimized the structure of SkyMapLite so that now there is only one node
for clipping and one texture cache.
-rw-r--r--kstars/CMakeLists.txt7
-rw-r--r--kstars/dialogs/detaildialog.cpp4
-rw-r--r--kstars/kspopupmenu.cpp4
-rw-r--r--kstars/kstarsdbus.cpp2
-rw-r--r--kstars/kstarslite/skyitems/asteroidsitem.cpp82
-rw-r--r--kstars/kstarslite/skyitems/asteroidsitem.h19
-rw-r--r--kstars/kstarslite/skyitems/cometsitem.cpp85
-rw-r--r--kstars/kstarslite/skyitems/cometsitem.h19
-rw-r--r--kstars/kstarslite/skyitems/horizonitem.cpp36
-rw-r--r--kstars/kstarslite/skyitems/horizonitem.h5
-rw-r--r--kstars/kstarslite/skyitems/linesitem.cpp81
-rw-r--r--kstars/kstarslite/skyitems/linesitem.h10
-rw-r--r--kstars/kstarslite/skyitems/planetsitem.cpp104
-rw-r--r--kstars/kstarslite/skyitems/planetsitem.h14
-rw-r--r--kstars/kstarslite/skyitems/rootnode.cpp135
-rw-r--r--kstars/kstarslite/skyitems/rootnode.h (renamed from kstars/kstarslite/skyitems/skynodes/rootnodes/rootnode.h)56
-rw-r--r--kstars/kstarslite/skyitems/skyitem.cpp25
-rw-r--r--kstars/kstarslite/skyitems/skyitem.h41
-rw-r--r--kstars/kstarslite/skyitems/skynodes/horizonnode.cpp7
-rw-r--r--kstars/kstarslite/skyitems/skynodes/horizonnode.h4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp19
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/linenode.h9
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp15
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h1
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp33
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/polynode.h8
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetnode.cpp4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp8
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.h1
-rw-r--r--kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.cpp76
-rw-r--r--kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.h43
-rw-r--r--kstars/kstarslite/skyitems/skynodes/rootnodes/rootnode.cpp91
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.cpp6
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.h11
-rw-r--r--kstars/kstarslite/skyitems/skynodes/trixelnode.cpp29
-rw-r--r--kstars/kstarslite/skyitems/skynodes/trixelnode.h3
-rw-r--r--kstars/oal/log.cpp2
-rw-r--r--kstars/printing/detailstable.cpp4
-rw-r--r--kstars/skycomponents/asteroidscomponent.cpp13
-rw-r--r--kstars/skycomponents/cometscomponent.cpp10
-rw-r--r--kstars/skycomponents/constellationboundarylines.cpp4
-rw-r--r--kstars/skycomponents/constellationlines.cpp5
-rw-r--r--kstars/skycomponents/ecliptic.cpp4
-rw-r--r--kstars/skycomponents/equator.cpp4
-rw-r--r--kstars/skycomponents/equatorialcoordinategrid.cpp4
-rw-r--r--kstars/skycomponents/horizoncomponent.cpp4
-rw-r--r--kstars/skycomponents/horizontalcoordinategrid.cpp4
-rw-r--r--kstars/skycomponents/planetmoonscomponent.cpp5
-rw-r--r--kstars/skycomponents/skylabeler.cpp6
-rw-r--r--kstars/skycomponents/skymapcomposite.cpp6
-rw-r--r--kstars/skycomponents/skymapcomposite.h17
-rw-r--r--kstars/skycomponents/solarsystemcomposite.cpp41
-rw-r--r--kstars/skycomponents/solarsystemcomposite.h5
-rw-r--r--kstars/skycomponents/solarsystemsinglecomponent.cpp5
-rw-r--r--kstars/skymaplite.cpp62
-rw-r--r--kstars/skymaplite.h48
-rw-r--r--kstars/tools/observinglist.cpp2
-rw-r--r--kstars/tools/obslistwizard.cpp2
58 files changed, 527 insertions, 827 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index b8778ff..8e9991c 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -544,6 +544,8 @@ if(BUILD_KSTARS_LITE)
kstarsliteinit.cpp
skymaplite.cpp
skymaplitevents.cpp
+ #RootNode
+ kstarslite/skyitems/rootnode.cpp
#SkyItems
kstarslite/skyitems/skyitem.cpp
kstarslite/skyitems/planetsitem.cpp
@@ -551,9 +553,6 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/cometsitem.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
@@ -566,7 +565,7 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/skynodes/nodes/polynode.cpp
kstarslite/skyitems/skynodes/nodes/linenode.cpp
#Material
- kstarslite/skyitems/skynodes/material/dashedshader.cpp
+ #kstarslite/skyitems/skynodes/material/dashedshader.cpp
#libtess
libtess/dict.c
libtess/geom.c
diff --git a/kstars/dialogs/detaildialog.cpp b/kstars/dialogs/detaildialog.cpp
index f1fd825..a876466 100644
--- a/kstars/dialogs/detaildialog.cpp
+++ b/kstars/dialogs/detaildialog.cpp
@@ -436,11 +436,11 @@ void DetailDialog::createGeneralTab()
//Common to all types:
if ( selectedObject->type() == SkyObject::CONSTELLATION )
Data->ObjectTypeInConstellation->setText(
- KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( selectedObject ) );
+ KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( selectedObject ) );
else
Data->ObjectTypeInConstellation->setText(
i18nc("%1 type of sky object (planet, asteroid etc), %2 name of a constellation", "%1 in %2", objecttyp,
- KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( selectedObject ) ) );
+ KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( selectedObject ) ) );
}
void DetailDialog::createPositionTab( const KStarsDateTime &ut, GeoLocation *geo ) {
diff --git a/kstars/kspopupmenu.cpp b/kstars/kspopupmenu.cpp
index be17323..e4105f1 100644
--- a/kstars/kspopupmenu.cpp
+++ b/kstars/kspopupmenu.cpp
@@ -230,7 +230,7 @@ void KSPopupMenu::createSatelliteMenu( Satellite *satellite ) {
addFancyLabel( satellite->name() );
addFancyLabel( satellite->id() );
addFancyLabel( i18n( "satellite" ) );
- addFancyLabel( KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( satellite ) );
+ addFancyLabel( KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( satellite ) );
addSeparator();
@@ -278,7 +278,7 @@ void KSPopupMenu::initPopupMenu( SkyObject *obj, QString name, QString type, QSt
addFancyLabel( name );
addFancyLabel( type );
addFancyLabel( info );
- addFancyLabel( KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( obj ) );
+ addFancyLabel( KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( obj ) );
//Insert Rise/Set/Transit labels
SkyObject* o = obj->clone();
diff --git a/kstars/kstarsdbus.cpp b/kstars/kstarsdbus.cpp
index 6687da6..1b009f9 100644
--- a/kstars/kstarsdbus.cpp
+++ b/kstars/kstarsdbus.cpp
@@ -459,7 +459,7 @@ QString KStars::getObjectDataXML( const QString &objectName ) {
stream.writeTextElement( "Name", target->name() );
stream.writeTextElement( "Alt_Name", target->name2() );
stream.writeTextElement( "Long_Name", target->longname() );
- stream.writeTextElement( "Constellation", KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( target ) );
+ stream.writeTextElement( "Constellation", KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( target ) );
stream.writeTextElement( "RA_Dec_Epoch_JD", QString::number( target->getLastPrecessJD(), 'f', 3 ) );
stream.writeTextElement( "RA_HMS", target->ra().toHMSString() );
stream.writeTextElement( "Dec_DMS", target->dec().toDMSString() );
diff --git a/kstars/kstarslite/skyitems/asteroidsitem.cpp b/kstars/kstarslite/skyitems/asteroidsitem.cpp
index d5fe627..05b08c3 100644
--- a/kstars/kstarslite/skyitems/asteroidsitem.cpp
+++ b/kstars/kstarslite/skyitems/asteroidsitem.cpp
@@ -20,68 +20,49 @@
#include "projections/projector.h"
#include "ksasteroid.h"
-#include "skynodes/rootnodes/rootnode.h"
#include "skynodes/planetnode.h"
#include "skynodes/pointsourcenode.h"
+#include "kstarslite/skyitems/rootnode.h"
-AsteroidsItem::AsteroidsItem(QQuickItem* parent)
- :SkyItem(parent), m_asteroidsList(0), m_clear(false)
+AsteroidsItem::AsteroidsItem(const QList<SkyObject*>& asteroidsList, RootNode *rootNode)
+ :SkyItem(rootNode), m_asteroidsList(asteroidsList)
{
-
+ recreateList();
}
-void AsteroidsItem::setAsteroidsList(QList<SkyObject*> *asteroidsList) {
+/*void AsteroidsItem::setAsteroidsList(QList<SkyObject*> *asteroidsList) {
m_asteroidsList = asteroidsList;
m_addAsteroids = true;
-}
-
-void AsteroidsItem::clear() {
- m_clear = true;
-}
-
-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(m_clear) {
- if(n) n->removeAllSkyNodes();
- m_clear = false;
+}*/
+
+void AsteroidsItem::recreateList() {
+ removeAllChildNodes();
+ foreach(SkyObject *asteroid, m_asteroidsList) {
+ KSAsteroid *ast = static_cast<KSAsteroid *>(asteroid);
+ if (ast->image().isNull() == false) {
+ appendChildNode(new PlanetNode(ast, rootNode()));
+ }
+ else {
+ appendChildNode(new PointSourceNode(ast, rootNode()));
+ }
}
+}
- if(!n) {
- if(!m_asteroidsList) return 0;// AsteroidsComponent is not ready
- n = new RootNode; // If no RootNode exists create one
+void AsteroidsItem::update() {
+ if (!Options::showAsteroids()) {
+ removeAllChildNodes();
+ hide();
+ return;
+ } else if (!childCount()) {
+ recreateList();
}
+ show();
- 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(ast,n));
- }
- }
- m_addAsteroids = false;
- }
+ QSGNode *n = firstChild();
+ while(n != 0) {
+ SkyNode* pNode = static_cast<SkyNode*>(n);
+ n = n->nextSibling();
- //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() );
@@ -93,7 +74,7 @@ QSGNode* AsteroidsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *u
if ( labelMagLimit > 10.0 ) labelMagLimit = 10.0;
//printf("labelMagLim = %.1f\n", labelMagLimit );*/
- KSAsteroid *ast = static_cast<KSAsteroid *>(pNode->getSkyObject());
+ KSAsteroid *ast = static_cast<KSAsteroid *>(pNode->skyObject());
if ( ast->mag() > Options::magLimitAsteroid() || std::isnan(ast->mag()) != 0) {
pNode->hide();
@@ -104,5 +85,4 @@ QSGNode* AsteroidsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *u
//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
index 3c00688..b980720 100644
--- a/kstars/kstarslite/skyitems/asteroidsitem.h
+++ b/kstars/kstarslite/skyitems/asteroidsitem.h
@@ -20,11 +20,12 @@
class KSAsteroid;
class SkyObject;
+class RootNode;
class AsteroidsItem : public SkyItem {
public:
- AsteroidsItem(QQuickItem* parent = 0);
+ AsteroidsItem(const QList<SkyObject*>& asteroidsList, RootNode *rootNode = 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
@@ -33,19 +34,11 @@ public:
*
* @param KSAsteroid that should be displayed on SkyMapLite
*/
- 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.
- */
- void clear();
+ //void setAsteroidsList(QList<SkyObject*> *asteroidsList);
-protected:
- virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+ void recreateList();
+ virtual void update() override;
private:
- bool m_clear;
- bool m_addAsteroids;
-
- QList<SkyObject*> *m_asteroidsList;
+ const QList<SkyObject*>& m_asteroidsList;
};
#endif
diff --git a/kstars/kstarslite/skyitems/cometsitem.cpp b/kstars/kstarslite/skyitems/cometsitem.cpp
index c72bdf1..93336f5 100644
--- a/kstars/kstarslite/skyitems/cometsitem.cpp
+++ b/kstars/kstarslite/skyitems/cometsitem.cpp
@@ -20,65 +20,24 @@
#include "projections/projector.h"
#include "kscomet.h"
-#include "skynodes/rootnodes/rootnode.h"
#include "skynodes/pointsourcenode.h"
-CometsItem::CometsItem(QQuickItem* parent)
- :SkyItem(parent)
+CometsItem::CometsItem(const QList<SkyObject*>& cometsList, RootNode *rootNode)
+ :SkyItem(rootNode), m_cometsList(cometsList)
{
-
-}
-
-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();
+ recreateList();
}
-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;
+void CometsItem::update() {
+ if (!Options::showComets() || Options::zoomFactor() < 10*MINZOOM ) {
+ removeAllChildNodes();
+ hide();
+ return;
+ } else if (!childCount()) {
+ show();
+ recreateList();
}
-
- 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();
+ show();
/*bool hideLabels = ! Options::showCometNames() ||
(SkyMap::Instance()->isSlewing() &&
@@ -89,11 +48,14 @@ QSGNode* CometsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
skyp->setPen( QPen( QColor( "darkcyan" ) ) );
skyp->setBrush( QBrush( QColor( "darkcyan" ) ) );*/
- //Traverse all children nodes of RootNode
- for(int i = 0; i < n->skyNodesCount(); ++i) {
- SkyNode* skyNode = static_cast<SkyNode*>(n->skyNodeAtIndex(i));
+ //Traverse all children nodes
+ QSGNode *n = firstChild();
+ while( n!= 0) {
+ SkyNode* skyNode = static_cast<SkyNode*>(n);
+ n = n->nextSibling();
- KSComet *com = static_cast<KSComet *>(skyNode->getSkyObject());
+ //TODO: Might be better move it to PointSourceNode
+ KSComet *com = static_cast<KSComet *>(skyNode->skyObject());
double mag = com->mag();
if (std::isnan(mag) == 0)
{
@@ -105,5 +67,12 @@ QSGNode* CometsItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
skyNode->hide();
}
}
- return n;
+}
+
+void CometsItem::recreateList() {
+ removeAllChildNodes();
+ foreach(SkyObject *comet, m_cometsList) {
+ KSComet *com = static_cast<KSComet *>(comet);
+ appendChildNode(new PointSourceNode(com,rootNode()));
+ }
}
diff --git a/kstars/kstarslite/skyitems/cometsitem.h b/kstars/kstarslite/skyitems/cometsitem.h
index 1f79cbe..8acaf94 100644
--- a/kstars/kstarslite/skyitems/cometsitem.h
+++ b/kstars/kstarslite/skyitems/cometsitem.h
@@ -19,10 +19,11 @@
#include "skyitem.h"
class KSComet;
+class SkyObject;
class CometsItem : public SkyItem {
public:
- CometsItem(QQuickItem* parent = 0);
+ CometsItem(const QList<SkyObject *>& cometsList, RootNode *rootNode = 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.
@@ -31,17 +32,11 @@ public:
*
* @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;
+ //void addComet(KSComet * comet);
+
+ virtual void update() override;
+ void recreateList();
private:
- bool m_clear;
- QList<KSComet *> m_comets;
- QList<KSComet *> m_toAdd;
+ const QList<SkyObject *>& m_cometsList;
};
#endif
diff --git a/kstars/kstarslite/skyitems/horizonitem.cpp b/kstars/kstarslite/skyitems/horizonitem.cpp
index be7a49a..dfdd473 100644
--- a/kstars/kstarslite/skyitems/horizonitem.cpp
+++ b/kstars/kstarslite/skyitems/horizonitem.cpp
@@ -15,48 +15,32 @@
***************************************************************************/
#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)
+HorizonItem::HorizonItem(HorizonComponent * hComp, RootNode *rootNode)
+ :SkyItem(rootNode), m_horizonComp(hComp)
{
-
+ appendChildNode(new HorizonNode(m_horizonComp->pointList()));
}
-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;
+void HorizonItem::update() {
+ if(!childCount()) {
+ appendChildNode(new HorizonNode(m_horizonComp->pointList()));
}
- 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);
+ QSGNode *n = firstChild();
+ while(n != 0) {
+ SkyNode *hNode = static_cast<SkyNode *>(n);
if(m_horizonComp->selected()) {
hNode->update();
} else {
hNode->hide();
}
+ n = n->nextSibling();
}
-
- return n;
}
diff --git a/kstars/kstarslite/skyitems/horizonitem.h b/kstars/kstarslite/skyitems/horizonitem.h
index 9b3a4d1..aa348a1 100644
--- a/kstars/kstarslite/skyitems/horizonitem.h
+++ b/kstars/kstarslite/skyitems/horizonitem.h
@@ -22,11 +22,10 @@ class HorizonComponent;
class HorizonItem : public SkyItem {
public:
- HorizonItem(QQuickItem* parent = 0);
+ HorizonItem(HorizonComponent * hComp, RootNode *rootNode);
inline void setHorizonComp(HorizonComponent * hComp) { m_horizonComp = hComp; }
-protected:
- virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+ virtual void update();
private:
HorizonComponent *m_horizonComp;
};
diff --git a/kstars/kstarslite/skyitems/linesitem.cpp b/kstars/kstarslite/skyitems/linesitem.cpp
index 25c55b1..5827c90 100644
--- a/kstars/kstarslite/skyitems/linesitem.cpp
+++ b/kstars/kstarslite/skyitems/linesitem.cpp
@@ -16,14 +16,16 @@
#include "Options.h"
#include "projections/projector.h"
+#include <QSGNode>
#include "skynodes/trixelnode.h"
#include "linesitem.h"
#include "linelist.h"
-#include "skynodes/rootnodes/linesrootnode.h"
+#include "linelistindex.h"
+#include "skynodes/nodes/linenode.h"
-LinesItem::LinesItem(QQuickItem* parent)
- :SkyItem(parent)
+LinesItem::LinesItem(RootNode *rootNode)
+ :SkyItem(rootNode)
{
Options::setHideCBounds(true);
Options::setShowCBounds(true);
@@ -43,40 +45,59 @@ LinesItem::LinesItem(QQuickItem* parent)
}
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) {
+ QSGOpacityNode *node = new QSGOpacityNode;
+ appendChildNode(node);
- Q_UNUSED(updatePaintNodeData);
+ m_lineIndexes.insert(node, linesComp);
+ LineListHash *trixels = linesComp->lineIndex();
- LinesRootNode *n = static_cast<LinesRootNode *>(oldNode);
- QRectF rect = boundingRect();
+ QHash< Trixel, LineListList *>::const_iterator i = trixels->begin();
+ while( i != trixels->end()) {
- if (rect.isEmpty()) {
- delete n;
- return 0;
- }
-
- if(!n) {
- n = new LinesRootNode; // If no RootNode exists create one
+ TrixelNode *trixel = new TrixelNode(i.key(), i.value());
+ node->appendChildNode(trixel);
+ trixel->setStyle(color, width, style);
+ ++i;
}
+}
- 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;
+void LinesItem::update() {
+ QMap< QSGOpacityNode *, LineListIndex *>::const_iterator i = m_lineIndexes.begin();
+ while( i != m_lineIndexes.end()) {
+ QVector<Trixel> visTrixels;
+ SkyMesh * mesh = SkyMesh::Instance();
+ SkyMapLite *map = SkyMapLite::Instance();
+ double radius = map->projector()->fov();
+ if ( radius > 180.0 )
+ radius = 180.0;
+ if(mesh) {
+ //mesh->aperture(map->focus(), radius);
}
- }
- //Update clipping geometry. If m_clipPoly in SkyMapLite wasn't changed, geometry is not updated
- //n->updateClipPoly();
+ MeshIterator region (mesh,DRAW_BUF);
+ while ( region.hasNext() ) {
+ visTrixels.append(region.next());
+ }
- n->update();
- return n;
+ QSGOpacityNode * node = i.key();
+ if(i.value()->selected()) {
+ node->setOpacity(1);
+ //for(int c = 0; c < node->childCount(); ++c) {
+ QSGNode *n = node->firstChild();
+ while(n != 0) {
+ TrixelNode * trixel = static_cast<TrixelNode *>(n);
+ n = n->nextSibling();
+ //if(visTrixels.contains(c)) {
+ trixel->update();
+ /* } else {
+ trixel->hide();
+ }*/
+ }
+ } else {
+ node->setOpacity(0);
+ }
+ node->markDirty(QSGNode::DirtyOpacity);
+ ++i;
+ }
}
diff --git a/kstars/kstarslite/skyitems/linesitem.h b/kstars/kstarslite/skyitems/linesitem.h
index dfc3537..c7b6286 100644
--- a/kstars/kstarslite/skyitems/linesitem.h
+++ b/kstars/kstarslite/skyitems/linesitem.h
@@ -24,17 +24,13 @@ class LineListIndex;
class LinesItem : public SkyItem {
public:
- LinesItem(QQuickItem* parent = 0);
+ LinesItem(RootNode *rootNode);
void addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style);
-protected:
- virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+ virtual void update();
private:
- QVector<QPair<bool, LineListIndex *>> m_lineIndexes;
- QVector<QString> m_colors;
- QVector<int> m_widths;
- QVector<Qt::PenStyle> m_styles;
+ QMap<QSGOpacityNode *,LineListIndex *> m_lineIndexes;
};
#endif
diff --git a/kstars/kstarslite/skyitems/planetsitem.cpp b/kstars/kstarslite/skyitems/planetsitem.cpp
index 24d8875..d208147 100644
--- a/kstars/kstarslite/skyitems/planetsitem.cpp
+++ b/kstars/kstarslite/skyitems/planetsitem.cpp
@@ -22,25 +22,22 @@
#include "skynodes/planetmoonsnode.h"
#include "skynodes/planetnode.h"
-#include "skynodes/rootnodes/rootnode.h"
-
#include "Options.h"
-PlanetsItem::PlanetsItem(QQuickItem* parent)
- :SkyItem(parent)
+PlanetsItem::PlanetsItem(QList<SolarSystemSingleComponent *> planets, QList<PlanetMoonsComponent *> moons, RootNode *rootNode)
+ :SkyItem(rootNode), m_planetComponents(planets), m_moonsComponents(moons)
{
-
-}
-
-void PlanetsItem::addPlanet(SolarSystemSingleComponent* planetComp) {
- if(!m_planetComponents.contains(planetComp) && !m_planetsToAdd.contains(planetComp)) {
- m_planetsToAdd.append(planetComp);
- }
-}
-
-void PlanetsItem::addMoons(PlanetMoonsComponent * moonsComponent) {
- if(!m_moonsComponents.contains(moonsComponent) && !m_moonsToAdd.contains(moonsComponent)) {
- m_moonsToAdd.append(moonsComponent);
+ foreach(SolarSystemSingleComponent * planetComp, m_planetComponents) {
+ KSPlanetBase *planet = planetComp->planet();
+ PlanetMoonsNode *pNode = new PlanetMoonsNode(planet, rootNode);
+ appendChildNode(pNode);
+
+ foreach(PlanetMoonsComponent * moonsComp, m_moonsComponents) {
+ // Find planet of moons
+ if(planet == moonsComp->getPlanet()) {
+ pNode->addMoons(moonsComp->getMoons());
+ }
+ }
}
}
@@ -51,77 +48,16 @@ SolarSystemSingleComponent * PlanetsItem::getParentComponent(SkyObject * planet)
return nullptr;
}
-QSGNode* PlanetsItem::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) {
- 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 the new instance of RootNode*/
- int mCompLen = m_moonsComponents.length();
- foreach(SolarSystemSingleComponent * planetComp, m_planetComponents) {
- KSPlanetBase *planet = planetComp->planet();
- PlanetMoonsNode *pNode = new PlanetMoonsNode(planet, n);
- n->appendSkyNode(pNode);
- /* If there are some moons that have been already displayed once then recreate them
- in the new instance of RootNode*/
- if(mCompLen > 0) {
- foreach(PlanetMoonsComponent * moonsComp, m_moonsComponents) {
- // Find planet of moons
- if(planet == moonsComp->getPlanet()) {
- pNode->addMoons(moonsComp->getMoons());
- }
- }
- }
- }
- }
- }
-
- int addPlanetLen = m_planetsToAdd.length();
- if(addPlanetLen > 0) { // If there are some new planets to add
- foreach(SolarSystemSingleComponent * planetComp, m_planetsToAdd) {
- m_planetComponents.append(planetComp);
-
- KSPlanetBase *planet = planetComp->planet();
- PlanetMoonsNode *pNode = new PlanetMoonsNode(planet, n);
- n->appendSkyNode(pNode);
- }
- m_planetsToAdd.clear();
- }
-
- int addMoonLen = m_moonsToAdd.length();
-
- //Update clipping geometry. If m_clipPoly in SkyMapLite wasn't changed, geometry is not updated
- n->updateClipPoly();
+void PlanetsItem::update() {
+ show();
//Traverse all children nodes of RootNode
- for(int i = 0; i < n->skyNodesCount(); ++i) {
- PlanetMoonsNode *pNode = static_cast<PlanetMoonsNode *>(n->skyNodeAtIndex(i));
-
- SkyObject * planet = pNode->getSkyObject();
-
- if(addMoonLen > 0) { // If there are moons to add
- foreach(PlanetMoonsComponent * moonsComp, m_moonsToAdd) {
- if(planet == moonsComp->getPlanet()) {
- pNode->addMoons(moonsComp->getMoons());
-
- m_moonsComponents.append(moonsComp);
- m_moonsToAdd.removeOne(moonsComp);
- }
- }
- }
+ QSGNode *n = firstChild();
+ while(n != 0) {
+ PlanetMoonsNode *pNode = static_cast<PlanetMoonsNode *>(n);
+ n = n->nextSibling();
- bool selected = getParentComponent(pNode->getSkyObject())->selected();
+ bool selected = getParentComponent(pNode->skyObject())->selected();
if(selected) pNode->update();
else pNode->hide();
}
- return n;
}
diff --git a/kstars/kstarslite/skyitems/planetsitem.h b/kstars/kstarslite/skyitems/planetsitem.h
index 2aeb6e4..ed12ebd 100644
--- a/kstars/kstarslite/skyitems/planetsitem.h
+++ b/kstars/kstarslite/skyitems/planetsitem.h
@@ -20,11 +20,12 @@
class SolarSystemSingleComponent;
class PlanetMoonsComponent;
+class RootNode;
class SkyObject;
class PlanetsItem : public SkyItem {
public:
- PlanetsItem(QQuickItem* parent = 0);
+ PlanetsItem(QList<SolarSystemSingleComponent *> planets, QList<PlanetMoonsComponent *> moons, RootNode *rootNode = 0);
/** Add a pointer to 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.
@@ -34,7 +35,7 @@ public:
* @param SolarSystemSingleComponent that should be displayed on SkyMapLite
*/
- void addPlanet(SolarSystemSingleComponent* planetComp);
+// void addPlanet(SolarSystemSingleComponent* planetComp);
/**
* Add a pointer to an object of type PlanetMoonsComponent to m_moonsToAdd. In the next call to
@@ -42,17 +43,16 @@ public:
* the drawing of moons and planet.
* @param pMoons pointer to PlanetMoonsComponent which moons should be displayed on SkyMapLite
*/
- void addMoons(PlanetMoonsComponent * pMoons);
+// void addMoons(PlanetMoonsComponent * pMoons);
SolarSystemSingleComponent * getParentComponent(SkyObject * planet);
+ void update() override;
protected:
- virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+ //virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
+
private:
QList<SolarSystemSingleComponent *> m_planetComponents;
- QList<SolarSystemSingleComponent *> m_planetsToAdd;
-
QList<PlanetMoonsComponent *> m_moonsComponents;
- QList<PlanetMoonsComponent *> m_moonsToAdd;
};
#endif
diff --git a/kstars/kstarslite/skyitems/rootnode.cpp b/kstars/kstarslite/skyitems/rootnode.cpp
new file mode 100644
index 0000000..cfa44a4
--- /dev/null
+++ b/kstars/kstarslite/skyitems/rootnode.cpp
@@ -0,0 +1,135 @@
+#include <QSGTexture>
+#include <QQuickWindow>
+
+#include "rootnode.h"
+#include "skymaplite.h"
+#include "projections/projector.h"
+#include "skymapcomposite.h"
+#include "solarsystemcomposite.h"
+#include "Options.h"
+
+#include "constellationboundarylines.h"
+#include "constellationlines.h"
+
+#include "horizontalcoordinategrid.h"
+#include "equatorialcoordinategrid.h"
+
+#include "ecliptic.h"
+#include "equator.h"
+
+//SkyItems
+#include "kstarslite/skyitems/planetsitem.h"
+#include "kstarslite/skyitems/asteroidsitem.h"
+#include "kstarslite/skyitems/cometsitem.h"
+#include "kstarslite/skyitems/horizonitem.h"
+#include "kstarslite/skyitems/linesitem.h"
+
+RootNode::RootNode()
+ :m_skyMapLite(SkyMapLite::Instance()),
+ m_clipGeometry(0)
+{
+ genCachedTextures();
+ Options::setProjection(Projector::Lambert);
+
+ SkyMapComposite *skyComposite = KStarsData::Instance()->skyComposite();
+ SolarSystemComposite *solarSystem = skyComposite->solarSystemComposite();
+
+ m_planetsItem = new PlanetsItem(solarSystem->planets(), solarSystem->planetMoonsComponent(), this);
+ m_asteroidsItem = new AsteroidsItem(solarSystem->asteroids(), this);
+ m_cometsItem = new CometsItem(solarSystem->comets(), this);
+
+
+ m_linesItem = new LinesItem(this);
+
+ m_linesItem->addLinesComponent( skyComposite->constellationBoundary(), "CBoundColor", 1, Qt::SolidLine );
+ m_linesItem->addLinesComponent( skyComposite->constellationLines(), "СLineColor", 1, Qt::SolidLine );
+
+ m_linesItem->addLinesComponent( skyComposite->equator(), "EqColor", 1, Qt::SolidLine );
+ m_linesItem->addLinesComponent( skyComposite->ecliptic(), "EclColor", 1, Qt::SolidLine );
+
+ m_linesItem->addLinesComponent( skyComposite->equatorialCoordGrid(), "EquatorialGridColor", 1, Qt::DotLine );
+ m_linesItem->addLinesComponent( skyComposite->horizontalCoordGrid(), "HorizontalGridColor", 1, Qt::DotLine );
+
+ m_horizonItem = new HorizonItem(skyComposite->horizon(), this);
+
+ setIsRectangular(false);
+ updateClipPoly();
+
+ Options::setShowGround(true);
+
+ /*
+ m_linesItem(new LinesItem(this)), m_horizonItem(new HorizonItem(this))
+ */
+}
+
+void RootNode::genCachedTextures() {
+ QVector<QVector<QPixmap*>> images = m_skyMapLite->getImageCache();
+
+ QQuickWindow *win = m_skyMapLite->window();
+
+ m_textureCache = QVector<QVector<QSGTexture*>> (images.length());
+
+ for(int i = 0; i < m_textureCache.length(); ++i) {
+ int length = images[i].length();
+ m_textureCache[i] = QVector<QSGTexture *>(length);
+ for(int c = 1; c < length; ++c) {
+ m_textureCache[i][c] = win->createTextureFromImage(images[i][c]->toImage(), QQuickWindow::TextureCanUseAtlas);
+ }
+ }
+}
+
+QSGTexture* RootNode::getCachedTexture(int size, char spType) {
+ return m_textureCache[SkyMapLite::Instance()->harvardToIndex(spType)][size];
+}
+
+void RootNode::updateClipPoly() {
+ QPolygonF newClip = m_skyMapLite->projector()->clipPoly();
+ if(m_clipPoly != newClip) {
+ m_clipPoly = newClip;
+ } else {
+ return; //We don't need to triangulate polygon and update geometry if polygon wasn't changed
+ }
+ QVector<QPointF> triangles;
+
+ for(int i = 1; i < m_clipPoly.size() - 1; ++i) {
+ triangles.append(m_clipPoly[0]);
+ triangles.append(m_clipPoly[i]);
+ triangles.append(m_clipPoly[i+1]);
+ }
+
+ const int size = triangles.size();
+ if(!m_clipGeometry) {
+ m_clipGeometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D (),
+ size);
+ m_clipGeometry->setDrawingMode(GL_TRIANGLES);
+ setGeometry(m_clipGeometry);
+ } else {
+ m_clipGeometry->allocate(size);
+ }
+
+ QSGGeometry::Point2D * vertex = m_clipGeometry->vertexDataAsPoint2D ();
+ for (int i = 0; i < size; i++) {
+ vertex[i].x = triangles[i].x();
+ vertex[i].y = triangles[i].y();
+ }
+ markDirty(QSGNode::DirtyGeometry);
+}
+
+void RootNode::update() {
+ updateClipPoly();
+ //TODO: Move this check somewhere else (create a separate function)
+ if(Options::showSolarSystem()) {
+ m_planetsItem->update();
+ m_asteroidsItem->update();
+ m_cometsItem->update();
+ } else {
+ m_planetsItem->hide();
+ m_asteroidsItem->hide();
+ m_cometsItem->hide();
+ }
+
+ m_horizonItem->update();
+
+ m_linesItem->update();
+}
+
diff --git a/kstars/kstarslite/skyitems/skynodes/rootnodes/rootnode.h b/kstars/kstarslite/skyitems/rootnode.h
index ea37f6c..1890b25 100644
--- a/kstars/kstarslite/skyitems/skynodes/rootnodes/rootnode.h
+++ b/kstars/kstarslite/skyitems/rootnode.h
@@ -16,15 +16,18 @@
***************************************************************************/
#ifndef ROOTNODE_H_
#define ROOTNODE_H_
-#include <QSGClipNode>
#include <QPolygonF>
#include <QSGClipNode>
-class QSGSimpleTextureNode;
-class QImage;
class QSGTexture;
class SkyMapLite;
-class SkyNode;
+
+class PlanetsItem;
+class AsteroidsItem;
+class CometsItem;
+
+class HorizonItem;
+class LinesItem;
/** @class RootNode
*
@@ -36,7 +39,7 @@ class SkyNode;
*@version 1.0
*/
-class RootNode : public QSGNode { //Clipping under construction
+class RootNode : public QSGClipNode { //Clipping under construction
public:
RootNode();
/**
@@ -53,35 +56,9 @@ public:
void updateClipPoly();
/**
- * @return number of SkyNodes in m_skyNodes
- */
- inline int skyNodesCount() { return m_skyNodes.length(); }
-
- /**
- * @short returns a SkyNode in m_skyNodes with index i
- * @param i index of SkyNode
- * @return desired SkyNode
+ * @short update positions of all child SkyItems
*/
- 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);
-
- void prependSkyNode(SkyNode *skyNode);
-
- /**
- * @short remove given skyNode from m_skyNodes and a node tree
- * @param skyNode pointer to skyNode that needs to be deleted
- */
- void removeSkyNode(SkyNode *skyNode);
-
- /**
- * @short deletes all SkyNodes from m_skyNodes and node tree
- */
- void removeAllSkyNodes();
+ void update();
private:
/**
* @short initializes textureCache with cached images of stars in SkyMapLite
@@ -91,10 +68,17 @@ private:
SkyMapLite *m_skyMapLite;
QPolygonF m_clipPoly;
- QSGGeometryNode *m_clipNode;
QSGGeometry *m_clipGeometry;
+
+ PlanetsItem *m_planetsItem;
+ AsteroidsItem *m_asteroidsItem;
+ CometsItem *m_cometsItem;
+
+ HorizonItem *m_horizonItem;
+ LinesItem *m_linesItem;
+
//To hold nodes that represent sky objects
- QVector<SkyNode *> m_skyNodes;
- bool m_hidden;
+ //QVector<SkyNode *> m_skyNodes;
+ //bool m_hidden;
};
#endif
diff --git a/kstars/kstarslite/skyitems/skyitem.cpp b/kstars/kstarslite/skyitems/skyitem.cpp
index 11b2378..f8b9c7b 100644
--- a/kstars/kstarslite/skyitems/skyitem.cpp
+++ b/kstars/kstarslite/skyitems/skyitem.cpp
@@ -15,22 +15,21 @@
***************************************************************************/
#include "skyitem.h"
#include "../../skymaplite.h"
+#include "rootnode.h"
+#include "skynodes/skynode.h"
-SkyItem::SkyItem(QQuickItem* parent)
- :QQuickItem(parent), m_skyMapLite(SkyMapLite::Instance())
+SkyItem::SkyItem(RootNode* parent)
+ :m_rootNode(parent)
{
- 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);
+ parent->appendChildNode(this);
+}
- connect(m_skyMapLite, &SkyMapLite::zoomChanged, this, &QQuickItem::update);
- setWidth(1);
- setHeight(1);
+void SkyItem::hide() {
+ setOpacity(0);
+ markDirty(QSGNode::DirtyOpacity);
}
-void SkyItem::resizeItem() {
- setWidth(parentItem()->width());
- setHeight(parentItem()->height());
+void SkyItem::show() {
+ setOpacity(1);
+ markDirty(QSGNode::DirtyOpacity);
}
diff --git a/kstars/kstarslite/skyitems/skyitem.h b/kstars/kstarslite/skyitems/skyitem.h
index 06bb651..3ca42ef 100644
--- a/kstars/kstarslite/skyitems/skyitem.h
+++ b/kstars/kstarslite/skyitems/skyitem.h
@@ -17,14 +17,14 @@
#ifndef SKYITEM_H_
#define SKYITEM_H_
-#include <QSGNode>
-#include <QQuickItem>
+#include <QSGOpacityNode>
//#include "skymaplite.h"
class SkyComponent;
-class Projector;
class SkyMapLite;
class QQuickItem;
+class RootNode;
+class SkyNode;
/** @class SkyItem
*
@@ -36,40 +36,27 @@ class QQuickItem;
*@version 1.0
*/
-class SkyItem : public QQuickItem {
+class SkyItem : public QSGOpacityNode {
- Q_OBJECT
-
-protected:
+public:
/**
- *Constructor, initializes m_parentComponent (a pointer to SkyComponent, which asked to initialize
- * this SkyItem).
+ *Constructor, add SkyItem to parent in a node tree
*
- * @param parent a pointer to SkyItem's data and visual parent
+ * @param parent a pointer to SkyItem's parent node
*/
- /* @param parentComponent a pointer to SkyComponent, which asked to initialize this SkyItem*/
- explicit SkyItem(QQuickItem* parent = 0);
+ explicit SkyItem(RootNode *rootNode = 0);
-public:
- /* @short Get the component that asked to instantiate this SkyItem
- *
- *@return a pointer to the parent component.
+ virtual void update() =0;
- 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; } */
+ void hide();
+ void show();
-public slots:
- /** Called whenever parent's width or height are changed.
- */
- void resizeItem();
+ inline RootNode *rootNode() { return m_rootNode; }
private:
- SkyMapLite* m_skyMapLite;
- //SkyComponent* m_parentComponent;
+ RootNode *m_rootNode;
+ QVector<SkyNode *>m_skyNodes;
};
#endif
diff --git a/kstars/kstarslite/skyitems/skynodes/horizonnode.cpp b/kstars/kstarslite/skyitems/skynodes/horizonnode.cpp
index 43c6cb7..526f2af 100644
--- a/kstars/kstarslite/skyitems/skynodes/horizonnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/horizonnode.cpp
@@ -4,7 +4,7 @@
#include "ksutils.h"
HorizonNode::HorizonNode(QList<SkyPoint*>& pointList)
- :SkyNode(0),m_pointList(pointList), m_polygonNode(new PolyNode)
+ :SkyNode(),m_pointList(pointList), m_polygonNode(new PolyNode)
{
appendChildNode(m_polygonNode);
}
@@ -16,10 +16,7 @@ void HorizonNode::update() {
QColor color = KStarsData::Instance()->colorScheme()->colorNamed( "HorzColor" );
- if(m_polygonNode->getColor() != color) {
- m_polygonNode->setColor(color);
- }
-
+ m_polygonNode->setColor(color);
m_polygonNode->setLineWidth(2);
//QVector<Vector2f> ground = projector()->groundPoly(labelPoint, drawLabel);
diff --git a/kstars/kstarslite/skyitems/skynodes/horizonnode.h b/kstars/kstarslite/skyitems/skynodes/horizonnode.h
index 9d84a64..70b3e9f 100644
--- a/kstars/kstarslite/skyitems/skynodes/horizonnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/horizonnode.h
@@ -30,10 +30,6 @@ public:
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;
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
index 1c08eb4..e80933f 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
@@ -1,5 +1,5 @@
/** *************************************************************************
- LineNode.cpp - K Desktop Planetarium
+ linenode.cpp - K Desktop Planetarium
-------------------
begin : 05/05/2016
copyright : (C) 2016 by Artem Fedoskin
@@ -17,9 +17,9 @@
#include "linenode.h"
#include <QSGFlatColorMaterial>
#include "skymaplite.h"
+
#include "projections/projector.h"
#include <QLinkedList>
-//#include <forward_list>
LineNode::LineNode(LineList *lineList)
:m_lineList(lineList), m_material(new QSGFlatColorMaterial),
@@ -48,13 +48,24 @@ void LineNode::setDrawStyle(Qt::PenStyle style) {
m_drawStyle = style;
}
+void LineNode::setStyle(QColor color, int width, Qt::PenStyle drawStyle) {
+ setColor(color);
+ setWidth(width);
+ setDrawStyle(drawStyle);
+}
+
void LineNode::hide() {
setOpacity(0);
markDirty(QSGNode::DirtyOpacity);
}
-void LineNode::updateGeometry() {
+void LineNode::show() {
setOpacity(1);
+ markDirty(QSGNode::DirtyOpacity);
+}
+
+void LineNode::updateGeometry() {
+
SkyList *points = m_lineList->points();
m_geometry->setDrawingMode(GL_LINES);
@@ -74,7 +85,7 @@ void LineNode::updateGeometry() {
SkyPoint* pThis = points->at( j );
oThis2 = oThis = m_proj->toScreen( pThis, true, &isVisible );
// & with the result of checkVisibility to clip away things below horizon
- //isVisible &= m_proj->checkVisibility(pThis);
+ isVisible &= m_proj->checkVisibility(pThis);
bool doSkip = false;
/*if( skipList ) {
doSkip = skipList->skip(j);
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
index 8b70b60..727ffe1 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
@@ -1,5 +1,5 @@
/** *************************************************************************
- LineNode.h - K Desktop Planetarium
+ linenode.h - K Desktop Planetarium
-------------------
begin : 05/05/2016
copyright : (C) 2016 by Artem Fedoskin
@@ -45,12 +45,17 @@ public:
* @short setSize update size of LineNode with the given parameter
* @param size new size of LineNode
*/
+
void setColor(QColor color);
void setWidth(int width);
+ void setDrawStyle(Qt::PenStyle drawStyle);
+
+ void setStyle(QColor color, int width, Qt::PenStyle drawStyle);
+
void updateGeometry();
inline LineList *lineList() { return m_lineList; }
void hide();
- void setDrawStyle(Qt::PenStyle drawStyle);
+ void show();
private:
QSGGeometryNode *m_geometryNode;
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
index 094d772..3c94527 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
@@ -18,7 +18,7 @@
#include <QQuickWindow>
#include "pointnode.h"
-#include "../rootnodes/rootnode.h"
+#include "kstarslite/skyitems/rootnode.h"
PointNode::PointNode(RootNode* p, char sp, float size)
:spType(sp), texture(new QSGSimpleTextureNode), m_rootNode(p)
@@ -29,12 +29,15 @@ PointNode::PointNode(RootNode* p, char sp, float size)
void PointNode::setSize(float size) {
int isize = qMin(static_cast<int>(size), 14);
- texture->setTexture(m_rootNode->getCachedTexture(isize, spType));
- //markDirty(QSGNode::DirtyMaterial);
+ if(size != m_size) {
+ texture->setTexture(m_rootNode->getCachedTexture(isize, spType));
+ //markDirty(QSGNode::DirtyMaterial);
- QSize tSize = texture->texture()->textureSize();
- QRectF oldRect = texture->rect();
- texture->setRect(QRect(oldRect.x(),oldRect.y(),tSize.width(),tSize.height()));
+ QSize tSize = texture->texture()->textureSize();
+ QRectF oldRect = texture->rect();
+ texture->setRect(QRect(oldRect.x(),oldRect.y(),tSize.width(),tSize.height()));
+ m_size = size;
+ }
}
void PointNode::show() {
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
index 6c4fe10..f1ced54 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
@@ -56,6 +56,7 @@ private:
QSGSimpleTextureNode *texture;
//parentNode holds texture cache
RootNode* m_rootNode;
+ float m_size;
};
#endif
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
index 7c1431a..b3738ff 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
@@ -15,26 +15,18 @@
***************************************************************************/
#include <QSGGeometryNode>
+#include <QSGGeometry>
#include <QSGFlatColorMaterial>
-#include <QSGSimpleTextureNode>
-#include <QPainter>
+#include <QPolygon>
#include "polynode.h"
-#include "skymaplite.h"
-#include "kstarsdata.h"
-#include <stdio.h>
-#include <stdlib.h>
+//#include <stdio.h>
+//#include <stdlib.h>
+
extern "C"
{
#include "libtess/tessellate.h"
}
-/*
-#include "qquickwindow.h"
-#include "triangle/include/tpp_interface.hpp"
-#include "polypartition/polypartition.h"
-#include "poly2tri/poly2tri.h"*/
-
-//using namespace tpp;
PolyNode::PolyNode()
:m_geometryNode(new QSGGeometryNode), m_geometry(0),
@@ -51,8 +43,17 @@ PolyNode::PolyNode()
}
void PolyNode::setColor(QColor color) {
- m_material->setColor(color);
- m_geometryNode->markDirty(QSGNode::DirtyMaterial);
+ if(color != m_material->color()) {
+ m_material->setColor(color);
+ m_geometryNode->markDirty(QSGNode::DirtyMaterial);
+ }
+}
+
+void PolyNode::setLineWidth(int width) {
+ if(width != m_geometry->lineWidth()) {
+ m_geometry->setLineWidth(width);
+ m_geometryNode->markDirty(QSGNode::DirtyGeometry);
+ }
}
void PolyNode::updateGeometry(QPolygonF polygon, bool filled) {
@@ -98,7 +99,7 @@ void PolyNode::updateGeometry(QPolygonF polygon, bool filled) {
QSGGeometry::Point2D * vertex = m_geometry->vertexDataAsPoint2D ();
for (i=0; i<3 * ntris; ++i) {
- int tris = tris_out[i];
+ //int tris = tris_out[i];
vertex[i].x = coordinates_out[tris_out[i]*2];
vertex[i].y = coordinates_out[tris_out[i]*2+1];
}
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
index 1799cb4..0be2d91 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
@@ -16,8 +16,6 @@
#ifndef POLYNODE_H_
#define POLYNODE_H_
#include <QSGOpacityNode>
-#include <QSGGeometry>
-#include <QSGFlatColorMaterial>
/** @class PolyNode
*
@@ -29,21 +27,19 @@
*@version 1.0
*/
-class RootNode;
class QSGGeometryNode;
class QSGGeometry;
+class QSGFlatColorMaterial;
class PolyNode : public QSGOpacityNode {
public:
PolyNode();
void setColor(QColor color);
- inline void setLineWidth(int width) { m_geometry->setLineWidth(width); }
+ void setLineWidth(int width);
void updateGeometry(QPolygonF polygon, bool filled);
- inline QColor getColor() { return m_material->color(); }
-
void show();
void hide();
private:
diff --git a/kstars/kstarslite/skyitems/skynodes/planetnode.cpp b/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
index 23e6096..0ebe885 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
@@ -51,7 +51,7 @@ PlanetNode::PlanetNode(KSPlanetBase* pb, RootNode* parentNode)
}
void PlanetNode::update() {
- KSPlanetBase * planet = static_cast<KSPlanetBase *>(m_skyObject);
+ KSPlanetBase * planet = static_cast<KSPlanetBase *>(skyObject());
const Projector * proj = projector();
if( !proj->checkVisibility(planet) ) {
@@ -145,7 +145,7 @@ void PlanetNode::changePos(QPointF pos) {
//Matrix has to be rotated between assigning x and y and translating it by the half
//of size of the planet. Otherwise the image will don't rotate at all or rotate around
//the top-left corner
- m.rotate(projector()->findPA( m_skyObject, pos.x(), pos.y()), 0, 0, 1);
+ m.rotate(projector()->findPA( skyObject(), pos.x(), pos.y()), 0, 0, 1);
} else {
size = m_point->size();
}
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
index f3f81e4..3d445b1 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
@@ -13,15 +13,13 @@
* (at your option) any later version. *
* *
***************************************************************************/
+#include "skyobject.h"
+#include "Options.h"
-#include <QImage>
-#include <QQuickWindow>
+#include <QSGSimpleTextureNode>
-#include "skymaplite.h"
#include "pointsourcenode.h"
-#include "skyobject.h"
#include "nodes/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
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
index cc3d907..1d1acba 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
@@ -15,7 +15,6 @@
***************************************************************************/
#ifndef POINTSOURCENODE_H_
#define POINTSOURCENODE_H_
-#include <QSGSimpleTextureNode>
#include "skynode.h"
class PlanetItemNode;
diff --git a/kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.cpp b/kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.cpp
deleted file mode 100644
index c4a0f41..0000000
--- a/kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#include <QSGTexture>
-#include <QQuickWindow>
-
-#include "linesrootnode.h"
-#include "skymaplite.h"
-#include "projections/projector.h"
-#include "../trixelnode.h"
-#include <QSGOpacityNode>
-
-LinesRootNode::LinesRootNode()
-{
-
-}
-
-void LinesRootNode::addLinesComponent(LineListIndex * linesComp, QString color, int width, Qt::PenStyle style) {
- QSGOpacityNode *node = new QSGOpacityNode;
- appendChildNode(node);
-
- m_lineIndexes.insert(node, linesComp);
- m_colors.append(color);
- m_widths.append(width);
- m_styles.append(style);
-
-
- LineListHash *trixels = linesComp->lineIndex();
-
- QHash< Trixel, LineListList *>::const_iterator i = trixels->begin();
- while( i != trixels->end()) {
-
- TrixelNode *trixel = new TrixelNode(i.key(), i.value());
- node->appendChildNode(trixel);
- //QString color = //m_colors[m_colors.size()-1];
- //int width = m_widths[m_widths.size()-1]; // TODO do something with this
- trixel->setStyle(color, width);
- ++i;
- }
-}
-
-void LinesRootNode::update() {
- QMap< QSGOpacityNode *, LineListIndex *>::const_iterator i = m_lineIndexes.begin();
- while( i != m_lineIndexes.end()) {
- QVector<Trixel> visTrixels;
- SkyMesh * mesh = SkyMesh::Instance();
- SkyMapLite *map = SkyMapLite::Instance();
- double radius = map->projector()->fov();
- if ( radius > 180.0 )
- radius = 180.0;
- if(mesh) {
- //mesh->aperture(map->focus(), radius);
- }
-
- MeshIterator region (mesh,DRAW_BUF);
- while ( region.hasNext() ) {
- visTrixels.append(region.next());
- }
-
- qDebug() << visTrixels.size();
-
- QSGOpacityNode * node = i.key();
- if(i.value()->selected()) {
- node->setOpacity(1);
- for(int c = 0; c < node->childCount(); ++c) {
- TrixelNode * trixel = static_cast<TrixelNode *>(node->childAtIndex(c));
- //if(visTrixels.contains(c)) {
- trixel->update();
- /* } else {
- trixel->hide();
- }*/
- }
- } else {
- node->setOpacity(0);
- }
- node->markDirty(QSGNode::DirtyOpacity);
- ++i;
- }
-}
diff --git a/kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.h b/kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.h
deleted file mode 100644
index 63889b8..0000000
--- a/kstars/kstarslite/skyitems/skynodes/rootnodes/linesrootnode.h
+++ /dev/null
@@ -1,43 +0,0 @@
-
-/** *************************************************************************
- LinesRootNode.h - K Desktop Planetarium
- -------------------
- begin : 14/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 LINESROOTNODE_H_
-#define LINESROOTNODE_H_
-#include "linelistindex.h"
-#include "rootnode.h"
-
-/** @class LinesRootNode
- *
- * A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
- * Upon construction LinesRootNode 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
- *@version 1.0
- */
-
-class LinesRootNode : public QSGNode { //Clipping under construction
-public:
- LinesRootNode();
- void addLinesComponent(LineListIndex * linesList, QString color, int width, Qt::PenStyle style);
- void update();
-private:
- QMap<QSGOpacityNode *, LineListIndex *> m_lineIndexes;
- QVector<QString> m_colors;
- QVector<int> m_widths;
- QVector<Qt::PenStyle> m_styles;
-};
-#endif
diff --git a/kstars/kstarslite/skyitems/skynodes/rootnodes/rootnode.cpp b/kstars/kstarslite/skyitems/skynodes/rootnodes/rootnode.cpp
deleted file mode 100644
index e8ea24a..0000000
--- a/kstars/kstarslite/skyitems/skynodes/rootnodes/rootnode.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <QSGTexture>
-#include <QQuickWindow>
-
-#include "rootnode.h"
-#include "skymaplite.h"
-#include "projections/projector.h"
-#include "../skynode.h"
-
-RootNode::RootNode()
- :m_clipNode(new QSGGeometryNode), m_skyMapLite(SkyMapLite::Instance()),
- m_clipGeometry(0)
-{
- genCachedTextures();
- updateClipPoly();
- // setIsRectangular(false);
-}
-
-void RootNode::genCachedTextures() {
- QVector<QVector<QPixmap*>> images = m_skyMapLite->getImageCache();
-
- QQuickWindow *win = m_skyMapLite->window();
-
- m_textureCache = QVector<QVector<QSGTexture*>> (images.length());
-
- for(int i = 0; i < m_textureCache.length(); ++i) {
- int length = images[i].length();
- m_textureCache[i] = QVector<QSGTexture *>(length);
- for(int c = 1; c < length; ++c) {
- m_textureCache[i][c] = win->createTextureFromImage(images[i][c]->toImage());
- }
- }
-}
-
-QSGTexture* RootNode::getCachedTexture(int size, char spType) {
- return m_textureCache[SkyMapLite::Instance()->harvardToIndex(spType)][size];
-}
-
-void RootNode::appendSkyNode(SkyNode *skyNode) {
- m_skyNodes.append(skyNode);
- appendChildNode(skyNode);
-}
-
-void RootNode::prependSkyNode(SkyNode *skyNode) {
- m_skyNodes.append(skyNode);
- prependChildNode(skyNode);
-}
-
-void RootNode::removeSkyNode(SkyNode *skyNode) {
- removeChildNode(skyNode);
- m_skyNodes.removeOne(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) {
- m_clipPoly = newClip;
- }
- QVector<QPointF> triangles;
-
- for(int i = 1; i < m_clipPoly.size() - 1; ++i) {
- triangles.append(m_clipPoly[0]);
- triangles.append(m_clipPoly[i]);
- triangles.append(m_clipPoly[i+1]);
- }
-
- const int size = triangles.size();
- if(!m_clipGeometry) {
- m_clipGeometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D (),
- size);
- m_clipGeometry->setDrawingMode(GL_TRIANGLES);
- setGeometry(m_clipGeometry);
- } else {
- m_clipGeometry->allocate(size);
- }
-
- QSGGeometry::Point2D * vertex = m_clipGeometry->vertexDataAsPoint2D ();
- for (int i = 0; i < size; i++) {
- vertex[i].x = triangles[i].x();
- vertex[i].y = triangles[i].y();
- }
- m_clipNode->markDirty(QSGNode::DirtyGeometry);*/
-}
-
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.cpp b/kstars/kstarslite/skyitems/skynodes/skynode.cpp
index 69ba96a..2d74a0c 100644
--- a/kstars/kstarslite/skyitems/skynodes/skynode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/skynode.cpp
@@ -22,3 +22,9 @@ SkyNode::SkyNode(SkyObject * skyObject)
{
}
+
+SkyNode::SkyNode()
+ :m_skyObject(nullptr)
+{
+
+}
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.h b/kstars/kstarslite/skyitems/skynodes/skynode.h
index 5954e50..a49652f 100644
--- a/kstars/kstarslite/skyitems/skynodes/skynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/skynode.h
@@ -41,6 +41,7 @@ public:
* @param skyObject that is represented on the SkyMapLIte
*/
SkyNode(SkyObject * skyObject);
+ SkyNode();
/** @short short function that returns pointer to the current projector
* @return pointer to current projector of SkyMapLite
*/
@@ -65,21 +66,19 @@ public:
virtual void hide() =0;
/**
- * @short changePos changes the position of SkyNode on SkyMapLite
+ * @short changes the position of SkyNode on SkyMapLite. Has to be overriden by the classes
+ * that support moving
* @param pos new position
*/
- virtual void changePos(QPointF pos) =0;
+ virtual void changePos(QPointF pos) { }
/**
* @short returns SkyObject associated with this SkyNode
* @return pointer to the object of type SkyObject
*/
- SkyObject * getSkyObject() const { return m_skyObject; }
+ SkyObject * skyObject() const { return m_skyObject; }
protected:
SkyObject * m_skyObject;
-private:
- //SkyMapLite * m_skyMapLite;
- //const Projector * m_proj;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp b/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp
index 10cd3be..03410cc 100644
--- a/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp
@@ -26,7 +26,7 @@
#include <QSGOpacityNode>
TrixelNode::TrixelNode(Trixel trixelId, LineListList *linesList)
- :SkyNode(0), trixel(trixelId), m_linesLists(linesList), m_opacity(new QSGOpacityNode)
+ :SkyNode(), trixel(trixelId), m_linesLists(linesList), m_opacity(new QSGOpacityNode)
{
appendChildNode(m_opacity);
for(int i = 0; i < m_linesLists->size(); ++i) {
@@ -35,20 +35,25 @@ TrixelNode::TrixelNode(Trixel trixelId, LineListList *linesList)
}
}
-void TrixelNode::setStyle(QString color, int width) {
- for(int i = 0; i < m_opacity->childCount(); ++i) {
- LineNode *ln = static_cast<LineNode *>(m_opacity->childAtIndex(i));
- ln->setColor(KStarsData::Instance()->colorScheme()->colorNamed( color ) );
- ln->setWidth(width);
+void TrixelNode::setStyle(QString color, int width, Qt::PenStyle style) {
+ QSGNode *n = m_opacity->firstChild();
+ while(n != 0) {
+ LineNode *ln = static_cast<LineNode *>(n);
+ ln->setStyle(KStarsData::Instance()->colorScheme()->colorNamed( color ), width, style);
+ n = n->nextSibling();
}
}
void TrixelNode::update() {
- m_opacity->setOpacity(1);
+ show();
DrawID drawID = SkyMesh::Instance()->drawID();
//UpdateID updateID = KStarsData::Instance()->updateID();
- for(int i = 0; i < m_opacity->childCount(); ++i) {
- LineNode * lines = static_cast<LineNode *>(m_opacity->childAtIndex(i));
+ //for(int i = 0; i < m_opacity->childCount(); ++i) {
+ QSGNode *n = m_opacity->firstChild();
+ while(n != 0) {
+ LineNode * lines = static_cast<LineNode *>(n);
+ n = n->nextSibling();
+
LineList * lineList = lines->lineList();
if ( lineList->drawID == drawID ) {
lines->hide();
@@ -61,4 +66,10 @@ void TrixelNode::update() {
void TrixelNode::hide() {
m_opacity->setOpacity(0);
+ m_opacity->markDirty(QSGNode::DirtyOpacity);
+}
+
+void TrixelNode::show() {
+ m_opacity->setOpacity(1);
+ m_opacity->markDirty(QSGNode::DirtyOpacity);
}
diff --git a/kstars/kstarslite/skyitems/skynodes/trixelnode.h b/kstars/kstarslite/skyitems/skynodes/trixelnode.h
index d970a4e..9ca0f00 100644
--- a/kstars/kstarslite/skyitems/skynodes/trixelnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/trixelnode.h
@@ -47,11 +47,12 @@ public:
*/
TrixelNode(Trixel trixel, LineListList *lineIndex);
- void setStyle(QString color, int width);
+ void setStyle(QString color, int width, Qt::PenStyle style);
virtual void changePos(QPointF pos) {}
virtual void update() override;
virtual void hide() override;
+ void show();
private:
QSGOpacityNode *m_opacity;
Trixel trixel;
diff --git a/kstars/oal/log.cpp b/kstars/oal/log.cpp
index 7b9e5ba..e4e5b8f 100644
--- a/kstars/oal/log.cpp
+++ b/kstars/oal/log.cpp
@@ -187,7 +187,7 @@ void OAL::Log::writeTarget( SkyObject *o ) {
}
writer->writeStartElement( "constellation" );
writer->writeCDATA(
- KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( o ) );
+ KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( o ) );
writer->writeEndElement();
writer->writeStartElement( "notes" );
writer->writeCDATA( o->notes() );
diff --git a/kstars/printing/detailstable.cpp b/kstars/printing/detailstable.cpp
index 86a302b..871d8e9 100644
--- a/kstars/printing/detailstable.cpp
+++ b/kstars/printing/detailstable.cpp
@@ -309,13 +309,13 @@ void DetailsTable::createGeneralTable(SkyObject *obj)
//Common to all types:
if(obj->type() == SkyObject::CONSTELLATION )
{
- objTypeVal = KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName(obj);
+ objTypeVal = KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName(obj);
}
else
{
objTypeVal = i18nc("%1 type of sky object (planet, asteroid etc), %2 name of a constellation", "%1 in %2", objTypeVal,
- KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName(obj));
+ KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName(obj));
}
QVector<QTextLength> constraints;
diff --git a/kstars/skycomponents/asteroidscomponent.cpp b/kstars/skycomponents/asteroidscomponent.cpp
index 7f515d8..c2a5446 100644
--- a/kstars/skycomponents/asteroidscomponent.cpp
+++ b/kstars/skycomponents/asteroidscomponent.cpp
@@ -25,15 +25,12 @@
#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"
-#ifdef KSTARS_LITE
-#include "skymaplite.h"
-#else
+#ifndef KSTARS_LITE
#include "skymap.h"
#endif
#include "skypainter.h"
@@ -95,11 +92,6 @@ void AsteroidsComponent::loadData()
emitProgressText( i18n("Loading asteroids") );
- // Clear Asteroid nodes in AsteroidsItem
-#ifdef KSTARS_LITE
- AsteroidsItem * asteroidsItem = SkyMapLite::Instance()->getAsteroidsItem();
- asteroidsItem->clear();
-#endif
// Clear lists
m_ObjectList.clear();
objectNames( SkyObject::ASTEROID ).clear();
@@ -196,9 +188,6 @@ void AsteroidsComponent::loadData()
// Add name to the list of object names
objectNames(SkyObject::ASTEROID).append(name);
}
-#ifdef KSTARS_LITE
- asteroidsItem->setAsteroidsList(&m_ObjectList);
-#endif
}
diff --git a/kstars/skycomponents/cometscomponent.cpp b/kstars/skycomponents/cometscomponent.cpp
index c7ff887..87a4fa9 100644
--- a/kstars/skycomponents/cometscomponent.cpp
+++ b/kstars/skycomponents/cometscomponent.cpp
@@ -25,8 +25,6 @@
#include "cometscomponent.h"
#include "solarsystemcomposite.h"
-#include "kstarslite/skyitems/cometsitem.h"
-
#include "Options.h"
#include "skyobjects/kscomet.h"
#include "ksutils.h"
@@ -90,11 +88,6 @@ void CometsComponent::loadData() {
long double JD;
float M1, M2, K1, K2, diameter, albedo, rot_period, period;
-#ifdef KSTARS_LITE
- CometsItem * cometsItem = SkyMapLite::Instance()->getCometsItem();
- cometsItem->clear();
-#endif
-
emitProgressText(i18n("Loading comets"));
objectNames(SkyObject::COMET).clear();
@@ -180,9 +173,6 @@ void CometsComponent::loadData() {
// Add *short* name to the list of object names
objectNames( SkyObject::COMET ).append( com->name() );
-#ifdef KSTARS_LITE
- cometsItem->addComet(com);
-#endif
}
}
diff --git a/kstars/skycomponents/constellationboundarylines.cpp b/kstars/skycomponents/constellationboundarylines.cpp
index 7d176d3..fa018f1 100644
--- a/kstars/skycomponents/constellationboundarylines.cpp
+++ b/kstars/skycomponents/constellationboundarylines.cpp
@@ -29,7 +29,6 @@
#include "kstarsdata.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/linesitem.h"
#else
#include "skymap.h"
#endif
@@ -148,9 +147,6 @@ ConstellationBoundaryLines::ConstellationBoundaryLines( SkyComposite *parent )
appendLine( lineList );
if( polyList )
appendPoly( polyList, idxFile, verbose );
-#ifdef KSTARS_LITE
- SkyMapLite::Instance()->getLinesItem()->addLinesComponent( this, "CBoundColor", 1, Qt::SolidLine );
-#endif
}
bool ConstellationBoundaryLines::selected()
diff --git a/kstars/skycomponents/constellationlines.cpp b/kstars/skycomponents/constellationlines.cpp
index aae5370..16c9ab5 100644
--- a/kstars/skycomponents/constellationlines.cpp
+++ b/kstars/skycomponents/constellationlines.cpp
@@ -31,7 +31,6 @@
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/linesitem.h"
#else
#include "skymap.h"
#endif
@@ -113,10 +112,6 @@ ConstellationLines::ConstellationLines( SkyComposite *parent, CultureList* cultu
if( lineList )
appendLine( lineList );
-#ifdef KSTARS_LITE
- SkyMapLite::Instance()->getLinesItem()->addLinesComponent( this, "CLineColor", 1, Qt::SolidLine );
-#endif
-
m_reindexInterval = StarObject::reindexInterval( maxPM );
//printf("CLines: maxPM = %6.1f milliarcsec/year\n", maxPM );
//printf("CLines: Update Interval = %6.1f years\n", m_reindexInterval * 100.0 );
diff --git a/kstars/skycomponents/ecliptic.cpp b/kstars/skycomponents/ecliptic.cpp
index f75d856..78c2777 100644
--- a/kstars/skycomponents/ecliptic.cpp
+++ b/kstars/skycomponents/ecliptic.cpp
@@ -22,7 +22,6 @@
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/linesitem.h"
#else
#include "skymap.h"
#endif
@@ -63,9 +62,6 @@ Ecliptic::Ecliptic(SkyComposite *parent ) :
}
appendLine( lineList );
}
-#ifdef KSTARS_LITE
- SkyMapLite::Instance()->getLinesItem()->addLinesComponent( this, "EclColor", 1, Qt::SolidLine );
-#endif
}
bool Ecliptic::selected()
diff --git a/kstars/skycomponents/equator.cpp b/kstars/skycomponents/equator.cpp
index ceb9c13..3d7f242 100644
--- a/kstars/skycomponents/equator.cpp
+++ b/kstars/skycomponents/equator.cpp
@@ -21,7 +21,6 @@
#include "kstarsdata.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/linesitem.h"
#else
#include "skymap.h"
#endif
@@ -56,9 +55,6 @@ Equator::Equator(SkyComposite *parent ) :
}
appendLine( lineList );
}
-#ifdef KSTARS_LITE
- SkyMapLite::Instance()->getLinesItem()->addLinesComponent( this, "EqColor", 1, Qt::SolidLine );
-#endif
}
bool Equator::selected()
diff --git a/kstars/skycomponents/equatorialcoordinategrid.cpp b/kstars/skycomponents/equatorialcoordinategrid.cpp
index 0d3fab0..bb1b4ed 100644
--- a/kstars/skycomponents/equatorialcoordinategrid.cpp
+++ b/kstars/skycomponents/equatorialcoordinategrid.cpp
@@ -26,7 +26,6 @@
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/linesitem.h"
#else
#include "skymap.h"
#endif
@@ -92,9 +91,6 @@ EquatorialCoordinateGrid::EquatorialCoordinateGrid( SkyComposite *parent )
appendLine( lineList );
}
}
-#ifdef KSTARS_LITE
- SkyMapLite::Instance()->getLinesItem()->addLinesComponent( this, "EquatorialGridColor", 1, Qt::DotLine );
-#endif
summary();
}
diff --git a/kstars/skycomponents/horizoncomponent.cpp b/kstars/skycomponents/horizoncomponent.cpp
index 7a33808..e9d723f 100644
--- a/kstars/skycomponents/horizoncomponent.cpp
+++ b/kstars/skycomponents/horizoncomponent.cpp
@@ -26,7 +26,6 @@
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/horizonitem.h"
#else
#include "skymap.h"
#endif
@@ -55,9 +54,6 @@ HorizonComponent::HorizonComponent(SkyComposite *parent )
o->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
pointList().append( o );
}
-#ifdef KSTARS_LITE
- SkyMapLite::Instance()->getHorizonItem()->setHorizonComp(this);
-#endif
}
HorizonComponent::~HorizonComponent()
diff --git a/kstars/skycomponents/horizontalcoordinategrid.cpp b/kstars/skycomponents/horizontalcoordinategrid.cpp
index 60ac727..127bcd8 100644
--- a/kstars/skycomponents/horizontalcoordinategrid.cpp
+++ b/kstars/skycomponents/horizontalcoordinategrid.cpp
@@ -26,7 +26,6 @@
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/linesitem.h"
#else
#include "skymap.h"
#endif
@@ -97,9 +96,6 @@ HorizontalCoordinateGrid::HorizontalCoordinateGrid( SkyComposite *parent )
appendLine( lineList );
}
}
-#ifdef KSTARS_LITE
- SkyMapLite::Instance()->getLinesItem()->addLinesComponent( this, "HorizontalGridColor", 1, Qt::DotLine );
-#endif
summary();
}
diff --git a/kstars/skycomponents/planetmoonscomponent.cpp b/kstars/skycomponents/planetmoonscomponent.cpp
index 3be9b45..e60a5fc 100644
--- a/kstars/skycomponents/planetmoonscomponent.cpp
+++ b/kstars/skycomponents/planetmoonscomponent.cpp
@@ -60,11 +60,6 @@ PlanetMoonsComponent::PlanetMoonsComponent( SkyComposite *p,
int nmoons = pmoons->nMoons();
for ( int i=0; i<nmoons; ++i )
objectNames(SkyObject::MOON).append( pmoons->name(i) );
-
-#ifdef KSTARS_LITE
- SkyMapLite *map = SkyMapLite::Instance();
- map->getPlanetsItem()->addMoons(this);
-#endif
}
PlanetMoonsComponent::~PlanetMoonsComponent()
diff --git a/kstars/skycomponents/skylabeler.cpp b/kstars/skycomponents/skylabeler.cpp
index 425e75e..a574906 100644
--- a/kstars/skycomponents/skylabeler.cpp
+++ b/kstars/skycomponents/skylabeler.cpp
@@ -212,9 +212,10 @@ void SkyLabeler::getMargins( const QString& text, float *left,
void SkyLabeler::reset( SkyMap* skyMap )
{
-#ifndef KSTARS_LITE
+
// ----- Set up Projector ---
m_proj = skyMap->projector();
+#ifdef KSTARS_LITE
// ----- Set up Painter -----
if( m_p.isActive() )
m_p.end();
@@ -230,7 +231,7 @@ void SkyLabeler::reset( SkyMap* skyMap )
m_skyFont = m_p.font();
m_fontMetrics = QFontMetrics( m_skyFont );
m_minDeltaX = (int) m_fontMetrics.width("MMMMM");
-
+#endif
// ----- Set up Zoom Dependent Offset -----
m_offset = SkyLabeler::ZoomOffset();
@@ -274,7 +275,6 @@ void SkyLabeler::reset( SkyMap* skyMap )
for (int i = 0; i < labelList.size(); i++) {
labelList[ i ].clear();
}
-#endif
}
void SkyLabeler::draw(QPainter& p)
diff --git a/kstars/skycomponents/skymapcomposite.cpp b/kstars/skycomponents/skymapcomposite.cpp
index c745cbc..5333ad0 100644
--- a/kstars/skycomponents/skymapcomposite.cpp
+++ b/kstars/skycomponents/skymapcomposite.cpp
@@ -113,6 +113,7 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent ) :
addComponent( m_StarHopRouteList = new TargetListComponent( this , 0, QPen() ), 130 );
addComponent( m_Satellites = new SatellitesComponent( this ), 7 );
addComponent( m_Supernovae = new SupernovaeComponent( this ), 7 );
+ SkyMapLite::Instance()->loadingFinished();
#else
addComponent( m_MilkyWay = new MilkyWay( this ), 50);
addComponent( m_Stars = StarComponent::Create( this ), 10);
@@ -700,11 +701,6 @@ SatellitesComponent* SkyMapComposite::satellites() {
return m_Satellites;
}
-SolarSystemComposite* SkyMapComposite::solarSystemComposite()
-{
- return m_SolarSystem;
-}
-
SupernovaeComponent* SkyMapComposite::supernovaeComponent()
{
return m_Supernovae;
diff --git a/kstars/skycomponents/skymapcomposite.h b/kstars/skycomponents/skymapcomposite.h
index 5561e9e..af76821 100644
--- a/kstars/skycomponents/skymapcomposite.h
+++ b/kstars/skycomponents/skymapcomposite.h
@@ -173,6 +173,19 @@ public:
SatellitesComponent* satellites();
SupernovaeComponent* supernovaeComponent();
ArtificialHorizonComponent* artificialHorizon();
+ inline HorizonComponent* horizon() { return m_Horizon; }
+
+ inline ConstellationBoundaryLines* constellationBoundary() { return m_CBoundLines; }
+ inline ConstellationLines* constellationLines() { return m_CLines; }
+
+ inline Ecliptic* ecliptic() { return m_Ecliptic; }
+ inline Equator* equator() { return m_Equator; }
+
+ inline EquatorialCoordinateGrid* equatorialCoordGrid() { return m_EquatorialCoordinateGrid; }
+ inline HorizontalCoordinateGrid* horizontalCoordGrid() { return m_HorizontalCoordinateGrid; }
+
+ inline SolarSystemComposite* solarSystemComposite() { return m_SolarSystem; }
+
//Accessors for StarComponent
SkyObject* findStarByGenetiveName( const QString name );
@@ -196,11 +209,7 @@ public:
QList<SkyComponent*> customCatalogs();
- ConstellationBoundaryLines* getConstellationBoundary() { return m_CBoundLines; }
inline TargetListComponent *getStarHopRouteList() { return m_StarHopRouteList; }
-
- SolarSystemComposite *solarSystemComposite();
-
signals:
void progressText( const QString &message );
diff --git a/kstars/skycomponents/solarsystemcomposite.cpp b/kstars/skycomponents/solarsystemcomposite.cpp
index a327321..eb8f2da 100644
--- a/kstars/skycomponents/solarsystemcomposite.cpp
+++ b/kstars/skycomponents/solarsystemcomposite.cpp
@@ -43,22 +43,39 @@ SolarSystemComposite::SolarSystemComposite(SkyComposite *parent ) :
m_Earth = new KSPlanet( I18N_NOOP( "Earth" ), QString(), QColor( "white" ), 12756.28 /*diameter in km*/ );
m_Sun = new KSSun();
- addComponent( new SolarSystemSingleComponent( this, m_Sun, Options::showSun ), 2 );
+ SolarSystemSingleComponent *sun = new SolarSystemSingleComponent( this, m_Sun, Options::showSun );
+ addComponent( sun, 2 );
m_Moon = new KSMoon();
- addComponent( new SolarSystemSingleComponent( this, m_Moon, Options::showMoon ), 3 );
- addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::MERCURY ), Options::showMercury ), 4 );
- addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::VENUS ), Options::showVenus ), 4 );
- addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::MARS ), Options::showMars ), 4 );
+ SolarSystemSingleComponent *moon = new SolarSystemSingleComponent( this, m_Moon, Options::showMoon );
+ addComponent( moon, 3 );
+ SolarSystemSingleComponent *mercury = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::MERCURY ), Options::showMercury );
+ addComponent( mercury, 4 );
+ SolarSystemSingleComponent *venus = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::VENUS ), Options::showVenus );
+ addComponent( venus, 4 );
+ SolarSystemSingleComponent *mars = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::MARS ), Options::showMars );
+ addComponent( mars, 4 );
SolarSystemSingleComponent *jup = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::JUPITER ), Options::showJupiter );
addComponent( jup, 4 );
m_JupiterMoons = new PlanetMoonsComponent( this, jup, KSPlanetBase::JUPITER);
addComponent( m_JupiterMoons, 5 );
SolarSystemSingleComponent *sat = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::SATURN ), Options::showSaturn );
addComponent( sat, 4 );
- addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::URANUS ), Options::showUranus ), 4 );
- addComponent( new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::NEPTUNE ), Options::showNeptune ), 4 );
+ SolarSystemSingleComponent *uranus = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::URANUS ), Options::showUranus );
+ addComponent( uranus, 4 );
+ SolarSystemSingleComponent *nep = new SolarSystemSingleComponent( this, new KSPlanet( KSPlanetBase::NEPTUNE ), Options::showNeptune );
+ addComponent( nep, 4 );
//addComponent( new SolarSystemSingleComponent( this, new KSPluto(), Options::showPluto ) );
+ m_planets.append(sun);
+ m_planets.append(moon);
+ m_planets.append(mercury);
+ m_planets.append(venus);
+ m_planets.append(mars);
+ m_planets.append(sat);
+ m_planets.append(jup);
+ m_planets.append(uranus);
+ m_planets.append(nep);
+
addComponent( m_AsteroidsComponent = new AsteroidsComponent( this ), 7);
addComponent( m_CometsComponent = new CometsComponent( this ), 7);
}
@@ -135,3 +152,13 @@ AsteroidsComponent* SolarSystemComposite::asteroidsComponent()
{
return m_AsteroidsComponent;
}
+
+const QList<SolarSystemSingleComponent *>& SolarSystemComposite::planets() const {
+ return m_planets;
+}
+
+QList<PlanetMoonsComponent *> SolarSystemComposite::planetMoonsComponent() const
+{
+ return QList <PlanetMoonsComponent *>({m_JupiterMoons});
+}
+
diff --git a/kstars/skycomponents/solarsystemcomposite.h b/kstars/skycomponents/solarsystemcomposite.h
index d13148c..3b19d39 100644
--- a/kstars/skycomponents/solarsystemcomposite.h
+++ b/kstars/skycomponents/solarsystemcomposite.h
@@ -62,6 +62,10 @@ public:
AsteroidsComponent* asteroidsComponent();
+ QList<PlanetMoonsComponent *> planetMoonsComponent() const;
+
+ const QList<SolarSystemSingleComponent *>& planets() const;
+
private:
KSPlanet *m_Earth;
KSSun *m_Sun;
@@ -69,6 +73,7 @@ private:
PlanetMoonsComponent *m_JupiterMoons;
AsteroidsComponent *m_AsteroidsComponent;
CometsComponent *m_CometsComponent;
+ QList<SolarSystemSingleComponent *> m_planets;
};
#endif
diff --git a/kstars/skycomponents/solarsystemsinglecomponent.cpp b/kstars/skycomponents/solarsystemsinglecomponent.cpp
index 27b6ac6..ba482a6 100644
--- a/kstars/skycomponents/solarsystemsinglecomponent.cpp
+++ b/kstars/skycomponents/solarsystemsinglecomponent.cpp
@@ -27,7 +27,6 @@
#include "skyobjects/ksplanet.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
-#include "kstarslite/skyitems/planetsitem.h"
#else
#include "skymap.h"
#endif
@@ -49,10 +48,6 @@ 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()->getPlanetsItem()->addPlanet(this);
- #endif
}
SolarSystemSingleComponent::~SolarSystemSingleComponent()
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index 5908ea7..93539e2 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -30,12 +30,7 @@
#include "Options.h"
#include "skymesh.h"
-//SkyItems
-#include "kstarslite/skyitems/planetsitem.h"
-#include "kstarslite/skyitems/asteroidsitem.h"
-#include "kstarslite/skyitems/cometsitem.h"
-#include "kstarslite/skyitems/horizonitem.h"
-#include "kstarslite/skyitems/linesitem.h"
+#include "kstarslite/skyitems/rootnode.h"
#include "ksplanetbase.h"
#include "ksutils.h"
@@ -89,16 +84,12 @@ 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)),
- m_asteroidsItem(new AsteroidsItem(this)), m_cometsItem(new CometsItem(this)), pinch(false),
- m_linesItem(new LinesItem(this)), m_horizonItem(new HorizonItem(this))
+ nStarSizes(15), nSPclasses(7), pinch(false), m_loadingFinished(false)
{
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::AllButtons);
setFlag(ItemHasContents, true);
- m_horizonItem->setZ(1);
-
midMouseButtonDown = false;
mouseButtonDown = false;
slewing = false;
@@ -120,30 +111,22 @@ SkyMapLite::SkyMapLite(QQuickItem* parent)
initStarImages();
// Set pinstance to yourself
pinstance = this;
- /*textureCache = QVector<QVector<QSGTexture*>> (imageCache.length());
- for(int i = 0; i < textureCache.length(); ++i) {
- int length = imageCache[i].length();
- textureCache[i] = QVector<QSGTexture *>(length);
- for(int c = 1; c < length; ++c) {
- textureCache[i][c] = window()->createTextureFromImage(imageCache[i][c]->toImage());
- }
- }*/
}
QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
- /*if(!textureCache.length()) {
- textureCache = QVector<QVector<QSGTexture*>> (imageCache.length());
-
- for(int i = 0; i < textureCache.length(); ++i) {
- int length = imageCache[i].length();
- textureCache[i] = QVector<QSGTexture *>(length);
- for(int c = 1; c < length; ++c) {
- //textureCache[i][c] = window()->createTextureFromImage(imageCache[i][c]->toImage());
- }
+ Q_UNUSED(updatePaintNodeData);
+ RootNode *n = static_cast<RootNode*>(oldNode);
+
+ if(m_loadingFinished) {
+ if(!n) {
+ n = new RootNode();
+ } else {
+ n->update();
}
- }*/
- return oldNode;
+ }
+
+ return n;
}
QSGTexture* SkyMapLite::getCachedTexture(int size, char spType) {
@@ -428,24 +411,7 @@ void SkyMapLite::forceUpdate() {
m_skyMesh->index( &Focus, radius + 1.0, NO_PRECESS_BUF );
}
}
- //TODO: Move this check somewhere else (create a separate function)
- if(Options::showSolarSystem()) {
- if(!m_planetsItem->property("visible").toBool()) {
- m_planetsItem->setVisible(true);
- m_asteroidsItem->setVisible(true);
- m_cometsItem->setVisible(true);
- }
- m_planetsItem->update();
- m_asteroidsItem->update();
- m_cometsItem->update();
- } else {
- m_planetsItem->setVisible(false);
- m_asteroidsItem->setVisible(false);
- m_cometsItem->setVisible(false);
- }
-
- m_horizonItem->update();
- m_linesItem->update();
+ update();
}
void SkyMapLite::setupProjector() {
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 4560d0a..7208c58 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -231,37 +231,6 @@ public:
*/
void setZoomFactor(double factor);
- /**
- * @short Get PlanetsItem object
- * @return const pointer to m_planetsItem
- */
- inline PlanetsItem *getPlanetsItem() { return m_planetsItem; }
-
- /**
- * @short Get AsteroidsItem object
- * @return pointer to m_asteroidsItem
- */
- inline AsteroidsItem *getAsteroidsItem() { return m_asteroidsItem; }
-
- /**
- * @short Get CometsItem object
- * @return pointer to m_cometsItem
- */
- inline CometsItem *getCometsItem() { return m_cometsItem; }
-
- /**
- * @short Get HorizonItem object
- * @return pointer to m_horizonItem
- */
- inline HorizonItem *getHorizonItem() { return m_horizonItem; }
-
- /**
- * @short Get EquatorItem object
- * @return pointer to m_equatorItem
- */
- inline LinesItem *getLinesItem() { return m_linesItem; }
-
-
/** @short Call to set up the projector before update of SkyItems positions begins. */
void setupProjector();
@@ -284,6 +253,9 @@ public:
*/
QSGTexture* getCachedTexture(int size, char spType);
+ /** Called when SkyMapComposite finished loading all SkyComponents */
+ inline void loadingFinished() { m_loadingFinished = true; }
+
bool isSlewing() const;
// NOTE: This method is draw-backend independent.
@@ -318,7 +290,7 @@ public:
SkyPoint getCenterPoint();*/
public slots:
- /** Called whenever wrappers' width or height are changed. Probably will be used to
+ /** Called whenever wrappers' width or height are changed. Probably will be used to
* update positions of items.
*/
void resizeItem();
@@ -575,6 +547,9 @@ private:
KStarsData *data;
+ //True if SkyMapComposite has finished loading of SkyComponents
+ bool m_loadingFinished;
+
/** @short Coordinates of point under cursor. It's update in
* function mouseMoveEvent
*/
@@ -599,15 +574,6 @@ private:
static SkyMapLite *pinstance;
QQuickItem *m_SkyMapLiteWrapper;
- //SkyItems
- //Solar system
- PlanetsItem *m_planetsItem;
- AsteroidsItem *m_asteroidsItem;
- CometsItem *m_cometsItem;
-
- HorizonItem *m_horizonItem;
- LinesItem *m_linesItem;
-
static int starColorMode;
const SkyPoint *m_rulerStartPoint; // Good to keep the original ruler start-point for purposes of dynamic_cast
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index 280d5c0..7610910 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -347,7 +347,7 @@ void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
<< new QStandardItem( dec )
<< new QStandardItem( smag )
<< new QStandardItem( obj->typeName() )
- << new QStandardItem( KSUtils::constNameToAbbrev( KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( obj ) ) )
+ << new QStandardItem( KSUtils::constNameToAbbrev( KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( obj ) ) )
<< BestTime
<< new QStandardItem( alt )
<< new QStandardItem( az );
diff --git a/kstars/tools/obslistwizard.cpp b/kstars/tools/obslistwizard.cpp
index fe9b5cf..341a158 100644
--- a/kstars/tools/obslistwizard.cpp
+++ b/kstars/tools/obslistwizard.cpp
@@ -747,7 +747,7 @@ bool ObsListWizard::applyRegionFilter( SkyObject *o, bool doBuildList,
//select by constellation
if ( isItemSelected( i18n("by constellation"), olw->RegionList ) )
{
- QString c = KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( o );
+ QString c = KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName( o );
if ( isItemSelected( c, olw->ConstellationList ) )
{
if ( doBuildList )