summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-07-01 09:45:52 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-07-01 09:45:52 (GMT)
commitfc3f9cd7d614edb1d11a8dcf633f6053bd9e12cd (patch)
treee813a164a69da7422085210c27942b95cdad232b
parent44963f08338caf6c18f6855d3a694e9b0c38d804 (diff)
Added mechanism for deleting unused nodes to reduce memory consumption.
-rw-r--r--kstars/CMakeLists.txt12
-rw-r--r--kstars/kstarslite/skyitems/deepskyitem.cpp160
-rw-r--r--kstars/kstarslite/skyitems/deepskyitem.h2
-rw-r--r--kstars/kstarslite/skyitems/deepstaritem.cpp132
-rw-r--r--kstars/kstarslite/skyitems/deepstaritem.h1
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.cpp15
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.h1
-rw-r--r--kstars/kstarslite/skyitems/lines/eclipticitem.cpp1
-rw-r--r--kstars/kstarslite/skyitems/lines/equatoritem.cpp1
-rw-r--r--kstars/kstarslite/skyitems/lines/linesitem.cpp1
-rw-r--r--kstars/kstarslite/skyitems/lines/linesitem.h1
-rw-r--r--kstars/kstarslite/skyitems/lines/milkywayitem.cpp1
-rw-r--r--kstars/kstarslite/skyitems/lines/milkywayitem.h1
-rw-r--r--kstars/kstarslite/skyitems/rootnode.cpp10
-rw-r--r--kstars/kstarslite/skyitems/skynodes/deepskynode.cpp42
-rw-r--r--kstars/kstarslite/skyitems/skynodes/deepskynode.h4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp5
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp3
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp49
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.h5
-rw-r--r--kstars/kstarslite/skyitems/skynodes/satellitenode.cpp22
-rw-r--r--kstars/kstarslite/skyitems/skynodes/satellitenode.h5
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.cpp12
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.h9
-rw-r--r--kstars/kstarslite/skyitems/skynodes/supernovanode.cpp2
-rw-r--r--kstars/kstarslite/skyitems/skynodes/trixelnode.cpp28
-rw-r--r--kstars/kstarslite/skyitems/skynodes/trixelnode.h41
-rw-r--r--kstars/kstarslite/skyitems/staritem.cpp108
-rw-r--r--kstars/kstarslite/skyitems/staritem.h1
-rw-r--r--kstars/kstarslite/skyitems/typedeflite.h7
-rw-r--r--kstars/projections/projector.cpp2
-rw-r--r--kstars/skymaplite.cpp26
-rw-r--r--kstars/skymaplite.h21
33 files changed, 555 insertions, 176 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index ddb22ce..8795d5d 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -582,6 +582,7 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/skynodes/constellationartnode.cpp
kstarslite/skyitems/skynodes/satellitenode.cpp
kstarslite/skyitems/skynodes/supernovanode.cpp
+ kstarslite/skyitems/skynodes/trixelnode.cpp
#Nodes
kstarslite/skyitems/skynodes/nodes/pointnode.cpp
kstarslite/skyitems/skynodes/nodes/polynode.cpp
@@ -688,8 +689,6 @@ if(NOT BUILD_KSTARS_LITE)
)
endif(NOT BUILD_KSTARS_LITE)
-set(kstars_SRCS ${kstarslite_SRCS} ${kstarslite_RESOURCE}
- )
if(BUILD_KSTARS_LITE)
kconfig_add_kcfg_files(kstars_SRCS GENERATE_MOC ${kstars_KCFG_SRCS})
else()
@@ -737,7 +736,7 @@ add_library( KStarsLib STATIC ${indi_SRCS} ${fits_SRCS} ${ekos_SRCS} ${onlinepar
${libkstarswidgets_SRCS} ${libkstarscomponents_SRCS} ${libkstarstools_SRCS}
${kstars_extra_SRCS} ${kstars_gl_SRCS} ${kstars_projection_SRCS} ${xplanet_SRCS}
${kstars_options_SRCS} ${kstars_skyobjects_SRCS} ${kstars_dialogs_SRCS} ${oal_SRCS}
- ${printing_SRCS} ${kstars_SRCS} ${kstarslite_RESOURCE})
+ ${printing_SRCS} ${kstars_SRCS} ${kstarslite_SRCS})
# FIXME TODO
#target_include_directories(KStarsLib INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR}/>")
@@ -777,6 +776,10 @@ else(BUILD_KSTARS_LITE)
)
endif(BUILD_KSTARS_LITE)
+add_executable(kstars main.cpp)
+
+target_link_libraries(kstars KStarsLib)
+
if(NOT WIN32)
target_link_libraries(KStarsLib m)
endif(NOT WIN32)
@@ -812,9 +815,6 @@ ecm_add_app_icon(KSTARS_APP_SRCS ICONS
${CMAKE_CURRENT_SOURCE_DIR}/icons/128-apps-kstars.png
)
-add_executable(kstars ${KSTARS_APP_SRCS})
-target_link_libraries(kstars KStarsLib)
-
if(NOT BUILD_KSTARS_LITE)
install(TARGETS kstars ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/kstars/kstarslite/skyitems/deepskyitem.cpp b/kstars/kstarslite/skyitems/deepskyitem.cpp
index 3da3fe8..7e6a27e 100644
--- a/kstars/kstarslite/skyitems/deepskyitem.cpp
+++ b/kstars/kstarslite/skyitems/deepskyitem.cpp
@@ -95,14 +95,9 @@ DeepSkyItem::DeepSkyItem(DeepSkyComponent *dsoComp, RootNode *rootNode)
QSGNode *symbols = new QSGNode;
for(int c = 0; c < dsoList->size(); ++c) {
- DeepSkyObject *dso = dsoList->at(c);
- if(dso) {
- DSOSymbolNode *dsoSymbol = new DSOSymbolNode(dso, indexNode->m_color);
- symbols->appendChildNode(dsoSymbol);
- DeepSkyNode *dsoNode = new DeepSkyNode(dso, dsoSymbol,i.key(), indexNode->m_labelType);
- trixel->appendChildNode(dsoNode);
- }
+ DeepSkyObject *dso = dsoList->at(c);
+ trixel->m_nodes.append(QPair<SkyObject *, SkyNode *>(dso, 0));
}
trixel->m_symbols = symbols;
@@ -124,25 +119,53 @@ void DeepSkyItem::update() {
MeshIterator region( m_skyMesh, DRAW_BUF );
+ int count = 0;
+
drawFlag = Options::showMessier() &&
! ( Options::hideOnSlew() && Options::hideMessier() && SkyMapLite::IsSlewing() );
updateDeepSkyNode(m_Messier, drawFlag, "MessColor", &region, Options::showMessierImages() );
+ /*QSGNode *n = m_Messier->m_trixels->firstChild();
+ while(n != 0) {
+ count += n->childCount();
+ n = n->nextSibling();
+ }*/
+
drawFlag = Options::showNGC() &&
! ( Options::hideOnSlew() && Options::hideNGC() && SkyMapLite::IsSlewing() );
updateDeepSkyNode(m_NGC, drawFlag, "NGCColor", &region );
+ /*n = m_NGC->m_trixels->firstChild();
+ while(n != 0) {
+ count += n->childCount();
+ n = n->nextSibling();
+ }*/
+
drawFlag = Options::showIC() &&
! ( Options::hideOnSlew() && Options::hideIC() && SkyMapLite::IsSlewing() );
updateDeepSkyNode(m_IC, drawFlag, "ICColor", &region );
+ /*n = m_IC->m_trixels->firstChild();
+ while(n != 0) {
+ count += n->childCount();
+ n = n->nextSibling();
+ }*/
+
drawFlag = Options::showOther() &&
! ( Options::hideOnSlew() && Options::hideOther() && SkyMapLite::IsSlewing() );
updateDeepSkyNode(m_other, drawFlag, "NGCColor", &region );
+
+ /*n = m_other->m_trixels->firstChild();
+ while(n != 0) {
+ count += n->childCount();
+ n = n->nextSibling();
+ }
+
+ qDebug() << count << "DSO";*/
}
void DeepSkyItem::updateDeepSkyNode(DSOIndexNode *indexNode, bool drawObject, const QString& colorString,
@@ -156,7 +179,7 @@ void DeepSkyItem::updateDeepSkyNode(DSOIndexNode *indexNode, bool drawObject, co
indexNode->show();
SkyMapLite *map = SkyMapLite::Instance();
- //const Projector *proj = map->projector();
+ const Projector *projector = map->projector();
KStarsData *data = KStarsData::Instance();
UpdateID updateID = data->updateID();
@@ -202,15 +225,31 @@ void DeepSkyItem::updateDeepSkyNode(DSOIndexNode *indexNode, bool drawObject, co
}*/
DSOTrixelNode *trixel = static_cast<DSOTrixelNode *>(indexNode->m_trixels->firstChild());
+ double delLim = SkyMapLite::deleteLimit();
+
while( trixel != 0 ) {
if(trixel->trixel < regionID) {
trixel->hide();
trixel->m_labels->hide();
- //label->hide();
+
+ if(trixel->hideCount() > delLim) {
+ QLinkedList<QPair<SkyObject *, SkyNode *>>::iterator i = trixel->m_nodes.begin();
+
+ while(i != trixel->m_nodes.end()) {
+ DeepSkyNode *node = static_cast<DeepSkyNode *>((*i).second);
+ if(node) {
+ node->parent()->removeChildNode(node);
+ node->destroy();
+
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, 0);
+ }
+ i++;
+ }
+ }
trixel = static_cast<DSOTrixelNode *>(trixel->nextSibling());
- //label = static_cast<TrixelNode *>(label->nextSibling());
continue;
+
} else if(trixel->trixel > regionID) {
if (region->hasNext()) {
regionID = region->next();
@@ -219,6 +258,21 @@ void DeepSkyItem::updateDeepSkyNode(DSOIndexNode *indexNode, bool drawObject, co
trixel->hide();
trixel->m_labels->hide();
+ if(trixel->hideCount() > delLim) {
+ QLinkedList<QPair<SkyObject *, SkyNode *>>::iterator i = trixel->m_nodes.begin();
+
+ while(i != trixel->m_nodes.end()) {
+ DeepSkyNode *node = static_cast<DeepSkyNode *>((*i).second);
+ if(node) {
+ node->parent()->removeChildNode(node);
+ node->destroy();
+
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, 0);
+ }
+ i++;
+ }
+ }
+
trixel = static_cast<DSOTrixelNode *>(trixel->nextSibling());
}
break;
@@ -231,50 +285,74 @@ void DeepSkyItem::updateDeepSkyNode(DSOIndexNode *indexNode, bool drawObject, co
if(region->hasNext()) {
regionID = region->next();
}
- }
- QSGNode *n = trixel->firstChild();
+ QLinkedList<QPair<SkyObject *, SkyNode *>> *nodes = &trixel->m_nodes;
- while(n != 0 && n != trixel->m_symbols) {
- DeepSkyNode *dsoNode = static_cast<DeepSkyNode *>(n);
- n = n->nextSibling();
+ QLinkedList<QPair<SkyObject *, SkyNode *>>::iterator i = nodes->begin();
- DeepSkyObject *obj = static_cast<DeepSkyObject *>(dsoNode->dsObject());
- //if ( obj->drawID == drawID ) continue; // only draw each line once
- //obj->drawID = drawID;
+ while(i != nodes->end()) {
+ DeepSkyObject *dsoObj = static_cast<DeepSkyObject *>((*i).first);
+ DeepSkyNode *dsoNode = static_cast<DeepSkyNode *>((*i).second);
- if ( obj->updateID != updateID ) {
- obj->updateID = updateID;
- if ( obj->updateNumID != updateNumID) {
- obj->updateCoords( data->updateNum() );
+ if ( dsoObj->updateID != updateID ) {
+ dsoObj->updateID = updateID;
+ if ( dsoObj->updateNumID != updateNumID) {
+ dsoObj->updateCoords( data->updateNum() );
+ }
+ dsoObj->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
}
- obj->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
- }
- float mag = obj->mag();
- float size = obj->a() * dms::PI * Options::zoomFactor() / 10800.0;
+ float mag = dsoObj->mag();
+ float size = dsoObj->a() * dms::PI * Options::zoomFactor() / 10800.0;
+
+ //only draw objects if flags set, it's bigger than 1 pixel (unless
+ //zoom > 2000.), and it's brighter than maglim (unless mag is
+ //undefined (=99.9)
+ bool sizeCriterion = (size > 1.0 || Options::zoomFactor() > 2000.);
+ bool magCriterion = ( mag < (float)maglim ) || ( showUnknownMagObjects && ( std::isnan( mag ) || mag > 36.0 ) );
- //only draw objects if flags set, it's bigger than 1 pixel (unless
- //zoom > 2000.), and it's brighter than maglim (unless mag is
- //undefined (=99.9)
- bool sizeCriterion = (size > 1.0 || Options::zoomFactor() > 2000.);
- bool magCriterion = ( mag < (float)maglim ) || ( showUnknownMagObjects && ( std::isnan( mag ) || mag > 36.0 ) );
- if ( sizeCriterion && magCriterion )
- {
bool drawLabel = false;
- if ( !( m_hideLabels || mag > labelMagLim ) ) drawLabel = true;
- dsoNode->update(drawImage, drawLabel);
- /*bool drawn = skyp->drawDeepSkyObject(obj, drawImage);
+ if ( !( m_hideLabels || mag > labelMagLim ) ) drawLabel = true;
- //FIXME: find a better way to do above*/
- } else {
- dsoNode->hide();
+ if( dsoNode ) {
+ if( dsoNode->hideCount() > delLim ) {
+ //qDebug() << dsoNode->hideCount() << "hideCount";
+ trixel->removeChildNode(dsoNode);
+ dsoNode->destroy();
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, 0);
+ } else {
+ if(sizeCriterion && magCriterion) {
+
+ dsoNode->update(drawImage, drawLabel);
+ } else {
+ dsoNode->hide();
+ }
+ }
+ } else {
+ if( sizeCriterion && magCriterion && projector->checkVisibility(dsoObj) ) {
+
+ QPointF pos;
+
+ bool visible = false;
+ pos = projector->toScreen(dsoObj,true,&visible);
+ if( visible && projector->onScreen(pos) ) {
+ DSOSymbolNode *dsoSymbol = new DSOSymbolNode(dsoObj, indexNode->m_color);
+ trixel->m_symbols->appendChildNode(dsoSymbol);
+
+ DeepSkyNode *dsoNode = new DeepSkyNode(dsoObj, dsoSymbol, trixel->trixel, indexNode->m_labelType);
+ trixel->appendChildNode(dsoNode);
+
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, static_cast<SkyNode *>(dsoNode));
+ dsoNode->update(drawImage, drawLabel, pos);
+ }
+ }
+ }
+ i++;
}
}
-
trixel = static_cast<DSOTrixelNode *>(trixel->nextSibling());
- //label = static_cast<TrixelNode *>(label->nextSibling());
}
+
region->reset();
}
diff --git a/kstars/kstarslite/skyitems/deepskyitem.h b/kstars/kstarslite/skyitems/deepskyitem.h
index 4f7be8d..02034ab 100644
--- a/kstars/kstarslite/skyitems/deepskyitem.h
+++ b/kstars/kstarslite/skyitems/deepskyitem.h
@@ -19,7 +19,7 @@
#include "skyitem.h"
#include "skyopacitynode.h"
#include "deepskycomponent.h"
-#include "typedeflite.h"
+#include "skynodes/trixelnode.h"
class DSOIndexNode : public SkyOpacityNode {
public:
diff --git a/kstars/kstarslite/skyitems/deepstaritem.cpp b/kstars/kstarslite/skyitems/deepstaritem.cpp
index 4f5fe51..c02e19b 100644
--- a/kstars/kstarslite/skyitems/deepstaritem.cpp
+++ b/kstars/kstarslite/skyitems/deepstaritem.cpp
@@ -28,6 +28,8 @@
#include "skymesh.h"
#include "rootnode.h"
+#include "skynodes/trixelnode.h"
+
DeepStarItem::DeepStarItem(DeepStarComponent *deepStarComp, RootNode *rootNode)
:SkyItem(LabelsItem::label_t::NO_LABEL, rootNode), m_deepStarComp(deepStarComp),
m_staticStars(deepStarComp->staticStars)
@@ -53,9 +55,7 @@ DeepStarItem::DeepStarItem(DeepStarComponent *deepStarComp, RootNode *rootNode)
StarObject *star = &(block->star( j )->star);
if(star) {
- PointSourceNode *point = new PointSourceNode(star, rootNode, LabelsItem::label_t::NO_LABEL, star->spchar(),
- star->mag(), i);
- trixel->appendChildNode(point);
+ trixel->m_nodes.append(QPair<SkyObject *, SkyNode *>(star, 0));
}
}
}
@@ -110,8 +110,8 @@ void DeepStarItem::update() {
MeshIterator region(m_skyMesh, DRAW_BUF);
// If we are to hide the fainter stars (eg: while slewing), we set the magnitude limit to hideStarsMag.
- if( hideFaintStars && maglim > hideStarsMag )
- maglim = hideStarsMag;
+ //if( hideFaintStars && maglim > hideStarsMag )
+ //maglim = hideStarsMag;
StarBlockFactory *m_StarBlockFactory = StarBlockFactory::Instance();
// m_StarBlockFactory->drawID = m_skyMesh->drawID();
@@ -157,30 +157,9 @@ void DeepStarItem::update() {
TrixelNode *trixel = static_cast<TrixelNode *>(firstTrixel);
while( trixel != 0 ) {
- if(trixelID != regionID) {
- trixel->hide();
-
- trixel = static_cast<TrixelNode *>(trixel->nextSibling());
-
- trixelID++;
-
- continue;
- } else {
- trixel->show();
-
- if(region.hasNext()) {
- regionID = region.next();
-
- }
- }
-
if(m_staticStars) {
- QSGNode *n = trixel->firstChild();
-
- bool hide = false;
-
- while(n != 0) {
+ /*while(n != 0) {
PointSourceNode *point = static_cast<PointSourceNode *>(n);
n = n->nextSibling();
@@ -200,6 +179,94 @@ void DeepStarItem::update() {
} else {
point->hide();
}
+ }*/
+
+ const Projector *projector = SkyMapLite::Instance()->projector();
+
+ double delLim = SkyMapLite::deleteLimit();
+
+ if(trixelID != regionID) {
+ trixel->hide();
+
+ if(trixel->hideCount() > delLim) {
+ QLinkedList<QPair<SkyObject *, SkyNode *>>::iterator i = trixel->m_nodes.begin();
+
+ while(i != trixel->m_nodes.end()) {
+ SkyNode *node = (*i).second;
+ if(node) {
+ trixel->removeChildNode(node);
+ delete node;
+
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, 0);
+ }
+ i++;
+ }
+ }
+
+ trixel = static_cast<TrixelNode *>(trixel->nextSibling());
+
+ trixelID++;
+
+ continue;
+
+ } else {
+ trixel->show();
+
+ if(region.hasNext()) {
+ regionID = region.next();
+ }
+
+ QLinkedList<QPair<SkyObject *, SkyNode *>> *nodes = &trixel->m_nodes;
+
+ QLinkedList<QPair<SkyObject *, SkyNode *>>::iterator i = nodes->begin();
+
+ while(i != nodes->end()) {
+ bool hide = false;
+ bool hideSlew = false;
+
+ bool drawLabel = false;
+
+ StarObject *starObj = static_cast<StarObject *>((*i).first);
+ SkyNode *node = (*i).second;
+
+ int mag = starObj->mag();
+
+ // break loop if maglim is reached
+ if ( mag > maglim ) hide = true;
+ if ( hideFaintStars && hideStarsMag) hideSlew = true;
+ if ( starObj->updateID != KStarsData::Instance()->updateID() )
+ starObj->JITupdate();
+
+ if( node ) {
+ if( node->hideCount() > delLim || hide) {
+ trixel->removeChildNode(node);
+ delete node;
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, 0);
+ } else {
+ if(!hideSlew) {
+ node->update(drawLabel);
+ } else {
+ node->hide();
+ }
+ }
+ } else {
+ if( !hide && !hideSlew && projector->checkVisibility(starObj) ) {
+
+ QPointF pos;
+
+ bool visible = false;
+ pos = projector->toScreen(starObj,true,&visible);
+ if( visible && projector->onScreen(pos) ) {
+ PointSourceNode *point = new PointSourceNode(starObj, rootNode(), LabelsItem::label_t::STAR_LABEL, starObj->spchar(), starObj->mag(), trixelID);
+ trixel->appendChildNode(point);
+
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, static_cast<SkyNode *>(point));
+ point->updatePos(pos, drawLabel);
+ }
+ }
+ }
+ i++;
+ }
}
} else if(false) {
if( !m_staticStars && !m_starBlockList->at( regionID )->fillToMag( maglim ) && maglim <= m_deepStarComp->m_FaintMagnitude * ( 1 - 1.5/16 ) ) {
@@ -249,5 +316,16 @@ void DeepStarItem::update() {
}
m_skyMesh->inDraw( false );
}
+
+ /*int count = 0;
+
+ QSGNode *n = firstChild();
+ while(n != 0) {
+ count += n->childCount();
+ n = n->nextSibling();
+ }
+
+ qDebug() << count << "Nodes - DeepStars";*/
}
+
diff --git a/kstars/kstarslite/skyitems/deepstaritem.h b/kstars/kstarslite/skyitems/deepstaritem.h
index 625e690..653d14d 100644
--- a/kstars/kstarslite/skyitems/deepstaritem.h
+++ b/kstars/kstarslite/skyitems/deepstaritem.h
@@ -18,7 +18,6 @@
#include "skyitem.h"
#include "skyopacitynode.h"
-#include "typedeflite.h"
/** @class DeepStarItem
*
diff --git a/kstars/kstarslite/skyitems/labelsitem.cpp b/kstars/kstarslite/skyitems/labelsitem.cpp
index a16f7db..e54b65b 100644
--- a/kstars/kstarslite/skyitems/labelsitem.cpp
+++ b/kstars/kstarslite/skyitems/labelsitem.cpp
@@ -25,6 +25,7 @@
#include "staritem.h"
#include "rootnode.h"
#include "skymesh.h"
+#include "skynodes/trixelnode.h"
LabelsItem::LabelsItem()
:m_rootNode(0)
@@ -224,7 +225,8 @@ void LabelsItem::deleteLabel(LabelNode *label) {
label_t type = label->labelType();
LabelTypeNode *node = m_labelsLists[type];
- if(type == STAR_LABEL) {
+ if(type == STAR_LABEL || type == DSO_IC_LABEL || type == DSO_NGC_LABEL || type == DSO_MESSIER_LABEL ||
+ type == DSO_OTHER_LABEL) {
QSGNode *trixel = node->firstChild();
bool found = false;
@@ -243,8 +245,15 @@ void LabelsItem::deleteLabel(LabelNode *label) {
trixel = trixel->nextSibling();
}
} else {
- node->removeChildNode(label);
- delete label;
+ QSGNode *n = node->firstChild();
+ while(n != 0) {
+ if(n == label) {
+ node->removeChildNode(label);
+ delete label;
+ break;
+ }
+ n = n->nextSibling();
+ }
}
}
}
diff --git a/kstars/kstarslite/skyitems/labelsitem.h b/kstars/kstarslite/skyitems/labelsitem.h
index f72462f..718e9a8 100644
--- a/kstars/kstarslite/skyitems/labelsitem.h
+++ b/kstars/kstarslite/skyitems/labelsitem.h
@@ -26,6 +26,7 @@ class StarItem;
class LabelNode;
class GuideLabelNode;
class RootNode;
+class TrixelNode;
class SkyObject;
diff --git a/kstars/kstarslite/skyitems/lines/eclipticitem.cpp b/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
index c93bab9..112ea4f 100644
--- a/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
@@ -21,6 +21,7 @@
#include "ecliptic.h"
#include "../skynodes/labelnode.h"
#include "../skynodes/nodes/linenode.h"
+#include "../skynodes/trixelnode.h"
EclipticItem::EclipticItem(Ecliptic *eclipticComp, RootNode *rootNode)
:SkyItem(LabelsItem::label_t::ECLIPTIC_LABEL, rootNode), m_eclipticComp(eclipticComp)
diff --git a/kstars/kstarslite/skyitems/lines/equatoritem.cpp b/kstars/kstarslite/skyitems/lines/equatoritem.cpp
index 52faef1..5ad1d0b 100644
--- a/kstars/kstarslite/skyitems/lines/equatoritem.cpp
+++ b/kstars/kstarslite/skyitems/lines/equatoritem.cpp
@@ -25,6 +25,7 @@
#include "../skynodes/nodes/linenode.h"
#include "../skynodes/labelnode.h"
+#include "../skynodes/trixelnode.h"
EquatorItem::EquatorItem(Equator *equatorComp, RootNode *rootNode)
:SkyItem(LabelsItem::label_t::EQUATOR_LABEL, rootNode), m_equatorComp(equatorComp)
diff --git a/kstars/kstarslite/skyitems/lines/linesitem.cpp b/kstars/kstarslite/skyitems/lines/linesitem.cpp
index cbfccbb..28252a5 100644
--- a/kstars/kstarslite/skyitems/lines/linesitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/linesitem.cpp
@@ -22,6 +22,7 @@
#include "linelist.h"
#include "linelistindex.h"
#include "../skynodes/nodes/linenode.h"
+#include "../skynodes/trixelnode.h"
LinesItem::LinesItem(RootNode *rootNode)
:SkyItem(LabelsItem::label_t::NO_LABEL, rootNode)
diff --git a/kstars/kstarslite/skyitems/lines/linesitem.h b/kstars/kstarslite/skyitems/lines/linesitem.h
index 8972a30..3632f1a 100644
--- a/kstars/kstarslite/skyitems/lines/linesitem.h
+++ b/kstars/kstarslite/skyitems/lines/linesitem.h
@@ -18,7 +18,6 @@
#include "../skyitem.h"
#include "../skyopacitynode.h"
-#include "../typedeflite.h"
class LineListIndex;
diff --git a/kstars/kstarslite/skyitems/lines/milkywayitem.cpp b/kstars/kstarslite/skyitems/lines/milkywayitem.cpp
index fa9c316..0592228 100644
--- a/kstars/kstarslite/skyitems/lines/milkywayitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/milkywayitem.cpp
@@ -24,6 +24,7 @@
#include "linelistindex.h"
#include "../skynodes/nodes/linenode.h"
#include "../skynodes/skypolygonnode.h"
+#include "../skynodes/trixelnode.h"
MilkyWayItem::MilkyWayItem(MilkyWay *mwComp, RootNode *rootNode)
:SkyItem(LabelsItem::label_t::NO_LABEL, rootNode), m_MWComp(mwComp), m_filled(Options::fillMilkyWay())
diff --git a/kstars/kstarslite/skyitems/lines/milkywayitem.h b/kstars/kstarslite/skyitems/lines/milkywayitem.h
index e3066f2..71a4732 100644
--- a/kstars/kstarslite/skyitems/lines/milkywayitem.h
+++ b/kstars/kstarslite/skyitems/lines/milkywayitem.h
@@ -18,7 +18,6 @@
#include "../skyitem.h"
#include "../skyopacitynode.h"
-#include "../typedeflite.h"
class LineListIndex;
class MilkyWay;
diff --git a/kstars/kstarslite/skyitems/rootnode.cpp b/kstars/kstarslite/skyitems/rootnode.cpp
index e90259a..3fa2c04 100644
--- a/kstars/kstarslite/skyitems/rootnode.cpp
+++ b/kstars/kstarslite/skyitems/rootnode.cpp
@@ -41,6 +41,7 @@ RootNode::RootNode()
:m_skyMapLite(SkyMapLite::Instance()),
m_clipGeometry(0)
{
+ SkyMapLite::setRootNode(this);
genCachedTextures();
Options::setProjection(Projector::Lambert);
@@ -61,7 +62,7 @@ RootNode::RootNode()
m_linesItem->addLinesComponent( m_skyComposite->constellationBoundary(), "CBoundColor", 1, Qt::SolidLine );
}
- m_artItem = new ConstellationArtItem(m_skyComposite->constellationArt(), this);
+ //m_artItem = new ConstellationArtItem(m_skyComposite->constellationArt(), this);
m_linesItem->addLinesComponent( m_skyComposite->constellationLines(), "CLineColor", 1, Qt::SolidLine );
@@ -84,15 +85,10 @@ RootNode::RootNode()
m_horizonItem = new HorizonItem(m_skyComposite->horizon(), this);
-
setIsRectangular(false);
updateClipPoly();
m_labelsItem->setRootNode(this);
-
- /*
- m_linesItem(new LinesItem(this)), m_horizonItem(new HorizonItem(this))
- */
}
void RootNode::testLeakAdd() {
@@ -204,7 +200,7 @@ void RootNode::update() {
m_MWItem->update();
- m_artItem->update();
+ // m_artItem->update();
m_linesItem->update();
diff --git a/kstars/kstarslite/skyitems/skynodes/deepskynode.cpp b/kstars/kstarslite/skyitems/skynodes/deepskynode.cpp
index 3d19f6a..03743a0 100644
--- a/kstars/kstarslite/skyitems/skynodes/deepskynode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/deepskynode.cpp
@@ -35,6 +35,16 @@ DeepSkyNode::DeepSkyNode(DeepSkyObject * skyObject, DSOSymbolNode *symbol, Trixe
}
+void DeepSkyNode::destroy() {
+ QSGNode *parent = m_symbol->parent();
+ parent->removeChildNode(m_symbol);
+
+ if(m_label) SkyMapLite::rootNode()->labelsItem()->deleteLabel(m_label);
+
+ delete m_symbol;
+ delete this;
+}
+
void DeepSkyNode::changePos(QPointF pos) {
QSizeF size = m_objImg->rect().size();
QMatrix4x4 m (1,0,0,pos.x(),
@@ -49,18 +59,20 @@ void DeepSkyNode::changePos(QPointF pos) {
markDirty(QSGNode::DirtyMatrix);
}
-void DeepSkyNode::update(bool drawImage, bool drawLabel) {
- const Projector *proj = projector();
- if( !proj->checkVisibility(m_dso) ) {
- hide();
- return;
- }
+void DeepSkyNode::update(bool drawImage, bool drawLabel, QPointF pos) {
+ if(pos.x() == -1 && pos.y() == -1) {
+ const Projector *proj = projector();
+ if( !proj->checkVisibility(m_dso) ) {
+ hide();
+ return;
+ }
- bool visible = false;
- QPointF pos = proj->toScreen(m_dso, true, &visible);
- if( !visible || !proj->onScreen(pos) ) {
- hide();
- return;
+ bool visible = false;
+ pos = proj->toScreen(m_dso, true, &visible);
+ if( !visible || !proj->onScreen(pos) ) {
+ hide();
+ return;
+ }
}
show();
@@ -71,10 +83,6 @@ void DeepSkyNode::update(bool drawImage, bool drawLabel) {
float size = majorAxis * dms::PI * Options::zoomFactor() / 10800.0;
- //Draw Image
- /*if ( drawImage && Options::zoomFactor() > 5.*MINZOOM )
- drawDeepSkyImage(pos, obj, positionAngle);*/
-
double zoom = Options::zoomFactor();
double w = m_dso->a() * dms::PI * zoom/10800.0;
double h = m_dso->e() * w;
@@ -97,13 +105,15 @@ void DeepSkyNode::update(bool drawImage, bool drawLabel) {
} else {
hide();
}
+
//Draw symbol
m_symbol->update(size, pos, m_angle);
+ m_symbol->show();
// Draw label
if(drawLabel) {
if(!m_label) {
- m_label = SkyMapLite::Instance()->rootNode()->labelsItem()->addLabel(m_dso, m_labelType, m_trixel);
+ m_label = SkyMapLite::rootNode()->labelsItem()->addLabel(m_dso, m_labelType, m_trixel);
}
m_label->setLabelPos(pos);
} else if(m_label) {
diff --git a/kstars/kstarslite/skyitems/skynodes/deepskynode.h b/kstars/kstarslite/skyitems/skynodes/deepskynode.h
index d897a38..94c0ae6 100644
--- a/kstars/kstarslite/skyitems/skynodes/deepskynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/deepskynode.h
@@ -53,7 +53,9 @@ public:
*/
void changePos(QPointF pos);
- void update(bool drawImage, bool drawLabel);
+ void destroy();
+
+ void update(bool drawImage, bool drawLabel, QPointF pos = QPointF(-1,-1));
virtual void hide() override;
DeepSkyObject *dsObject() { return m_dso; }
diff --git a/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp b/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp
index 15aa86e..c8fb429 100644
--- a/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp
@@ -208,10 +208,7 @@ void PlanetaryNebulaSymbol::updateSymbol(float x, float y, float e, float size)
e1->updateGeometry(0, 0, size, e*size, false);
- /*drawLine( QPointF(0., dy1), QPointF(0., dy1 - e*size/2. ) );
- drawLine( QPointF(0., dy2), QPointF(0., dy2 + e*size/2. ) );
- drawLine( QPointF(dx1, 0.), QPointF(dx1 - size/2., 0.) );
- drawLine( QPointF(dx2, 0.), QPointF(dx2 + size/2., 0.) );*/
+
QSGGeometry::Point2D * vertex = lines->geometry()->vertexDataAsPoint2D();
//First line
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
index 7ca0c06..c0bab07 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
@@ -23,7 +23,8 @@
EllipseNode::EllipseNode(QColor color, int width)
:m_geometryNode(new QSGGeometryNode), m_geometry(0),
- m_material(new QSGFlatColorMaterial), m_fillMode(false), m_width(0), m_height(0)
+ m_material(new QSGFlatColorMaterial), m_fillMode(false), m_width(0), m_height(0), m_x(-1),
+ m_y(-1)
{
m_geometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0);
m_geometry->allocate(60);
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
index 7fa281b..e2c502d 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
@@ -30,7 +30,13 @@ PointSourceNode::PointSourceNode(SkyObject * skyObject, RootNode * parentNode,
:SkyNode(skyObject), m_label(0), m_labelType(labelType), m_rootNode(parentNode),
m_trixel(trixel), m_point(0), m_size(size), m_spType(spType)
{
-
+ if(labelType == LabelsItem::label_t::STAR_LABEL) {
+ /*int i = 0;
+ while(i != 100000) {
+ i++;
+ m_int.append(i);
+ }*/
+ }
}
float PointSourceNode::starWidth(float mag) const
@@ -53,11 +59,14 @@ float PointSourceNode::starWidth(float mag) const
return size;
}
+PointSourceNode::~PointSourceNode() {
+ if(m_label) m_rootNode->labelsItem()->deleteLabel(m_label);
+}
+
void PointSourceNode::initPoint() {
if(!m_point) {
m_point = new PointNode(m_rootNode,m_spType,starWidth(m_size));
- //appendChildNode(m_opacity);
- m_opacity->appendChildNode(m_point);
+ addChildNode(m_point);
}
show();
m_point->setSize(starWidth(m_skyObject->mag()));
@@ -84,23 +93,29 @@ void PointSourceNode::update() {
bool visible = false;
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!
- initPoint();
- changePos(pos);
-
- if(m_drawLabel && m_labelType != LabelsItem::label_t::NO_LABEL) {
- if(!m_label) { //This way labels will be created only when they are needed
- if(m_trixel != -1) {
- m_label = m_rootNode->labelsItem()->addLabel(m_skyObject, m_labelType, m_trixel);
- } else {
- m_label = m_rootNode->labelsItem()->addLabel(m_skyObject, m_labelType);
- }
+ updatePos(pos, m_drawLabel);
+ } else {
+ hide();
+ }
+}
+
+void PointSourceNode::updatePos(QPointF pos, bool drawLabel) {
+ initPoint();
+ changePos(pos);
+ //Do something with this!
+ m_drawLabel = drawLabel;
+
+ if(m_drawLabel && m_labelType != LabelsItem::label_t::NO_LABEL) {
+ if(!m_label) { //This way labels will be created only when they are needed
+ if(m_trixel != -1) {
+ m_label = m_rootNode->labelsItem()->addLabel(m_skyObject, m_labelType, m_trixel);
+ } else {
+ m_label = m_rootNode->labelsItem()->addLabel(m_skyObject, m_labelType);
}
- m_label->setLabelPos(pos);
- } else {
- if(m_label) m_label->hide();
}
+ m_label->setLabelPos(pos);
} else {
- hide();
+ if(m_label) m_label->hide();
}
}
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
index 90ecc62..68a0757 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
@@ -46,7 +46,7 @@ public:
PointSourceNode(SkyObject * skyObject, RootNode * parentNode,
LabelsItem::label_t labelType = LabelsItem::label_t::STAR_LABEL, char spType = 'A', float size = 1, short trixel = -1);
- //virtual ~PointSourceNode();
+ virtual ~PointSourceNode();
/** @short Get the width of a star of magnitude mag */
float starWidth(float mag) const;
@@ -58,6 +58,8 @@ public:
*/
virtual void changePos(QPointF pos) override;
+ void updatePos(QPointF pos, bool drawLabel);
+
virtual void update() override;
virtual void hide() override;
private:
@@ -66,6 +68,7 @@ private:
RootNode *m_rootNode;
char m_spType;
float m_size;
+ QVector<int> m_int;
LabelNode *m_label;
LabelsItem::label_t m_labelType;
diff --git a/kstars/kstarslite/skyitems/skynodes/satellitenode.cpp b/kstars/kstarslite/skyitems/skynodes/satellitenode.cpp
index fa658e9..dd67d31 100644
--- a/kstars/kstarslite/skyitems/skynodes/satellitenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/satellitenode.cpp
@@ -22,11 +22,14 @@
#include "linelist.h"
#include "nodes/pointnode.h"
#include <QSGFlatColorMaterial>
-
+#include "../rootnode.h"
+#include "../labelsitem.h"
+#include "labelnode.h"
SatelliteNode::SatelliteNode(Satellite* sat, RootNode *rootNode)
- :m_sat(sat), m_lines(0), m_point(0), m_rootNode(rootNode)
+ :m_sat(sat), m_lines(0), m_point(0), m_rootNode(rootNode), m_label(0)
{
+
}
void SatelliteNode::initLines() {
@@ -99,12 +102,23 @@ void SatelliteNode::update() {
}
changePos(pos);
+
+ if ( Options::showSatellitesLabels() ) {
+ if(!m_label) {
+ m_label = SkyMapLite::rootNode()->labelsItem()->addLabel(m_sat,
+ LabelsItem::label_t::SATELLITE_LABEL);
+ }
+ m_label->setLabelPos(pos);
+ }
+
} else {
hide();
}
+}
- /*if ( Options::showSatellitesLabels() )
- data->skyComposite()->satellites()->drawLabel( sat, pos );*/
+void SatelliteNode::hide() {
+ SkyNode::hide();
+ if(m_label) m_label->hide();
}
void SatelliteNode::changePos(QPointF pos) {
diff --git a/kstars/kstarslite/skyitems/skynodes/satellitenode.h b/kstars/kstarslite/skyitems/skynodes/satellitenode.h
index 5c77e6a..6d63c88 100644
--- a/kstars/kstarslite/skyitems/skynodes/satellitenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/satellitenode.h
@@ -21,6 +21,7 @@ class PolyNode;
class Satellite;
class PointNode;
class QSGFlatColorMaterial;
+class LabelNode;
/** @class SatelliteNode
*
@@ -36,6 +37,8 @@ public:
void initLines();
void initPoint();
+ void hide();
+
void changePos(QPointF pos);
inline Satellite *sat() { return m_sat; }
@@ -47,6 +50,8 @@ private:
SkyOpacityNode *m_linesOpacity;
QSGGeometryNode *m_lines;
+ LabelNode *m_label;
+
QSGFlatColorMaterial *m_material;
QSGGeometry *m_geometry;
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.cpp b/kstars/kstarslite/skyitems/skynodes/skynode.cpp
index 8ee1ccc..c61a9e5 100644
--- a/kstars/kstarslite/skyitems/skynodes/skynode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/skynode.cpp
@@ -18,7 +18,7 @@
#include "skynode.h"
SkyNode::SkyNode(SkyObject * skyObject)
- :m_skyObject(skyObject), m_opacity(new SkyOpacityNode), m_drawLabel(false)
+ :m_skyObject(skyObject), m_opacity(new SkyOpacityNode), m_drawLabel(false), m_hideCount(0)
{
appendChildNode(m_opacity);
}
@@ -29,6 +29,16 @@ SkyNode::SkyNode()
appendChildNode(m_opacity);
}
+void SkyNode::hide() {
+ m_opacity->hide();
+ m_hideCount++;
+}
+
+void SkyNode::show() {
+ m_opacity->show();
+ m_hideCount = 0;
+}
+
void SkyNode::update(bool drawLabel) {
m_drawLabel = drawLabel;
update();
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.h b/kstars/kstarslite/skyitems/skynodes/skynode.h
index dcc9b2d..1918d65 100644
--- a/kstars/kstarslite/skyitems/skynodes/skynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/skynode.h
@@ -50,7 +50,7 @@ public:
*/
// All children nodes allocated on heap are deleted automatically
- //virtual ~SkyNode() { }
+ virtual ~SkyNode() { }
inline const Projector* projector() { return SkyMapLite::Instance()->projector(); }
@@ -75,12 +75,14 @@ public:
/**
* @short hides all child nodes (sets opacity of m_opacity to 0)
*/
- inline virtual void hide() { m_opacity->hide(); }
+ virtual void hide();
/**
* @short shows all child nodes (sets opacity of m_opacity to 1)
*/
- inline virtual void show() { m_opacity->show(); }
+ virtual void show();
+
+ inline int hideCount() { return m_hideCount; }
/**
* @short changes the position of SkyNode on SkyMapLite. Has to be overriden by the classes
@@ -103,6 +105,7 @@ public:
protected:
SkyObject * m_skyObject;
+ int m_hideCount;
bool m_drawLabel;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/supernovanode.cpp b/kstars/kstarslite/skyitems/skynodes/supernovanode.cpp
index fe21da9..4ea56c5 100644
--- a/kstars/kstarslite/skyitems/skynodes/supernovanode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/supernovanode.cpp
@@ -24,7 +24,7 @@
#include <QSGFlatColorMaterial>
SupernovaNode::SupernovaNode(Supernova *snova)
- :m_snova(snova)
+ :m_snova(snova), m_lines(0)
{
}
diff --git a/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp b/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp
new file mode 100644
index 0000000..98ead52
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp
@@ -0,0 +1,28 @@
+/** *************************************************************************
+ trixelnode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 01/07/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 "trixelnode.h"
+
+void TrixelNode::hide() {
+ m_hideCount++;
+ SkyOpacityNode::hide();
+}
+
+void TrixelNode::show() {
+ SkyOpacityNode::show();
+ m_hideCount = 0;
+}
diff --git a/kstars/kstarslite/skyitems/skynodes/trixelnode.h b/kstars/kstarslite/skyitems/skynodes/trixelnode.h
new file mode 100644
index 0000000..21a684e
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/trixelnode.h
@@ -0,0 +1,41 @@
+/** *************************************************************************
+ trixelnode.h - K Desktop Planetarium
+ -------------------
+ begin : 01/07/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 TRIXELNODE_H_
+#define TRIXELNODE_H_
+
+#include "../skyopacitynode.h"
+#include "typedef.h"
+
+class SkyObject;
+class SkyNode;
+
+class TrixelNode : public SkyOpacityNode {
+public:
+ Trixel m_trixel;
+
+ QLinkedList<QPair<SkyObject *, SkyNode *>> m_nodes;
+
+ inline int hideCount() { return m_hideCount; }
+ inline void resetHideCount() { m_hideCount = 0; }
+
+ void virtual hide() override;
+ void virtual show() override;
+private:
+ int m_hideCount;
+};
+
+
+#endif
diff --git a/kstars/kstarslite/skyitems/staritem.cpp b/kstars/kstarslite/skyitems/staritem.cpp
index cb917a4..3be7de6 100644
--- a/kstars/kstarslite/skyitems/staritem.cpp
+++ b/kstars/kstarslite/skyitems/staritem.cpp
@@ -26,6 +26,8 @@
#include "starblockfactory.h"
#include "skymesh.h"
#include "rootnode.h"
+#include <QLinkedList>
+#include "skynodes/trixelnode.h"
StarItem::StarItem(StarComponent *starComp, RootNode *rootNode)
:SkyItem(LabelsItem::label_t::STAR_LABEL, rootNode), m_starComp(starComp)
@@ -47,9 +49,7 @@ StarItem::StarItem(StarComponent *starComp, RootNode *rootNode)
for(int c = 0; c < skyList->size(); ++c) {
StarObject *star = skyList->at(c);
if(star) {
- PointSourceNode *point = new PointSourceNode(star, rootNode, LabelsItem::label_t::STAR_LABEL, star->spchar(),
- star->mag(), i);
- trixel->appendChildNode(point);
+ trixel->m_nodes.append(QPair<SkyObject *, SkyNode *>(star, 0));
}
}
}
@@ -152,35 +152,57 @@ void StarItem::update() {
if(reIndex) rootNode()->labelsItem()->deleteLabels(labelType());
+ const Projector *projector = SkyMapLite::Instance()->projector();
+
+ double delLim = SkyMapLite::deleteLimit();
+
while( trixel != 0 ) {
- //All stars were reindexed so recreate the trixel nodes again
if(reIndex) {
StarList *skyList = index->at(trixelID);
QSGNode *n = trixel->firstChild();
+
+ //Delete nodes
while( n != 0 ) {
QSGNode *c = n;
n = n->nextSibling();
- //Delete node
trixel->removeChildNode(c);
delete c;
}
+ //Delete all pairs that represent stars
+ trixel->m_nodes.clear();
+
for(int c = 0; c < skyList->size(); ++c) {
StarObject *star = skyList->at(c);
if(star) {
- PointSourceNode *point = new PointSourceNode(star, rootNode(), LabelsItem::label_t::STAR_LABEL, star->spchar(),
- star->mag(), c);
- trixel->appendChildNode(point);
+ //Add new pair with reindexed star
+ trixel->m_nodes.append(QPair<SkyObject *, SkyNode *>(star, 0));
}
}
}
+ bool hide = false;
+
if(trixelID != regionID) {
trixel->hide();
label->hide();
+ if(trixel->hideCount() > delLim) {
+ QLinkedList<QPair<SkyObject *, SkyNode *>>::iterator i = trixel->m_nodes.begin();
+
+ while(i != trixel->m_nodes.end()) {
+ SkyNode *node = (*i).second;
+ if(node) {
+ trixel->removeChildNode(node);
+ delete node;
+
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, 0);
+ }
+ i++;
+ }
+ }
} else {
trixel->show();
label->show();
@@ -189,31 +211,54 @@ void StarItem::update() {
regionID = region.next();
}
- QSGNode *n = trixel->firstChild();
-
- bool hide = false;
+ QLinkedList<QPair<SkyObject *, SkyNode *>> *nodes = &trixel->m_nodes;
- while(n != 0) {
- PointSourceNode *point = static_cast<PointSourceNode *>(n);
- n = n->nextSibling();
+ QLinkedList<QPair<SkyObject *, SkyNode *>>::iterator i = nodes->begin();
- StarObject *curStar = static_cast<StarObject *>(point->skyObject());
- float mag = curStar->mag();
+ while(i != nodes->end()) {
bool drawLabel = false;
- // break loop if maglim is reached
- if(!hide) {
- if ( mag > maglim ) hide = true;
- if(!(hideLabel || mag > labelMagLim)) drawLabel = true;
- }
- if(!hide) {
- if ( curStar->updateID != KStarsData::Instance()->updateID() )
- curStar->JITupdate();
- point->SkyNode::update(drawLabel);
+ StarObject *starObj = static_cast<StarObject *>((*i).first);
+ SkyNode *node = (*i).second;
+
+ int mag = starObj->mag();
+
+ // break loop if maglim is reached
+ if ( mag > maglim ) hide = true;
+ if (!(hideLabel || mag > labelMagLim)) drawLabel = true;
+ if ( starObj->updateID != KStarsData::Instance()->updateID() )
+ starObj->JITupdate();
+
+ if( node ) {
+ if( node->hideCount() > delLim || hide) {
+ trixel->removeChildNode(node);
+ delete node;
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, 0);
+ } else {
+ if(!hide) {
+ node->update(drawLabel);
+ } else {
+ node->hide();
+ }
+ }
} else {
- point->hide();
+ if( !hide && projector->checkVisibility(starObj) ) {
+
+ QPointF pos;
+
+ bool visible = false;
+ pos = projector->toScreen(starObj,true,&visible);
+ if( visible && projector->onScreen(pos) ) {
+ PointSourceNode *point = new PointSourceNode(starObj, rootNode(), LabelsItem::label_t::STAR_LABEL, starObj->spchar(), starObj->mag(), trixelID);
+ trixel->appendChildNode(point);
+
+ *i = QPair<SkyObject *, SkyNode *>((*i).first, static_cast<SkyNode *>(point));
+ point->updatePos(pos, drawLabel);
+ }
+ }
}
+ i++;
}
}
trixel = static_cast<TrixelNode *>(trixel->nextSibling());
@@ -238,6 +283,17 @@ void StarItem::update() {
deepStars->update();
}
+ /*int count = 0;
+
+ QSGNode *n = m_stars->firstChild();
+ while(n != 0) {
+ count += n->childCount();
+ n = n->nextSibling();
+ }
+
+ qDebug() << delLim << "delLim";
+ qDebug() << count << "Nodes";*/
+
m_skyMesh->inDraw( false );
}
diff --git a/kstars/kstarslite/skyitems/staritem.h b/kstars/kstarslite/skyitems/staritem.h
index f30e7c2..a32383e 100644
--- a/kstars/kstarslite/skyitems/staritem.h
+++ b/kstars/kstarslite/skyitems/staritem.h
@@ -18,7 +18,6 @@
#include "skyitem.h"
#include "skyopacitynode.h"
-#include "typedeflite.h"
/** @class StarItem
*
diff --git a/kstars/kstarslite/skyitems/typedeflite.h b/kstars/kstarslite/skyitems/typedeflite.h
index 2cb0e9c..ba49d49 100644
--- a/kstars/kstarslite/skyitems/typedeflite.h
+++ b/kstars/kstarslite/skyitems/typedeflite.h
@@ -2,15 +2,12 @@
#define TYPEDEFLITE_H_
#include "typedef.h"
#include "skyopacitynode.h"
+#include "skyobject.h"
+#include "skynodes/skynode.h"
class SkyOpacityNode;
typedef SkyOpacityNode LabelTypeNode;
typedef SkyOpacityNode LineIndexNode;
-class TrixelNode : public SkyOpacityNode {
-public:
- Trixel m_trixel;
-};
-
#endif
diff --git a/kstars/projections/projector.cpp b/kstars/projections/projector.cpp
index d76dc47..2d45b7a 100644
--- a/kstars/projections/projector.cpp
+++ b/kstars/projections/projector.cpp
@@ -485,7 +485,7 @@ Vector2f Projector::toScreenVec(const SkyPoint* o, bool oRefract, bool* onVisibl
qDebug() << "Y = " << Y << " and isfinite(Y) is" << std::isfinite(Y);
}
- //Q_ASSERT( std::isfinite( Y ) && std::isfinite( dX ) );
+ Q_ASSERT( std::isfinite( Y ) && std::isfinite( dX ) );
if(!std::isfinite( Y ) && !std::isfinite( dX )) {
return Vector2f(0,0);
}
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index bd606e0..2d52f34 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -82,17 +82,23 @@ QBitmap defaultCursorBitmap(int width) {
SkyMapLite *SkyMapLite::pinstance = 0;
+RootNode *SkyMapLite::m_rootNode = nullptr;
+
+int SkyMapLite::m_updatesCount = 0;
+int SkyMapLite::m_updatesCountTemp = 0;
+
int SkyMapLite::starColorMode = 0;
SkyMapLite::SkyMapLite(QQuickItem* parent)
:QQuickItem(parent), m_proj(0), count(0), data(KStarsData::Instance()),
- nStarSizes(15), nSPclasses(7), pinch(false), m_loadingFinished(false), m_sizeMagLim(10.0),
- m_rootNode(0)
+ nStarSizes(15), nSPclasses(7), pinch(false), m_loadingFinished(false), m_sizeMagLim(10.0)
{
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::AllButtons);
setFlag(ItemHasContents, true);
+ m_rootNode = 0;
+
midMouseButtonDown = false;
mouseButtonDown = false;
slewing = false;
@@ -101,6 +107,11 @@ SkyMapLite::SkyMapLite(QQuickItem* parent)
ClickedObject = NULL;
FocusObject = NULL;
+ m_timer.setInterval(1000);
+ m_timer.start();
+
+ connect(&m_timer, SIGNAL(timeout()), this, SLOT(setUpdateCounter()));
+
setupProjector();
// Whenever the wrapper's(parent) dimensions changed, change SkyMapLite too
@@ -117,6 +128,10 @@ SkyMapLite::SkyMapLite(QQuickItem* parent)
}
+void SkyMapLite::setUpdateCounter() {
+ m_updatesCount = m_updatesCountTemp; m_updatesCountTemp = 0;
+}
+
QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) {
Q_UNUSED(updatePaintNodeData);
RootNode *n = static_cast<RootNode*>(oldNode);
@@ -124,12 +139,12 @@ QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
qDeleteAll(m_deleteNodes);
m_deleteNodes.clear();
-
if(m_loadingFinished) {
if(!n) {
n = new RootNode();
m_rootNode = n;
}
+ m_updatesCountTemp++;
n->update();
}
@@ -151,6 +166,11 @@ QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
return n;
}
+double SkyMapLite::deleteLimit() {
+ double lim = (MAXZOOM/MINZOOM)/sqrt(Options::zoomFactor())/3;//(MAXZOOM/MINZOOM - Options::zoomFactor())/130;
+ return lim;
+}
+
void SkyMapLite::deleteSkyNode(SkyNode *skyNode) {
m_deleteNodes.append(skyNode);
}
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 54d27dd..21c5ce8 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -28,6 +28,7 @@
#include <QPolygonF>
#include <QLinkedList>
#include "kstarsdata.h"
+#include "kstarslite/skyitems/rootnode.h"
class dms;
class KStarsData;
@@ -70,6 +71,8 @@ protected:
virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
+ static RootNode *m_rootNode;
+
public:
static SkyMapLite* createInstance(QQuickItem* parent = 0);
@@ -289,7 +292,14 @@ public:
/** Used in PointSourceNode **/
inline float sizeMagLim() const { return m_sizeMagLim; }
- inline RootNode *rootNode() { return m_rootNode; }
+ static inline RootNode *rootNode() { return m_rootNode; }
+
+ static inline void setRootNode(RootNode *root) { m_rootNode = root; }
+
+ static inline int updatesCount() { return m_updatesCount; }
+
+ /** return limit of hides for the node to delete it **/
+ static double deleteLimit();
/**
*@short Proxy method for SkyMapDrawAbstract::drawObjectLabels()
@@ -500,6 +510,9 @@ private slots:
/** Set the shape of mouse cursor to a cross with 4 arrows. */
void setMouseMoveCursor();
+ /** resets updates counter **/
+ void setUpdateCounter();
+
private:
/** @short Sets the shape of the default mouse cursor to a cross. */
@@ -590,13 +603,15 @@ private:
bool m_objPointingMode;
bool m_fovCaptureMode;
- RootNode *m_rootNode;
-
Projector* m_proj;
static SkyMapLite *pinstance;
QQuickItem *m_SkyMapLiteWrapper;
+ QTimer m_timer;
+ static int m_updatesCount; // To count the number of updates per second
+ static int m_updatesCountTemp;
+
//Holds SkyNodes that need to be deleted
QLinkedList<SkyNode *> m_deleteNodes;