summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-06-22 01:24:06 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-06-22 01:24:06 (GMT)
commit0f31a955d6d38ba5b6ff8bbe043049b898841ad3 (patch)
tree9b8d7ef41350b8767e35c657f08a706fa55446be
parentbeb4c4693cc91195f7279e9278ef5578968fa85d (diff)
Added support for DSOs (Images and symbols)
-rw-r--r--kstars/CMakeLists.txt11
-rw-r--r--kstars/kstars.kcfg18
-rw-r--r--kstars/kstarslite/qml/main.qml4
-rw-r--r--kstars/kstarslite/skyitems/cometsitem.cpp8
-rw-r--r--kstars/kstarslite/skyitems/deepskyitem.cpp322
-rw-r--r--kstars/kstarslite/skyitems/deepskyitem.h76
-rw-r--r--kstars/kstarslite/skyitems/deepstaritem.cpp262
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.cpp72
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.h9
-rw-r--r--kstars/kstarslite/skyitems/lines/linesitem.cpp5
-rw-r--r--kstars/kstarslite/skyitems/rootnode.cpp66
-rw-r--r--kstars/kstarslite/skyitems/rootnode.h7
-rw-r--r--kstars/kstarslite/skyitems/skyitem.cpp13
-rw-r--r--kstars/kstarslite/skyitems/skyitem.h6
-rw-r--r--kstars/kstarslite/skyitems/skynodes/deepskynode.cpp108
-rw-r--r--kstars/kstarslite/skyitems/skynodes/deepskynode.h75
-rw-r--r--kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp414
-rw-r--r--kstars/kstarslite/skyitems/skynodes/dsosymbolnode.h160
-rw-r--r--kstars/kstarslite/skyitems/skynodes/labelnode.cpp7
-rw-r--r--kstars/kstarslite/skyitems/skynodes/labelnode.h4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp86
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h52
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp21
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/linenode.h1
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp3
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h3
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp2
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/polynode.h2
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp67
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetnode.cpp1
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp14
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.h5
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.h4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skytexturenode.cpp15
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skytexturenode.h15
-rw-r--r--kstars/kstarslite/skyitems/skyopacitynode.h4
-rw-r--r--kstars/kstarslite/skyitems/staritem.cpp84
-rw-r--r--kstars/main.cpp10
-rw-r--r--kstars/skycomponents/deepskycomponent.h8
-rw-r--r--kstars/skycomponents/deepstarcomponent.h2
-rw-r--r--kstars/skycomponents/highpmstarlist.cpp5
-rw-r--r--kstars/skycomponents/highpmstarlist.h2
-rw-r--r--kstars/skycomponents/skylabeler.cpp1
-rw-r--r--kstars/skycomponents/skylabeler.h3
-rw-r--r--kstars/skycomponents/skymapcomposite.h2
-rw-r--r--kstars/skycomponents/starblocklist.cpp3
-rw-r--r--kstars/skycomponents/starcomponent.cpp10
-rw-r--r--kstars/skycomponents/starcomponent.h14
-rw-r--r--kstars/skymaplite.cpp18
-rw-r--r--kstars/skymaplite.h11
-rw-r--r--kstars/skyqpainter.cpp13
52 files changed, 1871 insertions, 261 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index a4020c2..81096f3 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -558,7 +558,8 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/constellationnamesitem.cpp
kstarslite/skyitems/staritem.cpp
kstarslite/skyitems/deepstaritem.cpp
- #Lines
+ kstarslite/skyitems/deepskyitem.cpp
+ #Line
kstarslite/skyitems/lines/linesitem.cpp
kstarslite/skyitems/lines/equatoritem.cpp
kstarslite/skyitems/lines/eclipticitem.cpp
@@ -568,14 +569,16 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/skynodes/pointsourcenode.cpp
kstarslite/skyitems/skynodes/planetmoonsnode.cpp
kstarslite/skyitems/skynodes/horizonnode.cpp
- #kstarslite/skyitems/skynodes/trixelnode.cpp
- #kstarslite/skyitems/skynodes/startrixelnode.cpp
kstarslite/skyitems/skynodes/labelnode.cpp
kstarslite/skyitems/skynodes/guidelabelnode.cpp
+ kstarslite/skyitems/skynodes/skytexturenode.cpp
+ kstarslite/skyitems/skynodes/deepskynode.cpp
+ kstarslite/skyitems/skynodes/dsosymbolnode.cpp
#Nodes
kstarslite/skyitems/skynodes/nodes/pointnode.cpp
kstarslite/skyitems/skynodes/nodes/polynode.cpp
kstarslite/skyitems/skynodes/nodes/linenode.cpp
+ kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
#Material
#kstarslite/skyitems/skynodes/material/dashedshader.cpp
#libtess
@@ -677,7 +680,7 @@ 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})
+ kconfig_add_kcfg_files(kstars_SRCS ${kstars_KCFG_SRCS})
else()
kconfig_add_kcfg_files(kstars_SRCS ${kstars_KCFG_SRCS})
endif()
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index c772db9..fb0322a 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -60,19 +60,19 @@
<label>Time InfoBox anchor flag</label>
<whatsthis>Is the Time InfoBox anchored to a window edge? 0 = not anchored; 1 = anchored to right edge; 2 = anchored to bottom edge; 3 = anchored to bottom and right edges.</whatsthis>
<default>0</default>
- <!--<min>0</min><max>3</max>-->
+ <min>0</min><max>3</max>
</entry>
<entry name="StickyFocusBox" type="Int">
<label>Time InfoBox anchor flag</label>
<whatsthis>Is the Focus InfoBox anchored to a window edge? 0 = not anchored; 1 = anchored to right edge; 2 = anchored to bottom edge; 3 = anchored to bottom and right edges.</whatsthis>
<default>1</default>
- <!--<min>0</min><max>3</max>-->
+ <min>0</min><max>3</max>
</entry>
<entry name="StickyGeoBox" type="Int">
<label>Geographic InfoBox anchor flag</label>
<whatsthis>Is the Geographic Location InfoBox anchored to a window edge? 0 = not anchored; 1 = anchored to right edge; 2 = anchored to bottom edge; 3 = anchored to bottom and right edges.</whatsthis>
<default>2</default>
- <!--<min>0</min><max>3</max>-->
+ <min>0</min><max>3</max>
</entry>
<entry name="ShowStatusBar" type="Bool">
<label>Display the statusbar?</label>
@@ -125,7 +125,7 @@
</entry>
</group>
- <group name="indi">
+ <group name="indi">
<entry name="useGeographicUpdate" type="Bool">
<label>Automatically updates geographic location?</label>
<default>true</default>
@@ -143,7 +143,7 @@
<label>Display INDI messages in the statusbar?</label>
<whatsthis>Toggle display of INDI messages in the KStars statusbar.</whatsthis>
<default>true</default>
- </entry>
+ </entry>
<entry name="useComputerSource" type="Bool">
<label>Use computer time and location for synchronization?</label>
<default>true</default>
@@ -644,7 +644,7 @@
<label>Zoom Factor, in pixels per radian</label>
<whatsthis>The zoom level, measured in pixels per radian.</whatsthis>
<default>1000.</default>
- <!--<min>200.</min><max>5000000.</max>-->
+ <min>200.</min><max>5000000.</max>
</entry>
<entry name="MagLimitAsteroid" type="Double">
<label>Faint limit for asteroids</label>
@@ -762,13 +762,13 @@
<label>Mode for rendering stars</label>
<whatsthis>The method for rendering stars: 0="realistic colors"; 1="solid red"; 2="solid black"; 3="solid white"</whatsthis>
<default>0</default>
- <!--<max>3</max>-->
+ <max>3</max>
</entry>
<entry name="StarColorIntensity" type="UInt">
<label>Saturation level of star colors</label>
<whatsthis>The color saturation level of stars (only applicable when using "realistic colors" mode).</whatsthis>
<default>6</default>
- <!--<max>10</max>-->
+ <max>10</max>
</entry>
<entry name="AngularRulerColor" type="String">
<label>Color of angular distance ruler</label>
@@ -1538,7 +1538,7 @@
<entry name="PHD2Port" type="UInt">
<label>PHD2 Event Monitoring Port</label>
<default>4400</default>
- </entry>
+ </entry>
<entry name="CalibrationPulseDuration" type="UInt">
<label>Pulse duration in milliseconds used for guiding pulses during calibration stage.</label>
<default>1000</default>
diff --git a/kstars/kstarslite/qml/main.qml b/kstars/kstarslite/qml/main.qml
index 887917e..45846ce 100644
--- a/kstars/kstarslite/qml/main.qml
+++ b/kstars/kstarslite/qml/main.qml
@@ -52,7 +52,7 @@ Window {
right: parent.right
top: parent.top
}
- height: parent.height * 0.25
+ height: parent.height * 0.10
onPressed: {
posY = mouseY
@@ -153,7 +153,7 @@ Window {
horizontalCenter: parent.horizontalCenter
}
width: bottomMenu.width
- height: parent.height *0.25
+ height: parent.height *0.10
onPressed: {
posY = mouseY
diff --git a/kstars/kstarslite/skyitems/cometsitem.cpp b/kstars/kstarslite/skyitems/cometsitem.cpp
index ed687e5..70d7eaf 100644
--- a/kstars/kstarslite/skyitems/cometsitem.cpp
+++ b/kstars/kstarslite/skyitems/cometsitem.cpp
@@ -40,9 +40,13 @@ void CometsItem::update() {
show();
- bool hideLabels = ! Options::showCometNames() ||
+ bool hideLabel = ! Options::showCometNames() ||
(SkyMapLite::Instance()->isSlewing() &&
Options::hideLabels() );
+
+ if(hideLabel) {
+ hideLabels();
+ }
double rsunLabelLimit = Options::maxRadCometName();
/*//FIXME: Should these be config'able?
@@ -61,7 +65,7 @@ void CometsItem::update() {
if (std::isnan(mag) == 0)
{
bool drawLabel = false;
- if ( !(hideLabels || com->rsun() >= rsunLabelLimit) ) {
+ if ( !(hideLabel || com->rsun() >= rsunLabelLimit) ) {
drawLabel = true;
}
skyNode->update(drawLabel);
diff --git a/kstars/kstarslite/skyitems/deepskyitem.cpp b/kstars/kstarslite/skyitems/deepskyitem.cpp
new file mode 100644
index 0000000..8bb5a81
--- /dev/null
+++ b/kstars/kstarslite/skyitems/deepskyitem.cpp
@@ -0,0 +1,322 @@
+/** *************************************************************************
+ deepskyitem.cpp - K Desktop Planetarium
+ -------------------
+ begin : 18/06/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "Options.h"
+#include "projections/projector.h"
+
+#include "skynodes/deepskynode.h"
+#include "labelsitem.h"
+#include "deepskyitem.h"
+#include "deepstaritem.h"
+#include "skynodes/dsosymbolnode.h"
+
+#include "starcomponent.h"
+#include "starblockfactory.h"
+#include "skymesh.h"
+#include "rootnode.h"
+
+DSOIndexNode::DSOIndexNode(DeepSkyIndex *index)
+ :m_index(index), m_trixImage(new QSGNode), m_trixSymbol(new QSGNode)
+{
+ appendChildNode(m_trixImage);
+ appendChildNode(m_trixSymbol);
+}
+
+DSOTrixelNode::DSOTrixelNode(Trixel trixelID)
+ :trixel(trixelID)
+{
+
+}
+
+DeepSkyItem::DeepSkyItem(DeepSkyComponent *dsoComp, RootNode *rootNode)
+ :SkyItem(LabelsItem::label_t::DEEP_SKY_LABEL, rootNode), m_dsoComp(dsoComp),
+ m_skyMesh(SkyMesh::Instance())
+
+ /*,m_starLabels(rootNode->labelsItem()->getLabelNode(labelType())), m_stars(new SkyOpacityNode),
+ m_deepStars(new SkyOpacityNode)*/
+{
+ m_Messier = new DSOIndexNode(&(m_dsoComp->m_MessierIndex));
+ appendChildNode(m_Messier);
+
+ m_NGC = new DSOIndexNode(&(m_dsoComp->m_NGCIndex));
+ appendChildNode(m_NGC);
+
+ m_IC = new DSOIndexNode(&(m_dsoComp->m_ICIndex));
+ appendChildNode(m_IC);
+
+ m_other = new DSOIndexNode(&(m_dsoComp->m_OtherIndex));
+ appendChildNode(m_other);
+
+ QSGNode *n = firstChild();
+
+ while(n != 0 ) {
+ DSOIndexNode *indexNode = static_cast<DSOIndexNode *>(n);
+ DeepSkyIndex *index = indexNode->m_index;
+ QMap<int, DeepSkyList* > result;
+ QHashIterator<int, DeepSkyList*> it(*index);
+ while (it.hasNext()) {
+ it.next();
+ result.insert(it.key(), it.value());
+ }
+
+ QMap<int, DeepSkyList* >::const_iterator i = result.constBegin();
+
+ while(i != result.constEnd()) {
+ DeepSkyList *dsoList = i.value();
+
+ DSOTrixelNode *trixelImage = new DSOTrixelNode(i.key());
+ DSOTrixelNode *trixelSymbol = new DSOTrixelNode(i.key());
+
+ indexNode->m_trixImage->appendChildNode(trixelImage);
+ indexNode->m_trixSymbol->appendChildNode(trixelSymbol);
+
+ for(int c = 0; c < dsoList->size(); ++c) {
+ DeepSkyObject *dso = dsoList->at(c);
+ if(dso) {
+ DSOSymbolNode *dsoSymbol = new DSOSymbolNode(dso);
+ trixelSymbol->appendChildNode(dsoSymbol);
+
+ DeepSkyNode *dsoNode = new DeepSkyNode(dso, dsoSymbol);
+ trixelImage->appendChildNode(dsoNode);
+ }
+ }
+ ++i;
+ }
+ n = n->nextSibling();
+ }
+}
+
+void DeepSkyItem::update() {
+ if( !m_dsoComp->selected() ) {
+ hide();
+ return;
+ }
+
+ bool drawFlag;
+
+ MeshIterator region( m_skyMesh, DRAW_BUF );
+
+ drawFlag = Options::showMessier() &&
+ ! ( Options::hideOnSlew() && Options::hideMessier() && SkyMapLite::IsSlewing() );
+
+ updateDeepSkyNode(m_Messier, drawFlag, "MessColor", &region, Options::showMessierImages() );
+
+ drawFlag = Options::showNGC() &&
+ ! ( Options::hideOnSlew() && Options::hideNGC() && SkyMapLite::IsSlewing() );
+
+ updateDeepSkyNode(m_NGC, drawFlag, "NGCColor", &region );
+
+ drawFlag = Options::showIC() &&
+ ! ( Options::hideOnSlew() && Options::hideIC() && SkyMapLite::IsSlewing() );
+
+ updateDeepSkyNode(m_IC, drawFlag, "ICColor", &region );
+
+ drawFlag = Options::showOther() &&
+ ! ( Options::hideOnSlew() && Options::hideOther() && SkyMapLite::IsSlewing() );
+
+ updateDeepSkyNode(m_other, drawFlag, "NGCColor", &region );
+}
+
+void DeepSkyItem::updateDeepSkyNode(DSOIndexNode *indexNode, bool drawObject, const QString& colorString,
+ MeshIterator *region, bool drawImage)
+{
+#ifndef KSTARS_LITE
+ //adjust maglimit for ZoomLevel
+ double lgmin = log10(MINZOOM);
+ double lgmax = log10(MAXZOOM);
+ double lgz = log10(Options::zoomFactor());
+ if ( lgz <= 0.75 * lgmax )
+ maglim -= (Options::magLimitDrawDeepSky() - Options::magLimitDrawDeepSkyZoomOut() )*(0.75*lgmax - lgz)/(0.75*lgmax - lgmin);
+ m_zoomMagLimit = maglim;
+
+ double labelMagLim = Options::deepSkyLabelDensity();
+ labelMagLim += ( Options::magLimitDrawDeepSky() - labelMagLim ) * ( lgz - lgmin) / (lgmax - lgmin );
+ if ( labelMagLim > Options::magLimitDrawDeepSky() ) labelMagLim = Options::magLimitDrawDeepSky();
+
+ ////
+ //DrawID drawID = m_skyMesh->drawID();
+ MeshIterator region( m_skyMesh, DRAW_BUF );
+
+ while ( region.hasNext() ) {
+
+ Trixel trixel = region.next();
+ DeepSkyList* dsList = dsIndex->value( trixel );
+ if ( dsList == 0 ) continue;
+ for (int j = 0; j < dsList->size(); j++ ) {
+ DeepSkyObject *obj = dsList->at( j );
+
+ //if ( obj->drawID == drawID ) continue; // only draw each line once
+ //obj->drawID = drawID;
+
+ if ( obj->updateID != updateID ) {
+ obj->updateID = updateID;
+ if ( obj->updateNumID != updateNumID) {
+ obj->updateCoords( data->updateNum() );
+ }
+ obj->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ }
+
+ float mag = obj->mag();
+ float size = obj->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 ) );
+ if ( sizeCriterion && magCriterion )
+ {
+
+ bool drawn = skyp->drawDeepSkyObject(obj, drawImage);
+ if ( drawn && !( m_hideLabels || mag > labelMagLim ) )
+ addLabel( proj->toScreen(obj), obj );
+ //FIXME: find a better way to do above
+ }
+ }
+ }
+#endif
+ if ( ! ( drawObject || drawImage ) ) {
+ indexNode->hide();
+ return;
+ }
+
+ indexNode->show();
+
+ SkyMapLite *map = SkyMapLite::Instance();
+ //const Projector *proj = map->projector();
+ KStarsData *data = KStarsData::Instance();
+
+ UpdateID updateID = data->updateID();
+ UpdateID updateNumID = data->updateNumID();
+
+ //WARNING: CHECK COLOR
+ /*skyp->setPen( data->colorScheme()->colorNamed( colorString ) );
+ skyp->setBrush( Qt::NoBrush );*/
+
+ bool m_hideLabels = ( map->isSlewing() && Options::hideOnSlew() ) ||
+ ! ( Options::showDeepSkyMagnitudes() || Options::showDeepSkyNames() );
+
+
+ double maglim = Options::magLimitDrawDeepSky();
+ bool showUnknownMagObjects = Options::showUnknownMagObjects();
+
+ //adjust maglimit for ZoomLevel
+ double lgmin = log10(MINZOOM);
+ double lgmax = log10(MAXZOOM);
+ double lgz = log10(Options::zoomFactor());
+ if ( lgz <= 0.75 * lgmax )
+ maglim -= (Options::magLimitDrawDeepSky() - Options::magLimitDrawDeepSkyZoomOut() )*(0.75*lgmax - lgz)/(0.75*lgmax - lgmin);
+ double m_zoomMagLimit = maglim;
+
+ double labelMagLim = Options::deepSkyLabelDensity();
+ labelMagLim += ( Options::magLimitDrawDeepSky() - labelMagLim ) * ( lgz - lgmin) / (lgmax - lgmin );
+ if ( labelMagLim > Options::magLimitDrawDeepSky() ) labelMagLim = Options::magLimitDrawDeepSky();
+
+ //DrawID drawID = m_skyMesh->drawID();
+
+ int regionID = -1;
+ if(region->hasNext()) {
+ regionID = region->next();
+ }
+
+ /*//Check that at least one trixel is shown
+
+ if(regionID == -1) {
+ hide();
+ return;
+ } else {
+ show();
+ }*/
+
+ DSOTrixelNode *trixelImg = static_cast<DSOTrixelNode *>(indexNode->m_trixImage->firstChild());
+ DSOTrixelNode *trixelSymbol = static_cast<DSOTrixelNode *>(indexNode->m_trixSymbol->firstChild());
+ while( trixelImg != 0 ) {
+ if(trixelImg->trixel < regionID) {
+ trixelImg->hide();
+ trixelSymbol->hide();
+ //label->hide();
+
+ trixelImg = static_cast<DSOTrixelNode *>(trixelImg->nextSibling());
+ trixelSymbol = static_cast<DSOTrixelNode *>(trixelSymbol->nextSibling());
+ //label = static_cast<TrixelNode *>(label->nextSibling());
+ continue;
+ } else if(trixelImg->trixel > regionID) {
+ if (region->hasNext()) {
+ regionID = region->next();
+ } else {
+ while(trixelImg != 0) {
+ trixelImg->hide();
+ trixelSymbol->hide();
+
+ trixelImg = static_cast<DSOTrixelNode *>(trixelImg->nextSibling());
+ trixelSymbol = static_cast<DSOTrixelNode *>(trixelSymbol->nextSibling());
+ }
+ break;
+ }
+ continue;
+ } else {
+ trixelImg->show();
+ trixelSymbol->show();
+ //label->show();
+ if(region->hasNext()) {
+ regionID = region->next();
+ }
+ }
+
+ QSGNode *n = trixelImg->firstChild();
+
+ while(n != 0) {
+ DeepSkyNode *dsoNode = static_cast<DeepSkyNode *>(n);
+ n = n->nextSibling();
+
+ DeepSkyObject *obj = static_cast<DeepSkyObject *>(dsoNode->dsObject());
+ //if ( obj->drawID == drawID ) continue; // only draw each line once
+ //obj->drawID = drawID;
+
+ if ( obj->updateID != updateID ) {
+ obj->updateID = updateID;
+ if ( obj->updateNumID != updateNumID) {
+ obj->updateCoords( data->updateNum() );
+ }
+ obj->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ }
+
+ float mag = obj->mag();
+ float size = obj->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 ) );
+ if ( sizeCriterion && magCriterion )
+ {
+ dsoNode->update(drawImage);
+ /*bool drawn = skyp->drawDeepSkyObject(obj, drawImage);
+ if ( drawn && !( m_hideLabels || mag > labelMagLim ) )
+ addLabel( proj->toScreen(obj), obj );
+ //FIXME: find a better way to do above*/
+ } else {
+ dsoNode->hide();
+ }
+ }
+
+ trixelImg = static_cast<DSOTrixelNode *>(trixelImg->nextSibling());
+ trixelSymbol = static_cast<DSOTrixelNode *>(trixelSymbol->nextSibling());
+ //label = static_cast<TrixelNode *>(label->nextSibling());
+ }
+ region->reset();
+}
diff --git a/kstars/kstarslite/skyitems/deepskyitem.h b/kstars/kstarslite/skyitems/deepskyitem.h
new file mode 100644
index 0000000..cd1d6ea
--- /dev/null
+++ b/kstars/kstarslite/skyitems/deepskyitem.h
@@ -0,0 +1,76 @@
+/** *************************************************************************
+ deepskyitem.h - K Desktop Planetarium
+ -------------------
+ begin : 18/06/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 DEEPSKYITEM_H_
+#define DEEPSKYITEM_H_
+
+#include "skyitem.h"
+#include "skyopacitynode.h"
+#include "deepskycomponent.h"
+#include "typedeflite.h"
+
+class DSOIndexNode : public SkyOpacityNode {
+public:
+ DSOIndexNode(DeepSkyIndex *index);
+ QSGNode *m_trixImage;
+ QSGNode *m_trixSymbol;
+ DeepSkyIndex *m_index;
+};
+
+class DSOTrixelNode : public TrixelNode {
+public:
+ DSOTrixelNode(Trixel trixelID);
+ Trixel trixel;
+};
+
+ /** @class StarItem
+ *
+ *@short Class that handles Deep Sky Objects
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class DeepSkyComponent;
+class SkyMesh;
+class StarBlockFactory;
+class MeshIterator;
+
+class DeepSkyItem : public SkyItem {
+public:
+ /**
+ * @short Constructor.
+ * @param rootNode parent RootNode that instantiated this object
+ */
+ DeepSkyItem(DeepSkyComponent *dsoComp, RootNode *rootNode);
+
+ /**
+ * @short updates all trixels that contain stars
+ */
+ virtual void update();
+
+ void updateDeepSkyNode(DSOIndexNode *node, bool drawObject, const QString& colorString,
+ MeshIterator *region, bool drawImage = false);
+
+private:
+ DeepSkyComponent *m_dsoComp;
+ SkyMesh *m_skyMesh;
+
+ DSOIndexNode *m_Messier;
+ DSOIndexNode *m_NGC;
+ DSOIndexNode *m_IC;
+ DSOIndexNode *m_other;
+};
+#endif
+
diff --git a/kstars/kstarslite/skyitems/deepstaritem.cpp b/kstars/kstarslite/skyitems/deepstaritem.cpp
index 9325afb..ffb9b9a 100644
--- a/kstars/kstarslite/skyitems/deepstaritem.cpp
+++ b/kstars/kstarslite/skyitems/deepstaritem.cpp
@@ -182,187 +182,187 @@ void DeepStarItem::update() {
m_skyMesh->inDraw( false );
#endif
- //if(m_staticStars) {
- SkyMapLite *map = SkyMapLite::Instance();
- KStarsData* data = KStarsData::Instance();
- UpdateID updateID = data->updateID();
+ if(m_staticStars) { // dynamic stars under construction
+ SkyMapLite *map = SkyMapLite::Instance();
+ KStarsData* data = KStarsData::Instance();
+ UpdateID updateID = data->updateID();
- //FIXME_FOV -- maybe not clamp like that...
- float radius = map->projector()->fov();
- if ( radius > 90.0 ) radius = 90.0;
+ //FIXME_FOV -- maybe not clamp like that...
+ float radius = map->projector()->fov();
+ if ( radius > 90.0 ) radius = 90.0;
- if ( m_skyMesh != SkyMesh::Instance() && m_skyMesh->inDraw() ) {
- printf("Warning: aborting concurrent DeepStarComponent::draw()");
- }
- bool checkSlewing = ( map->isSlewing() && Options::hideOnSlew() );
+ if ( m_skyMesh != SkyMesh::Instance() && m_skyMesh->inDraw() ) {
+ printf("Warning: aborting concurrent DeepStarComponent::draw()");
+ }
+ bool checkSlewing = ( map->isSlewing() && Options::hideOnSlew() );
- //shortcuts to inform whether to draw different objects
- bool hideFaintStars( checkSlewing && Options::hideStars() );
- double hideStarsMag = Options::magLimitHideStar();
+ //shortcuts to inform whether to draw different objects
+ bool hideFaintStars( checkSlewing && Options::hideStars() );
+ double hideStarsMag = Options::magLimitHideStar();
- //adjust maglimit for ZoomLevel
- // double lgmin = log10(MINZOOM);
- // double lgmax = log10(MAXZOOM);
- // double lgz = log10(Options::zoomFactor());
- // TODO: Enable hiding of faint stars
+ //adjust maglimit for ZoomLevel
+ // double lgmin = log10(MINZOOM);
+ // double lgmax = log10(MAXZOOM);
+ // double lgz = log10(Options::zoomFactor());
+ // TODO: Enable hiding of faint stars
- float maglim = StarComponent::zoomMagnitudeLimit();
+ float maglim = StarComponent::zoomMagnitudeLimit();
- if( maglim < m_deepStarComp->triggerMag || !m_staticStars ) {
- hide();
- return;
- } else {
- show();
- }
+ if( maglim < m_deepStarComp->triggerMag || !m_staticStars ) {
+ hide();
+ return;
+ } else {
+ show();
+ }
- float m_zoomMagLimit = maglim;
+ float m_zoomMagLimit = maglim;
- m_skyMesh->inDraw( true );
+ m_skyMesh->inDraw( true );
- SkyPoint* focus = map->focus();
- m_skyMesh->aperture( focus, radius + 1.0, DRAW_BUF ); // divide by 2 for testing
+ SkyPoint* focus = map->focus();
+ m_skyMesh->aperture( focus, radius + 1.0, DRAW_BUF ); // divide by 2 for testing
- MeshIterator region(m_skyMesh, DRAW_BUF);
+ 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 we are to hide the fainter stars (eg: while slewing), we set the magnitude limit to hideStarsMag.
+ if( hideFaintStars && maglim > hideStarsMag )
+ maglim = hideStarsMag;
- StarBlockFactory *m_StarBlockFactory = StarBlockFactory::Instance();
- // m_StarBlockFactory->drawID = m_skyMesh->drawID();
- // qDebug() << "Mesh size = " << m_skyMesh->size() << "; drawID = " << m_skyMesh->drawID();
+ StarBlockFactory *m_StarBlockFactory = StarBlockFactory::Instance();
+ // m_StarBlockFactory->drawID = m_skyMesh->drawID();
+ // qDebug() << "Mesh size = " << m_skyMesh->size() << "; drawID = " << m_skyMesh->drawID();
- /*t_dynamicLoad = 0;
+ /*t_dynamicLoad = 0;
t_updateCache = 0;
t_drawUnnamed = 0;*/
- //visibleStarCount = 0;
-
- // Mark used blocks in the LRU Cache. Not required for static stars
- if( !m_staticStars ) {
- while( region.hasNext() ) {
- Trixel currentRegion = region.next();
- for( int i = 0; i < m_starBlockList->at( currentRegion )->getBlockCount(); ++i ) {
- StarBlock *prevBlock = ( ( i >= 1 ) ? m_starBlockList->at( currentRegion )->block( i - 1 ) : NULL );
- StarBlock *block = m_starBlockList->at( currentRegion )->block( i );
-
- if( i == 0 && !m_StarBlockFactory->markFirst( block ) )
- qDebug() << "markFirst failed in trixel" << currentRegion;
- if( i > 0 && !m_StarBlockFactory->markNext( prevBlock, block ) )
- qDebug() << "markNext failed in trixel" << currentRegion << "while marking block" << i;
- if( i < m_starBlockList->at( currentRegion )->getBlockCount()
- && m_starBlockList->at( currentRegion )->block( i )->getFaintMag() < maglim )
- break;
+ //visibleStarCount = 0;
+
+ // Mark used blocks in the LRU Cache. Not required for static stars
+ if( !m_staticStars ) {
+ while( region.hasNext() ) {
+ Trixel currentRegion = region.next();
+ for( int i = 0; i < m_starBlockList->at( currentRegion )->getBlockCount(); ++i ) {
+ StarBlock *prevBlock = ( ( i >= 1 ) ? m_starBlockList->at( currentRegion )->block( i - 1 ) : NULL );
+ StarBlock *block = m_starBlockList->at( currentRegion )->block( i );
+
+ if( i == 0 && !m_StarBlockFactory->markFirst( block ) )
+ qDebug() << "markFirst failed in trixel" << currentRegion;
+ if( i > 0 && !m_StarBlockFactory->markNext( prevBlock, block ) )
+ qDebug() << "markNext failed in trixel" << currentRegion << "while marking block" << i;
+ if( i < m_starBlockList->at( currentRegion )->getBlockCount()
+ && m_starBlockList->at( currentRegion )->block( i )->getFaintMag() < maglim )
+ break;
+ }
}
+ //t_updateCache = t.restart();
+ region.reset();
}
- //t_updateCache = t.restart();
- region.reset();
- }
- m_StarBlockFactory->drawID = m_skyMesh->drawID();
+ m_StarBlockFactory->drawID = m_skyMesh->drawID();
- int regionID = -1;
- if(region.hasNext()) {
- regionID = region.next();
- }
+ int regionID = -1;
+ if(region.hasNext()) {
+ regionID = region.next();
+ }
- int trixelID = 0;
+ int trixelID = 0;
- QSGNode *firstTrixel = firstChild();
- TrixelNode *trixel = static_cast<TrixelNode *>(firstTrixel);
+ QSGNode *firstTrixel = firstChild();
+ TrixelNode *trixel = static_cast<TrixelNode *>(firstTrixel);
- while( trixel != 0 ) {
- if(trixelID != regionID) {
- trixel->hide();
+ while( trixel != 0 ) {
+ if(trixelID != regionID) {
+ trixel->hide();
- trixel = static_cast<TrixelNode *>(trixel->nextSibling());
+ trixel = static_cast<TrixelNode *>(trixel->nextSibling());
- trixelID++;
+ trixelID++;
- continue;
- } else {
- trixel->show();
+ continue;
+ } else {
+ trixel->show();
- if(region.hasNext()) {
- regionID = region.next();
+ if(region.hasNext()) {
+ regionID = region.next();
+ }
}
- }
- if(m_staticStars) {
+ if(m_staticStars) {
- QSGNode *n = trixel->firstChild();
+ QSGNode *n = trixel->firstChild();
- bool hide = false;
+ bool hide = false;
- while(n != 0) {
- PointSourceNode *point = static_cast<PointSourceNode *>(n);
- n = n->nextSibling();
+ while(n != 0) {
+ PointSourceNode *point = static_cast<PointSourceNode *>(n);
+ n = n->nextSibling();
- StarObject *curStar = static_cast<StarObject *>(point->skyObject());
- float mag = curStar->mag();
+ StarObject *curStar = static_cast<StarObject *>(point->skyObject());
+ float mag = curStar->mag();
- // break loop if maglim is reached
- if(!hide) {
- if ( mag > maglim ) hide = true;
- }
+ // break loop if maglim is reached
+ if(!hide) {
+ if ( mag > maglim ) hide = true;
+ }
- if(!hide) {
- if ( curStar->updateID != KStarsData::Instance()->updateID() )
- curStar->JITupdate();
- point->setSizeMagLim(m_zoomMagLimit);
- point->update();
- } else {
- point->hide();
+ if(!hide) {
+ if ( curStar->updateID != KStarsData::Instance()->updateID() )
+ curStar->JITupdate();
+ //point->setSizeMagLim(m_zoomMagLimit);
+ point->update();
+ } else {
+ point->hide();
+ }
+ }
+ } else if(false) {
+ if( !m_staticStars && !m_starBlockList->at( regionID )->fillToMag( maglim ) && maglim <= m_deepStarComp->m_FaintMagnitude * ( 1 - 1.5/16 ) ) {
+ qDebug() << "SBL::fillToMag( " << maglim << " ) failed for trixel "
+ << regionID << " !"<< endl;
}
- }
- } else if(false) {
- if( !m_staticStars && !m_starBlockList->at( regionID )->fillToMag( maglim ) && maglim <= m_deepStarComp->m_FaintMagnitude * ( 1 - 1.5/16 ) ) {
- qDebug() << "SBL::fillToMag( " << maglim << " ) failed for trixel "
- << regionID << " !"<< endl;
- }
- for( int i = 0; i < m_starBlockList->at( regionID )->getBlockCount(); ++i ) {
+ for( int i = 0; i < m_starBlockList->at( regionID )->getBlockCount(); ++i ) {
- bool hide = false;
+ bool hide = false;
- StarBlock *block = m_starBlockList->at( regionID )->block( i );
- for( int j = 0; j < block->getStarCount(); j++ ) {
+ StarBlock *block = m_starBlockList->at( regionID )->block( i );
+ for( int j = 0; j < block->getStarCount(); j++ ) {
- StarNode *star = block->star( j );
- StarObject *curStar = &(star->star);
- PointSourceNode *point = star->starNode;
+ StarNode *star = block->star( j );
+ StarObject *curStar = &(star->star);
+ PointSourceNode *point = star->starNode;
- if ( curStar->updateID != updateID )
- curStar->JITupdate();
+ if ( curStar->updateID != updateID )
+ curStar->JITupdate();
- float mag = curStar->mag();
-
- if(!hide) {
- if ( mag > maglim ) hide = true;
- }
+ float mag = curStar->mag();
- if(!hide) {
- if(!point) {
- star->starNode = new PointSourceNode(curStar, rootNode(), LabelsItem::label_t::NO_LABEL, curStar->spchar(),
- curStar->mag(), regionID);
- point = star->starNode;
- trixel->appendChildNode(point);
+ if(!hide) {
+ if ( mag > maglim ) hide = true;
}
- point->setSizeMagLim(m_zoomMagLimit);
- point->update();
- } else {
- if(point) point->hide();
+ if(!hide) {
+ if(!point) {
+ star->starNode = new PointSourceNode(curStar, rootNode(), LabelsItem::label_t::NO_LABEL, curStar->spchar(),
+ curStar->mag(), regionID);
+ point = star->starNode;
+ trixel->appendChildNode(point);
+ }
+ //point->setSizeMagLim(m_zoomMagLimit);
+ point->update();
+
+ } else {
+ if(point) point->hide();
+ }
}
}
}
- }
- trixel = static_cast<TrixelNode *>(trixel->nextSibling());
+ trixel = static_cast<TrixelNode *>(trixel->nextSibling());
- trixelID++;
+ trixelID++;
+ }
+ m_skyMesh->inDraw( false );
}
- m_skyMesh->inDraw( false );
}
-//}
diff --git a/kstars/kstarslite/skyitems/labelsitem.cpp b/kstars/kstarslite/skyitems/labelsitem.cpp
index dc1d0ac..1913486 100644
--- a/kstars/kstarslite/skyitems/labelsitem.cpp
+++ b/kstars/kstarslite/skyitems/labelsitem.cpp
@@ -65,6 +65,22 @@ LabelsItem::LabelsItem()
appendChildNode(deep_sky);
m_labelsLists.insert(label_t::DEEP_SKY_LABEL, deep_sky);
+ LabelTypeNode *dso_messier = new LabelTypeNode;
+ deep_sky->appendChildNode(dso_messier);
+ m_labelsLists.insert(label_t::DSO_MESSIER_LABEL, dso_messier);
+
+ LabelTypeNode *dso_ngc = new LabelTypeNode;
+ deep_sky->appendChildNode(dso_ngc);
+ m_labelsLists.insert(label_t::DSO_NGC_LABEL, dso_ngc);
+
+ LabelTypeNode *dso_ic = new LabelTypeNode;
+ deep_sky->appendChildNode(dso_ic);
+ m_labelsLists.insert(label_t::DSO_IC_LABEL, dso_ic);
+
+ LabelTypeNode *dso_other = new LabelTypeNode;
+ deep_sky->appendChildNode(dso_other);
+ m_labelsLists.insert(label_t::DSO_OTHER_LABEL, dso_other);
+
LabelTypeNode *constellation = new LabelTypeNode;
appendChildNode(constellation);
m_labelsLists.insert(label_t::CONSTEL_NAME_LABEL, constellation);
@@ -138,13 +154,15 @@ void LabelsItem::update() {
updateChildLabels(label_t::SATURN_MOON_LABEL);
updateChildLabels(label_t::ASTEROID_LABEL);
- if(getLabelNode(label_t::COMET_LABEL)->opacity()) {
+ if(getLabelNode(label_t::COMET_LABEL)->visible()) {
updateChildLabels(label_t::COMET_LABEL);
}
updateChildLabels(label_t::CONSTEL_NAME_LABEL);
- updateChildLabels(label_t::STAR_LABEL);
+ if(getLabelNode(label_t::STAR_LABEL)->visible()) {
+ updateChildLabels(label_t::STAR_LABEL);
+ }
}
void LabelsItem::hideLabels(label_t labelType) {
@@ -161,12 +179,52 @@ void LabelsItem::setRootNode(RootNode *rootNode) {
}
void LabelsItem::deleteLabels(label_t labelType) {
- if(labelType != NO_LABEL) {
+ if(labelType == STAR_LABEL) {
+ LabelTypeNode *node = m_labelsLists[labelType];
+ QSGNode *trixel = node->firstChild();
+ while(trixel != 0) {
+ while(QSGNode *label = trixel->firstChild()) {
+ trixel->removeChildNode(label);
+ delete label;
+ }
+ trixel = trixel->nextSibling();
+ }
+ } else if(labelType != NO_LABEL) {
LabelTypeNode *node = m_labelsLists[labelType];
while(QSGNode *n = node->firstChild()) { node->removeChildNode(n); delete n; }
}
}
+void LabelsItem::deleteLabel(LabelNode *label) {
+ if(label) {
+ label_t type = label->labelType();
+ LabelTypeNode *node = m_labelsLists[type];
+
+ if(type == STAR_LABEL) {
+ QSGNode *trixel = node->firstChild();
+ bool found = false;
+
+ while(trixel != 0 && !found) {
+ QSGNode *l = trixel->firstChild();
+ while(l != 0) {
+ if(l == label) {
+ trixel->removeChildNode(label);
+ delete label;
+
+ found = true;
+ break;
+ }
+ l = l->nextSibling();
+ }
+ trixel = trixel->nextSibling();
+ }
+ } else {
+ node->removeChildNode(label);
+ delete label;
+ }
+ }
+}
+
void LabelsItem::updateChildLabels(label_t labelType) {
LabelTypeNode *node = m_labelsLists[labelType];
node->show();
@@ -189,7 +247,13 @@ void LabelsItem::updateChildLabels(label_t labelType) {
}
} else {*/
while( n != 0) {
- if(labelType == STAR_LABEL) {
+ /*
+ * int max = int( m_zoomMagLimit * 10.0 );
+ if ( max < 0 ) max = 0;
+ if ( max > MAX_LINENUMBER_MAG ) max = MAX_LINENUMBER_MAG;
+ */
+ if(labelType == STAR_LABEL || labelType == DSO_NGC_LABEL || labelType == DSO_MESSIER_LABEL
+ || labelType == DSO_IC_LABEL || labelType == DSO_OTHER_LABEL) {
TrixelNode *trixel = static_cast<TrixelNode *>(n);
if(trixel->visible()) {
diff --git a/kstars/kstarslite/skyitems/labelsitem.h b/kstars/kstarslite/skyitems/labelsitem.h
index 2081dcf..99e333d 100644
--- a/kstars/kstarslite/skyitems/labelsitem.h
+++ b/kstars/kstarslite/skyitems/labelsitem.h
@@ -78,6 +78,10 @@ public:
JUPITER_MOON_LABEL,
SATURN_MOON_LABEL,
DEEP_SKY_LABEL,
+ DSO_MESSIER_LABEL,
+ DSO_NGC_LABEL,
+ DSO_IC_LABEL,
+ DSO_OTHER_LABEL,
CONSTEL_NAME_LABEL,
SATELLITE_LABEL,
RUDE_LABEL, ///Rude labels block other labels FIXME: find a better solution
@@ -143,6 +147,11 @@ public:
void deleteLabels(label_t labelType);
/**
+ * @short deletes particular label
+ */
+ void deleteLabel(LabelNode *label);
+
+ /**
* @short hides all labels of type labelType
*/
diff --git a/kstars/kstarslite/skyitems/lines/linesitem.cpp b/kstars/kstarslite/skyitems/lines/linesitem.cpp
index 6c2b77f..baec4dd 100644
--- a/kstars/kstarslite/skyitems/lines/linesitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/linesitem.cpp
@@ -46,8 +46,9 @@ void LinesItem::addLinesComponent(LineListIndex *linesComp, QString color, int w
QColor schemeColor = KStarsData::Instance()->colorScheme()->colorNamed(color);
for(int c = 0; c < linesList->size(); ++c) {
- LineNode * ln = new LineNode(linesList->at(c), schemeColor, width, style);
- trixel->appendChildNode(ln);
+ //LineNode * ln = new LineNode(linesList->at(c), schemeColor, width, style);
+ /*trixel->appendChildNode(ln);*/
+ trixel->appendChildNode(new LineNode(linesList->at(c), schemeColor, width, style));
}
}
++i;
diff --git a/kstars/kstarslite/skyitems/rootnode.cpp b/kstars/kstarslite/skyitems/rootnode.cpp
index dfed107..55f6899 100644
--- a/kstars/kstarslite/skyitems/rootnode.cpp
+++ b/kstars/kstarslite/skyitems/rootnode.cpp
@@ -10,6 +10,7 @@
#include "constellationboundarylines.h"
#include "constellationlines.h"
+#include "starcomponent.h"
#include "horizontalcoordinategrid.h"
#include "equatorialcoordinategrid.h"
@@ -19,6 +20,7 @@
//SkyItems
#include "kstarslite/skyitems/staritem.h"
+#include "kstarslite/skyitems/deepskyitem.h"
#include "kstarslite/skyitems/planetsitem.h"
#include "kstarslite/skyitems/asteroidsitem.h"
#include "kstarslite/skyitems/cometsitem.h"
@@ -51,7 +53,7 @@ RootNode::RootNode()
m_linesItem->addLinesComponent( m_skyComposite->constellationBoundary(), "CBoundColor", 1, Qt::SolidLine );
m_linesItem->addLinesComponent( m_skyComposite->constellationLines(), "CLineColor", 1, Qt::SolidLine );
- m_starItem = new StarItem(m_skyComposite->starComponent(), this);
+ m_starItem = new StarItem(StarComponent::Instance(), this);
m_solarSystem = m_skyComposite->solarSystemComposite();
@@ -63,6 +65,8 @@ RootNode::RootNode()
m_cometsItem = new CometsItem(m_solarSystem->comets(), this);
m_constelNamesItem = new ConstellationNamesItem(m_skyComposite->constellationNamesComponent(), this);
+ m_dsoItem = new DeepSkyItem( m_skyComposite->deepSkyComponent(), this );
+
m_horizonItem = new HorizonItem(m_skyComposite->horizon(), this);
setIsRectangular(false);
@@ -75,6 +79,64 @@ RootNode::RootNode()
*/
}
+void RootNode::testLeakAdd() {
+/* m_linesItem = new LinesItem(this);
+
+ m_linesItem->addLinesComponent( m_skyComposite->equatorialCoordGrid(), "EquatorialGridColor", 1, Qt::DotLine );
+ m_linesItem->addLinesComponent( m_skyComposite->horizontalCoordGrid(), "HorizontalGridColor", 2, Qt::DotLine );
+
+ m_linesItem->addLinesComponent( m_skyComposite->constellationBoundary(), "CBoundColor", 1, Qt::SolidLine );
+ m_linesItem->addLinesComponent( m_skyComposite->constellationLines(), "CLineColor", 1, Qt::SolidLine );
+
+ m_starItem = new StarItem(m_skyComposite->starComponent(), this);
+
+ m_solarSystem = m_skyComposite->solarSystemComposite();
+
+ m_equator = new EquatorItem(m_skyComposite->equator(),this);
+ m_ecliptic = new EclipticItem(m_skyComposite->ecliptic(),this);
+
+ m_planetsItem = new PlanetsItem(m_solarSystem->planets(), m_solarSystem->planetMoonsComponent(), this);
+ m_asteroidsItem = new AsteroidsItem(m_solarSystem->asteroids(), this);
+ m_cometsItem = new CometsItem(m_solarSystem->comets(), this);
+
+ m_constelNamesItem = new ConstellationNamesItem(m_skyComposite->constellationNamesComponent(), this);
+ m_horizonItem = new HorizonItem(m_skyComposite->horizon(), this);*/
+}
+
+void RootNode::testLeakDelete() {
+ /*removeChildNode(m_linesItem);
+ delete m_linesItem;
+
+ removeChildNode(m_starItem);
+ delete m_starItem;
+
+ removeChildNode(m_equator);
+ delete m_equator;
+ removeChildNode(m_ecliptic);
+ delete m_ecliptic;
+
+ removeChildNode(m_planetsItem);
+ delete m_planetsItem;
+ removeChildNode(m_asteroidsItem);
+ delete m_asteroidsItem;
+ removeChildNode(m_cometsItem);
+ delete m_cometsItem;
+
+ removeChildNode(m_constelNamesItem);
+ delete m_constelNamesItem;
+
+ removeChildNode(m_horizonItem);
+ delete m_horizonItem;*/
+}
+
+RootNode::~RootNode() {
+ for(int i = 0; i < m_textureCache.length(); ++i) {
+ for(int c = 0; c < m_textureCache[i].size(); ++c) {
+ delete m_textureCache[i][c];
+ }
+ }
+}
+
void RootNode::genCachedTextures() {
QVector<QVector<QPixmap*>> images = m_skyMapLite->getImageCache();
@@ -116,6 +178,7 @@ void RootNode::updateClipPoly() {
size);
m_clipGeometry->setDrawingMode(GL_TRIANGLES);
setGeometry(m_clipGeometry);
+ setFlag(QSGNode::OwnsGeometry);
} else {
m_clipGeometry->allocate(size);
}
@@ -156,6 +219,7 @@ void RootNode::update() {
m_constelNamesItem->update();
m_starItem->update();
+ m_dsoItem->update();
m_equator->update();
m_ecliptic->update();
diff --git a/kstars/kstarslite/skyitems/rootnode.h b/kstars/kstarslite/skyitems/rootnode.h
index 1193b58..296ff46 100644
--- a/kstars/kstarslite/skyitems/rootnode.h
+++ b/kstars/kstarslite/skyitems/rootnode.h
@@ -22,6 +22,7 @@ class QSGTexture;
class SkyMapLite;
class StarItem;
+class DeepSkyItem;
class PlanetsItem;
class AsteroidsItem;
@@ -51,6 +52,7 @@ class SolarSystemComposite;
class RootNode : public QSGClipNode {
public:
RootNode();
+ virtual ~RootNode();
/**
* @short returns cached texture from textureCache
* @param size size of the star
@@ -69,6 +71,10 @@ public:
*/
void update();
+ //Debug
+ void testLeakDelete();
+ void testLeakAdd();
+
inline CometsItem *cometsItem() { return m_cometsItem; }
inline LabelsItem *labelsItem() { return m_labelsItem; }
@@ -87,6 +93,7 @@ private:
QSGGeometry *m_clipGeometry;
StarItem *m_starItem;
+ DeepSkyItem *m_dsoItem;
PlanetsItem *m_planetsItem;
AsteroidsItem *m_asteroidsItem;
diff --git a/kstars/kstarslite/skyitems/skyitem.cpp b/kstars/kstarslite/skyitems/skyitem.cpp
index f45af1e..7d5282a 100644
--- a/kstars/kstarslite/skyitems/skyitem.cpp
+++ b/kstars/kstarslite/skyitems/skyitem.cpp
@@ -26,7 +26,18 @@ SkyItem::~SkyItem() {
rootNode()->labelsItem()->deleteLabels(m_labelType);
}
+void SkyItem::show() {
+ SkyOpacityNode::show();
+ if(labelType() != LabelsItem::label_t::NO_LABEL) {
+ rootNode()->labelsItem()->getLabelNode(m_labelType)->show();
+ }
+}
+
+void SkyItem::hideLabels() {
+ rootNode()->labelsItem()->getLabelNode(m_labelType)->hide();
+}
+
void SkyItem::hide() {
SkyOpacityNode::hide();
- rootNode()->labelsItem()->hideLabels(labelType());
+ rootNode()->labelsItem()->hideLabels(m_labelType);
}
diff --git a/kstars/kstarslite/skyitems/skyitem.h b/kstars/kstarslite/skyitems/skyitem.h
index 1e60d60..acf5b34 100644
--- a/kstars/kstarslite/skyitems/skyitem.h
+++ b/kstars/kstarslite/skyitems/skyitem.h
@@ -58,10 +58,14 @@ public:
virtual void update() =0;
+ virtual void show() override;
+
/**
* @short hides this item and corresponding labels
*/
- void hide();
+ virtual void hide() override;
+
+ void hideLabels();
/**
* @return RootNode that is the parent of this SkyItem in a node tree
diff --git a/kstars/kstarslite/skyitems/skynodes/deepskynode.cpp b/kstars/kstarslite/skyitems/skynodes/deepskynode.cpp
new file mode 100644
index 0000000..6d3e529
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/deepskynode.cpp
@@ -0,0 +1,108 @@
+/** *************************************************************************
+ deepskynode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 20/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "skyobject.h"
+#include "Options.h"
+
+#include <QSGSimpleTextureNode>
+#include <QQuickWindow>
+
+#include "deepskynode.h"
+#include "nodes/pointnode.h"
+#include "dsosymbolnode.h"
+
+#include "../rootnode.h"
+#include "../labelsitem.h"
+#include "labelnode.h"
+
+DeepSkyNode::DeepSkyNode(DeepSkyObject * skyObject, DSOSymbolNode *symbol)
+ :m_dso(skyObject),m_objImg(0), m_symbol(symbol)//, m_label(0), m_labelType(labelType), m_rootNode(parentNode), m_trixel(trixel)
+{
+
+}
+
+void DeepSkyNode::changePos(QPointF pos) {
+ QSizeF size = m_objImg->rect().size();
+ QMatrix4x4 m (1,0,0,pos.x(),
+ 0,1,0,pos.y(),
+ 0,0,1,0,
+ 0,0,0,1);
+ //FIXME: this is probably incorrect (inherited from drawDeepSkyImage())
+ m.rotate(m_angle, 0, 0, 1);
+ m.translate(-0.5*size.width(), -0.5*size.height());
+
+ setMatrix(m);
+ markDirty(QSGNode::DirtyMatrix);
+}
+
+void DeepSkyNode::update(bool drawImage) {
+ 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;
+ }
+ show();
+
+ // if size is 0.0 set it to 1.0, this are normally stars (type 0 and 1)
+ // if we use size 0.0 the star wouldn't be drawn
+ float majorAxis = m_dso->a();
+ if ( majorAxis == 0.0 ) { majorAxis = 1.0; }
+
+ 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;
+
+ m_angle = projector()->findPA( m_dso, pos.x(), pos.y() );
+
+ if(drawImage && Options::zoomFactor() > 5.*MINZOOM) {
+ if(!(m_dso->image().isNull())) {
+ if(!m_objImg) {
+ m_objImg = new QSGSimpleTextureNode;
+ m_objImg->setTexture(SkyMapLite::Instance()->window()->createTextureFromImage(
+ m_dso->image(),QQuickWindow::TextureCanUseAtlas));
+ m_objImg->setOwnsTexture(true);
+ m_opacity->appendChildNode(m_objImg);
+ }
+
+ m_objImg->setRect(0,0,w,h);
+ changePos(pos);
+ }
+ } else {
+ hide();
+ }
+ m_symbol->update(size, pos, m_angle);
+ //Draw Symbol
+ //drawDeepSkySymbol(pos, obj->type(), size, obj->e(), positionAngle);
+}
+
+void DeepSkyNode::hide() {
+ //if(m_label) m_label->hide();
+ SkyNode::hide();
+ m_symbol->hide();
+ //m_point->hide();
+}
diff --git a/kstars/kstarslite/skyitems/skynodes/deepskynode.h b/kstars/kstarslite/skyitems/skynodes/deepskynode.h
new file mode 100644
index 0000000..18033ac
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/deepskynode.h
@@ -0,0 +1,75 @@
+/** *************************************************************************
+ deepskynode.h - K Desktop Planetarium
+ -------------------
+ begin : 20/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 DEEPSKYNODE_H_
+#define DEEPSKYNODE_H_
+#include "skynode.h"
+#include "../labelsitem.h"
+
+class PlanetItemNode;
+class SkyMapLite;
+class PointNode;
+class LabelNode;
+class QSGSimpleTextureNode;
+class DSOSymbolNode;
+
+/** @class DeepSkyNode
+ *
+ * A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject.
+ *
+ *@short A SkyNode derived class that represents stars and objects that are drawn as stars
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class RootNode;
+
+class DeepSkyNode : public SkyNode {
+public:
+ /**
+ * @short Constructor
+ * @param skyObject pointer to SkyObject that has to be displayed on SkyMapLite
+ * @param parentNode pointer to the top parent node, which holds texture cache
+ * @param spType spectral class of PointNode
+ * @param size initial size of PointNode
+ */
+ DeepSkyNode(DeepSkyObject *skyObject, DSOSymbolNode *symbol);
+
+ /**
+ * @short changePos changes the position m_point
+ * @param pos new position
+ */
+ void changePos(QPointF pos);
+
+ void update(bool drawImage);
+ virtual void hide() override;
+
+ DeepSkyObject *dsObject() { return m_dso; }
+private:
+ //RootNode *m_rootNode;
+ QSGSimpleTextureNode *m_objImg;
+
+ LabelNode *m_label;
+ LabelsItem::label_t m_labelType;
+ DeepSkyObject *m_dso;
+ DSOSymbolNode *m_symbol;
+ float m_angle;
+
+ short m_trixel; //Trixel to which this object belongs. Used only in stars. By default -1 for all
+ QPointF pos;
+};
+
+#endif
+
diff --git a/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp b/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp
new file mode 100644
index 0000000..275e7bb
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.cpp
@@ -0,0 +1,414 @@
+/** *************************************************************************
+ dsosymbolnode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 20/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "skyobject.h"
+#include "Options.h"
+
+#include <QSGFlatColorMaterial>
+
+#include "dsosymbolnode.h"
+#include "nodes/ellipsenode.h"
+
+#include "../rootnode.h"
+#include "../labelsitem.h"
+#include "labelnode.h"
+
+void SymbolNode::updateSymbol(float x, float y, float e, float size) {
+ zoom = Options::zoomFactor();
+ x = 0;
+ y = 0;
+ isize = int(size);
+
+ dx1 = -0.5*size;
+ dx2 = 0.5*size;
+ dy1 = -1.0*e*size/2.;
+ dy2 = e*size/2.;
+ x1 = x + dx1;
+ x2 = x + dx2;
+ y1 = y + dy1;
+ y2 = y + dy2;
+
+ dxa = -size/4.;
+ dxb = size/4.;
+ dya = -1.0*e*size/4.;
+ dyb = e*size/4.;
+ xa = x + dxa;
+ xb = x + dxb;
+ ya = y + dya;
+ yb = y + dyb;
+}
+
+StarSymbol::StarSymbol()
+ :m_ellipse(new EllipseNode(QColor("#006666")))
+{
+ appendChildNode(m_ellipse);
+}
+
+void StarSymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+ if (size<2.) size = 2.;
+ if ( Options::useAntialias() )
+ m_ellipse->updateGeometry(0, 0, size, e*size, false);
+ else
+ m_ellipse->updateGeometry(0, 0, int(size/2), int(size/2), false);
+}
+
+AsterismSymbol::AsterismSymbol() {
+ e1 = new EllipseNode(QColor("#008f00"));
+ e2 = new EllipseNode(QColor("#008f00"));
+ e3 = new EllipseNode(QColor("#008f00"));
+ e4 = new EllipseNode(QColor("#008f00"));
+ e5 = new EllipseNode(QColor("#008f00"));
+ e6 = new EllipseNode(QColor("#008f00"));
+ e7 = new EllipseNode(QColor("#008f00"));
+ e8 = new EllipseNode(QColor("#008f00"));
+ appendChildNode(e1);
+ appendChildNode(e2);
+ appendChildNode(e3);
+ appendChildNode(e4);
+ appendChildNode(e5);
+ appendChildNode(e6);
+ appendChildNode(e7);
+ appendChildNode(e8);
+}
+
+void AsterismSymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+ psize = 2.;
+ if ( size > 50. ) psize *= 2.;
+ if ( size > 100. ) psize *= 2.;
+
+ e1->updateGeometry(xa, y1, psize, psize, true);
+ e2->updateGeometry(xb, y1, psize, psize, true);
+ e3->updateGeometry(xa, y2, psize, psize, true);
+ e4->updateGeometry(xb, y2, psize, psize, true);
+ e5->updateGeometry(x1, ya, psize, psize, true);
+ e6->updateGeometry(x1, yb, psize, psize, true);
+ e7->updateGeometry(x2, ya, psize, psize, true);
+ e8->updateGeometry(x2, yb, psize, psize, true);
+}
+
+GlobularClusterSymbol::GlobularClusterSymbol()
+ :e1(new EllipseNode(QColor("#008f00")))
+{
+ appendChildNode(e1);
+
+ lines = new QSGGeometryNode;
+ appendChildNode(lines);
+
+ QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(),0);
+ geometry->setDrawingMode(GL_LINES);
+ geometry->allocate(4);
+
+ lines->setGeometry(geometry);
+ lines->setFlag(QSGNode::OwnsGeometry);
+
+ QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
+ material->setColor(QColor("#008f00"));
+ lines->setOpaqueMaterial(material);
+ lines->setFlag(QSGNode::OwnsMaterial);
+}
+
+void GlobularClusterSymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+
+ if (size<2.) size = 2.;
+ e1->updateGeometry(0, 0, size, e*size, false);
+
+ QSGGeometry::Point2D * vertex = lines->geometry()->vertexDataAsPoint2D();
+ //First line
+ vertex[0].set(dx1, 0);
+ vertex[1].set(dx2, 0);
+
+ //Second line
+ vertex[2].set(0, dy1);
+ vertex[3].set(0, dy2);
+
+ lines->markDirty(QSGNode::DirtyGeometry);
+}
+
+DarkNebulaSymbol::DarkNebulaSymbol() {
+ lines = new QSGGeometryNode;
+ appendChildNode(lines);
+
+ QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(),0);
+ geometry->setDrawingMode(GL_LINES);
+ geometry->allocate(8);
+
+ lines->setGeometry(geometry);
+ lines->setFlag(QSGNode::OwnsGeometry);
+
+ QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
+ material->setColor("#006666");
+ lines->setOpaqueMaterial(material);
+ lines->setFlag(QSGNode::OwnsMaterial);
+}
+
+void DarkNebulaSymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+
+ if (size<2.) size = 2.;
+
+ QSGGeometry::Point2D * vertex = lines->geometry()->vertexDataAsPoint2D();
+ //First line
+ vertex[0].set(dx1, dy1);
+ vertex[1].set(dx2, dy1);
+
+ //Second line
+ vertex[2].set(dx2, dy1);
+ vertex[3].set(dx2, dy2);
+
+ //Third line
+ vertex[4].set(dx2, dy2);
+ vertex[5].set(dx1, dy2);
+
+ //Fourth line
+ vertex[6].set(dx1, dy2);
+ vertex[7].set(dx1, dy1);
+
+ lines->markDirty(QSGNode::DirtyGeometry);
+}
+
+PlanetaryNebulaSymbol::PlanetaryNebulaSymbol() {
+ e1 = new EllipseNode;
+ appendChildNode(e1);
+
+ lines = new QSGGeometryNode;
+ appendChildNode(lines);
+
+ QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(),0);
+ geometry->setDrawingMode(GL_LINES);
+ geometry->allocate(8);
+
+ lines->setGeometry(geometry);
+ lines->setFlag(QSGNode::OwnsGeometry);
+
+ QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
+ material->setColor(QColor("#006666"));
+ lines->setOpaqueMaterial(material);
+ lines->setFlag(QSGNode::OwnsMaterial);
+}
+
+void PlanetaryNebulaSymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+
+ if (size<2.) size = 2.;
+
+ 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
+ vertex[0].set(0., dy1);
+ vertex[1].set(0., dy1 - e*size/2. );
+
+ //Second line
+ vertex[2].set(0., dy2);
+ vertex[3].set(0., dy2 + e*size/2.);
+
+ //Third line
+ vertex[4].set(dx1, 0.);
+ vertex[5].set(dx1 - size/2., 0.);
+
+ //Fourth line
+ vertex[6].set(dx2, 0.);
+ vertex[7].set(dx2 + size/2., 0.);
+
+ lines->markDirty(QSGNode::DirtyGeometry);
+}
+
+SupernovaRemnantSymbol::SupernovaRemnantSymbol() {
+ lines = new QSGGeometryNode;
+ appendChildNode(lines);
+
+ QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(),0);
+ geometry->setDrawingMode(GL_LINES);
+ geometry->allocate(8);
+
+ lines->setGeometry(geometry);
+ lines->setFlag(QSGNode::OwnsGeometry);
+
+ QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
+ material->setColor(QColor("#006666"));
+ lines->setOpaqueMaterial(material);
+ lines->setFlag(QSGNode::OwnsMaterial);
+}
+
+void SupernovaRemnantSymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+
+ if (size<2.) size = 2.;
+ /*drawLine( QPointF(0., dy1), QPointF(dx2, 0.) );
+ drawLine( QPointF(dx2, 0.), QPointF(0., dy2) );
+ drawLine( QPointF(0., dy2), QPointF(dx1, 0.) );
+ drawLine( QPointF(dx1, 0.), QPointF(0., dy1) );*/
+
+ QSGGeometry::Point2D * vertex = lines->geometry()->vertexDataAsPoint2D();
+ //First line
+ vertex[0].set(0., dy1);
+ vertex[1].set(dx2, 0. );
+
+ //Second line
+ vertex[2].set(dx2, 0.);
+ vertex[3].set(0., dy2);
+
+ //Third line
+ vertex[4].set(0., dy2);
+ vertex[5].set(dx1, 0.);
+
+ //Fourth line
+ vertex[6].set(dx1, 0.);
+ vertex[7].set(0., dy1);
+
+ lines->markDirty(QSGNode::DirtyGeometry);
+}
+
+GalaxySymbol::GalaxySymbol()
+ :e1(new EllipseNode(QColor("#006666")))
+{
+ appendChildNode(e1);
+}
+
+void GalaxySymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+
+ if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force ellipse above zoomFactor 20
+ if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force points above zoomFactor 5
+ if ( size>2. ) {
+ e1->updateGeometry(0,0,size,e*size,false);
+ } else if ( size>0. ) {
+ e1->updateGeometry(0,0,1,1,false);
+ }
+}
+
+GalaxyClusterSymbol::GalaxyClusterSymbol()
+ :lines(new QSGGeometryNode)
+{
+ QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(),0);
+ geometry->setDrawingMode(GL_LINES);
+ geometry->allocate(32);
+
+ lines->setGeometry(geometry);
+ lines->setFlag(QSGNode::OwnsGeometry);
+
+ QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
+ material->setColor(QColor("#006666"));
+ lines->setOpaqueMaterial(material);
+ lines->setFlag(QSGNode::OwnsMaterial);
+
+ appendChildNode(lines);
+}
+
+void GalaxyClusterSymbol::updateSymbol(float x, float y, float e, float size) {
+ SymbolNode::updateSymbol(x, y, e, size);
+
+ psize = 1.;
+ if ( size > 50. ) psize *= 2.;
+
+ QSGGeometry::Point2D * vertex = lines->geometry()->vertexDataAsPoint2D();
+
+ vertex[0].set(xa - psize, y1);vertex[1].set(xa + psize, y1 );
+ vertex[2].set(xa, y1 - psize);vertex[3].set(xa, y1 + psize);
+ vertex[4].set(xb - psize, y1);vertex[5].set(xb + psize, y1);
+ vertex[6].set(xb, y1 - psize);vertex[7].set(xb, y1 + psize);
+ vertex[8].set(xa - psize, y2);vertex[9].set(xa + psize, y2 );
+ vertex[10].set(xa, y2 - psize);vertex[11].set(xa, y2 + psize);
+ vertex[12].set(xb - psize, y2);vertex[13].set(xb + psize, y2);
+ vertex[14].set(xb, y2 - psize);vertex[15].set(xb, y2 + psize);
+ vertex[16].set(x1 - psize, ya);vertex[17].set(x1 + psize, ya);
+ vertex[18].set(x1, ya - psize);vertex[19].set(x1, ya + psize);
+ vertex[20].set(x1 - psize, yb);vertex[21].set(x1 + psize, yb);
+ vertex[22].set(x1, yb - psize);vertex[23].set(x1, yb + psize);
+ vertex[24].set(x2 - psize, ya);vertex[25].set(x2 + psize, ya);
+ vertex[26].set(x2, ya - psize);vertex[27].set(x2, ya + psize);
+ vertex[28].set(x2 - psize, yb);vertex[29].set(x2 + psize, yb);
+ vertex[30].set(x2, yb - psize);vertex[31].set(x2, yb + psize);
+
+ lines->markDirty(QSGNode::DirtyGeometry);
+
+}
+
+DSOSymbolNode::DSOSymbolNode(DeepSkyObject * skyObject)
+ :m_dso(skyObject), m_symbol(0), m_rotate(false) //We don't rotate the symbol by default
+{
+ int type = m_dso->type();
+ switch ( type ) {
+ case 0:
+ case 1:
+ //catalog star
+ m_symbol = new StarSymbol();
+ break;
+ case 3: //Open cluster; draw circle of points
+ case 13: // Asterism
+ m_symbol = new AsterismSymbol();
+ break;
+ case 4: //Globular Cluster
+ m_symbol = new GlobularClusterSymbol();
+ m_rotate = true;
+ break;
+ case 5: //Gaseous Nebula
+ case 15: // Dark Nebula
+ m_symbol = new DarkNebulaSymbol();
+ m_rotate = true;
+ break;
+ case 6: //Planetary Nebula
+ m_symbol = new PlanetaryNebulaSymbol();
+ m_rotate = true;
+ break;
+ case 7: //Supernova remnant
+ m_symbol = new SupernovaRemnantSymbol();
+ m_rotate = true;
+ break;
+ case 8: //Galaxy
+ case 16: // Quasar
+ m_symbol = new GalaxySymbol();
+ m_rotate = true;
+ break;
+ case 14: // Galaxy cluster - draw a circle of + marks
+ m_symbol = new GalaxyClusterSymbol();
+ m_rotate = true;
+ break;
+ default:
+ break;
+ }
+ if(m_symbol) addChildNode(m_symbol);
+}
+
+void DSOSymbolNode::changePos(float size, const QPointF &pos, float positionangle) {
+ QMatrix4x4 m (1,0,0,pos.x(),
+ 0,1,0,pos.y(),
+ 0,0,1,0,
+ 0,0,0,1);
+ //FIXME: this is probably incorrect (inherited from drawDeepSkyImage())
+ if(m_rotate) {
+ m.rotate(positionangle, 0, 0, 1);
+ }
+ //m.translate(-0.5*size, -0.5*size);
+
+ setMatrix(m);
+ markDirty(QSGNode::DirtyMatrix);
+}
+
+void DSOSymbolNode::update(float size, const QPointF &pos, float positionangle) {
+ show();
+ if(m_symbol) {
+ m_symbol->updateSymbol(pos.x(), pos.y(), m_dso->e(), size);
+ }
+ changePos(size, pos, positionangle);
+}
diff --git a/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.h b/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.h
new file mode 100644
index 0000000..6bba9a6
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/dsosymbolnode.h
@@ -0,0 +1,160 @@
+/** *************************************************************************
+ dsosymbolnode.h - K Desktop Planetarium
+ -------------------
+ begin : 20/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 DSOSYMBOLNODE_H_
+#define DSOSYMBOLNODE_H_
+#include "skynode.h"
+#include "../labelsitem.h"
+
+class PlanetItemNode;
+class SkyMapLite;
+class PointNode;
+class LabelNode;
+class QSGSimpleTextureNode;
+class EllipseNode;
+class LineNode;
+
+/** @class DSOSymbolNode
+ *
+ * A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject.
+ *
+ *@short A SkyNode derived class that represents stars and objects that are drawn as stars
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class RootNode;
+
+class SymbolNode : public QSGNode {
+public:
+ virtual void updateSymbol(float x, float y, float e, float size);
+protected:
+ SymbolNode() { }
+ float zoom;
+ int isize;
+
+ float dx1;
+ float dx2;
+ float dy1;
+ float dy2;
+ float x1;
+ float x2;
+ float y1;
+ float y2;
+
+ float dxa;
+ float dxb;
+ float dya;
+ float dyb;
+ float xa;
+ float xb;
+ float ya;
+ float yb;
+ float psize;
+};
+
+class StarSymbol : public SymbolNode {
+public:
+ StarSymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+ EllipseNode *m_ellipse;
+};
+
+class AsterismSymbol : public SymbolNode {
+public:
+ AsterismSymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+
+ EllipseNode *e1;
+ EllipseNode *e2;
+ EllipseNode *e3;
+ EllipseNode *e4;
+ EllipseNode *e5;
+ EllipseNode *e6;
+ EllipseNode *e7;
+ EllipseNode *e8;
+};
+
+class GlobularClusterSymbol : public SymbolNode {
+public:
+ GlobularClusterSymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+
+ EllipseNode *e1;
+ QSGGeometryNode *lines;
+};
+
+class DarkNebulaSymbol : public SymbolNode {
+public:
+ DarkNebulaSymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+
+ QSGGeometryNode *lines;
+};
+
+class PlanetaryNebulaSymbol : public SymbolNode {
+public:
+ PlanetaryNebulaSymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+
+ EllipseNode *e1;
+ QSGGeometryNode *lines;
+};
+
+class SupernovaRemnantSymbol : public SymbolNode {
+public:
+ SupernovaRemnantSymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+
+ QSGGeometryNode *lines;
+};
+
+class GalaxySymbol : public SymbolNode {
+public:
+ GalaxySymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+
+ EllipseNode *e1;
+};
+
+class GalaxyClusterSymbol : public SymbolNode {
+public:
+ GalaxyClusterSymbol();
+ virtual void updateSymbol(float x, float y, float e, float size) override;
+
+ QSGGeometryNode *lines;
+};
+
+class DSOSymbolNode : public SkyNode {
+public:
+ /**
+ * @short Constructor
+ * @param skyObject pointer to SkyObject that has to be displayed on SkyMapLite
+ * @param parentNode pointer to the top parent node, which holds texture cache
+ * @param spType spectral class of PointNode
+ * @param size initial size of PointNode
+ */
+ DSOSymbolNode(DeepSkyObject *skyObject);
+ void changePos(float size, const QPointF &pos, float positionangle);
+ void update(float size, const QPointF &pos, float positionangle);
+private:
+ //TODO deal setter for this when stars will be introduced
+ DeepSkyObject *m_dso;
+ SymbolNode *m_symbol;
+ bool m_rotate; //If the symbol needs rotation this should be set to true
+};
+
+#endif
+
diff --git a/kstars/kstarslite/skyitems/skynodes/labelnode.cpp b/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
index d3f0494..a7f4a18 100644
--- a/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
@@ -35,6 +35,12 @@ LabelNode::LabelNode(QString name, LabelsItem::label_t type)
initialize();
}
+LabelNode::~LabelNode() {
+ m_opacity->removeChildNode(m_textTexture);
+ m_textTexture->setOwnsTexture(true);
+ delete m_textTexture;
+}
+
void LabelNode::initialize() {
switch(m_labelType) {
case LabelsItem::label_t::PLANET_LABEL:
@@ -89,6 +95,7 @@ void LabelNode::createTexture() {
QSGTexture *oldTexture = m_textTexture->texture();
m_textTexture->setTexture(SkyMapLite::Instance()->textToTexture(m_name, color, m_zoomFont));
+
if(m_zoomFont) m_fontSize = SkyLabeler::Instance()->drawFont().pointSize();
switch(m_labelType) {
diff --git a/kstars/kstarslite/skyitems/skynodes/labelnode.h b/kstars/kstarslite/skyitems/skynodes/labelnode.h
index 5f55c33..a9a7d67 100644
--- a/kstars/kstarslite/skyitems/skynodes/labelnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/labelnode.h
@@ -50,6 +50,8 @@ public:
/** does the same as above function but with QString instead of skyObject **/
LabelNode(QString name, LabelsItem::label_t type);
+ virtual ~LabelNode();
+
void initialize();
/**
@@ -67,6 +69,8 @@ public:
inline QString name() { return m_name; }
+ inline LabelsItem::label_t labelType() { return m_labelType; }
+
void createTexture();
/**
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
new file mode 100644
index 0000000..0160517
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
@@ -0,0 +1,86 @@
+/** *************************************************************************
+ polynode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 28/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <QSGGeometryNode>
+#include <QSGGeometry>
+#include <QSGFlatColorMaterial>
+#include <QPolygon>
+
+#include "ellipsenode.h"
+//#include <stdio.h>
+//#include <stdlib.h>
+
+extern "C"
+{
+#include "libtess/tessellate.h"
+}
+
+EllipseNode::EllipseNode(QColor color, int width)
+ :m_geometryNode(new QSGGeometryNode), m_geometry(0),
+ m_material(new QSGFlatColorMaterial), m_fillMode(false)
+{
+ m_geometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0);
+ m_geometry->allocate(360);
+ m_geometryNode->setGeometry(m_geometry);
+ m_geometryNode->setFlag(QSGNode::OwnsGeometry);
+
+ m_geometryNode->setOpaqueMaterial(m_material);
+ m_geometryNode->setFlag(QSGNode::OwnsMaterial);
+
+ if(color.isValid()) {
+ setColor(color);
+ }
+ setLineWidth(width);
+
+ appendChildNode(m_geometryNode);
+}
+
+void EllipseNode::setColor(QColor color) {
+ if(color != m_material->color()) {
+ m_material->setColor(color);
+ m_geometryNode->markDirty(QSGNode::DirtyMaterial);
+ }
+}
+
+void EllipseNode::setLineWidth(int width) {
+ if(width != m_geometry->lineWidth()) {
+ m_geometry->setLineWidth(width);
+ m_geometryNode->markDirty(QSGNode::DirtyGeometry);
+ }
+}
+
+void EllipseNode::updateGeometry(float x, float y, int width, int height, bool filled) {
+ if(filled) {
+ m_geometry->setDrawingMode(GL_POLYGON);
+ } else {
+ m_geometry->setDrawingMode(GL_LINE_LOOP);
+ }
+
+ QSGGeometry::Point2D * vertex = m_geometry->vertexDataAsPoint2D();
+
+ for (int i=0; i < 360; ++i) {
+ vertex[i].x = x + width*cos(i*(M_PI/180));
+ vertex[i].y = y + height*sin(i*(M_PI/180));
+ }
+ /*vertex[0].x = 0;
+ vertex[0].y = 0;
+
+ vertex[1].x = 50;
+ vertex[1].x = 50;*/
+
+ m_geometryNode->markDirty(QSGNode::DirtyGeometry);
+
+}
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h
new file mode 100644
index 0000000..fcdeab0
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h
@@ -0,0 +1,52 @@
+/** *************************************************************************
+ polynode.h - K Desktop Planetarium
+ -------------------
+ begin : 28/05/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef ELLIPSENODE_H_
+#define ELLIPSENODE_H_
+//#include "../../skyopacitynode.h"
+#include <QSGNode>
+
+/** @class PolyNode
+ *
+ * A QSGOpacityNode derived class used for representing stars and planets as stars. Upon
+ * construction loads the texture of star cached in parentNode
+ *
+ *@short QSGOpacityNode derived class that represents stars and planets using cached QSGTexture
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class QSGGeometryNode;
+class QSGGeometry;
+class QSGFlatColorMaterial;
+
+class EllipseNode : public QSGNode {
+public:
+ EllipseNode(QColor color = QColor(), int width = 0);
+
+ void setColor(QColor color);
+ void setLineWidth(int width);
+ void setFillMode(bool fillMode) { m_fillMode = fillMode; }
+
+ void updateGeometry(float x, float y, int width, int height, bool filled);
+private:
+ QSGGeometryNode *m_geometryNode;
+ QSGGeometry *m_geometry;
+ QSGFlatColorMaterial *m_material;
+ bool m_fillMode;
+};
+
+#endif
+
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
index a56a0e4..ff7e4c3 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
@@ -22,23 +22,24 @@
#include <QLinkedList>
LineNode::LineNode(LineList *lineList, QColor color, int width, Qt::PenStyle drawStyle)
- :m_lineList(lineList), m_geometryNode(new QSGGeometryNode), m_color(color), m_drawStyle(drawStyle)
-
+ :m_lineList(lineList), m_geometryNode(new QSGGeometryNode), m_color(color), m_drawStyle(drawStyle),
+ m_material(new QSGFlatColorMaterial)
{
- m_material = new QSGFlatColorMaterial;
- static_cast<QSGFlatColorMaterial *>(m_material)->setColor(color);
- markDirty(QSGNode::DirtyMaterial);
-
- m_geometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0);
m_geometryNode->setOpaqueMaterial(m_material);
+ //m_geometryNode->setFlag(QSGNode::OwnsMaterial);
+ m_material->setColor(color);
+ m_geometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0);
+ m_geometryNode->setGeometry(m_geometry);
+ //m_geometryNode->setFlag(QSGNode::OwnsGeometry);
setWidth(width);
appendChildNode(m_geometryNode);
- m_geometryNode->setGeometry(m_geometry);
+}
- setFlag(QSGNode::OwnsGeometry);
- setFlag(QSGNode::OwnsMaterial);
+LineNode::~LineNode() {
+ delete m_geometry;
+ delete m_material;
}
void LineNode::setColor(QColor color) {
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
index 0391330..d286f71 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
@@ -42,6 +42,7 @@ public:
* @param size initial size of LineNode
*/
LineNode(LineList *lineList, QColor color, int width, Qt::PenStyle drawStyle);
+ virtual ~LineNode();
/**
* @short setSize update size of LineNode with the given parameter
* @param size new size of LineNode
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
index 03a6d9a..f58b2a0 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
@@ -19,9 +19,10 @@
#include "pointnode.h"
#include "kstarslite/skyitems/rootnode.h"
+#include <QSGTexture>
PointNode::PointNode(RootNode* p, char sp, float size)
- :spType(sp), texture(new QSGSimpleTextureNode), m_rootNode(p)
+ :spType(sp), texture(new QSGSimpleTextureNode), m_rootNode(p), m_size(-1) //Important to init to -1
{
appendChildNode(texture);
setSize(size);
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
index 5999126..3dcc8e8 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
@@ -42,6 +42,7 @@ public:
* @param size initial size of PointNode
*/
PointNode(RootNode* rootNode, char spType = 'A', float size = 1);
+
/**
* @short setSize update size of PointNode with the given parameter
* @param size new size of PointNode
@@ -51,9 +52,11 @@ public:
inline QSizeF size() const { return texture->rect().size(); }
private:
char spType;
+
QSGSimpleTextureNode *texture;
//parentNode holds texture cache
RootNode* m_rootNode;
+
float m_size;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
index 5176bdc..fae6b9f 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
@@ -56,7 +56,7 @@ void PolyNode::setLineWidth(int width) {
}
}
-void PolyNode::updateGeometry(QPolygonF polygon, bool filled) {
+void PolyNode::updateGeometry(const QPolygonF &polygon, bool filled) {
if(!filled) {
m_geometry->setDrawingMode(GL_LINE_STRIP);
int size = polygon.size();
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
index 6c1dcd3..9cdd747 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
@@ -38,7 +38,7 @@ public:
void setColor(QColor color);
void setLineWidth(int width);
- void updateGeometry(QPolygonF polygon, bool filled);
+ void updateGeometry(const QPolygonF &polygon, bool filled);
private:
QSGGeometryNode *m_geometryNode;
QSGGeometry *m_geometry;
diff --git a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp
index 66e52c6..8b92b5d 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp
@@ -7,17 +7,27 @@
#include "ksplanetbase.h"
#include "skylabeler.h"
+#include "../rootnode.h";
+#include "../labelsitem.h";
+
#include "Options.h"
PlanetMoonsNode::PlanetMoonsNode(KSPlanetBase* planet, RootNode* parentNode)
:SkyNode(planet), m_rootNode(parentNode), pmoons(0),
- m_planetNode(new PlanetNode(planet, parentNode))
-{
+ m_planetNode(new PlanetNode(planet, parentNode)), m_labelType(LabelsItem::label_t::NO_LABEL)
+ //For now we consider labels only in case of Jupiter
+{
appendChildNode(m_planetNode);
}
+PlanetMoonsNode::~PlanetMoonsNode() {
+ if(m_labelType != LabelsItem::label_t::NO_LABEL) {
+ m_rootNode->labelsItem()->deleteLabels(m_labelType);
+ }
+}
+
void PlanetMoonsNode::update() {
- if(pmoons) updateMoons();
+ updateMoons();
m_planetNode->update();
}
@@ -34,38 +44,42 @@ void PlanetMoonsNode::updateMoons() {
//In order to get the z-order right for the moons and the planet,
//we need to first append the planet (both m_point and m_planetPic) then append all nodes for moons
//that are nearer than the planet and then prepend nodes for moons that are further than the planet
- int nmoons = pmoons->nMoons();
+ if(pmoons) {
+ int nmoons = pmoons->nMoons();
+ if(m_labelType == LabelsItem::label_t::NO_LABEL) {
+ m_labelType = LabelsItem::label_t::JUPITER_MOON_LABEL;
+ }
- if(!m_moonNodes.length()) { //Initialize PointSourceNodes used for drawing moons
- for ( int i=0; i<nmoons; ++i ) {
- m_moonNodes.append(new PointSourceNode(pmoons->moon(i), m_rootNode,LabelsItem::label_t::JUPITER_MOON_LABEL));
+ if(!m_moonNodes.length()) { //Initialize PointSourceNodes used for drawing moons
+ for ( int i=0; i<nmoons; ++i ) {
+ m_moonNodes.append(new PointSourceNode(pmoons->moon(i), m_rootNode,m_labelType));
+ }
}
- }
- removeAllChildNodes(); // Clear all child nodes so that we can render moons according to z-order
+ removeAllChildNodes(); // Clear all child nodes so that we can render moons according to z-order
- // We need to reappend node that draws the planet
- appendChildNode(m_planetNode);
+ // We need to reappend node that draws the planet
+ appendChildNode(m_planetNode);
- bool drawLabel = true;
+ bool drawLabel = true;
- if ( ! (Options::showPlanetNames() && Options::zoomFactor() > 50.*MINZOOM) ) {
- drawLabel = false;
- }
+ if ( ! (Options::showPlanetNames() && Options::zoomFactor() > 50.*MINZOOM) ) {
+ drawLabel = false;
+ }
- for ( int i=0; i<nmoons; ++i ) {
- if ( pmoons->z(i) < 0.0 ) { //Moon is nearer than the planet
- appendChildNode(m_moonNodes[i]);
- m_moonNodes[i]->update(drawLabel);
- } else {
- //Draw Moons that are further than the planet
- //skyp->drawPointSource( pmoons->moon(i), pmoons->moon(i)->mag() );
- prependChildNode(m_moonNodes[i]);
- m_moonNodes[i]->update(drawLabel);
+ for ( int i=0; i<nmoons; ++i ) {
+ if ( pmoons->z(i) < 0.0 ) { //Moon is nearer than the planet
+ appendChildNode(m_moonNodes[i]);
+ m_moonNodes[i]->update(drawLabel);
+ } else {
+ //Draw Moons that are further than the planet
+ //skyp->drawPointSource( pmoons->moon(i), pmoons->moon(i)->mag() );
+ prependChildNode(m_moonNodes[i]);
+ m_moonNodes[i]->update(drawLabel);
+ }
}
- }
-/* //Draw Moon name labels if at high zoom
+ /* //Draw Moon name labels if at high zoom
return;
for ( int i=0; i<nmoons; ++i ) {
/*
@@ -75,4 +89,5 @@ void PlanetMoonsNode::updateMoons() {
SkyLabeler::AddLabel( pmoons->moon(i), SkyLabeler::JUPITER_MOON_LABEL );
}*/
+ }
}
diff --git a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h
index 4e664af..762e334 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h
@@ -16,6 +16,7 @@
#ifndef PLANETMOONSNODE_H_
#define PLANETMOONSNODE_H_
#include "skynode.h"
+#include "../labelsitem.h"
class PlanetNode;
class PlanetMoons;
@@ -46,6 +47,7 @@ public:
* which are cached in RootNode.
*/
PlanetMoonsNode(KSPlanetBase* planet, RootNode* parentNode);
+ ~PlanetMoonsNode();
/**
* @short Add object of type PlanetMoons to this node
@@ -80,6 +82,8 @@ private:
PlanetNode *m_planetNode;
PlanetMoons *pmoons;
+ LabelsItem::label_t m_labelType;
+
QList<SkyNode *> m_moonNodes;
RootNode *m_rootNode;
diff --git a/kstars/kstarslite/skyitems/skynodes/planetnode.cpp b/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
index cf2d682..a2a921e 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
@@ -51,6 +51,7 @@ PlanetNode::PlanetNode(KSPlanetBase* pb, RootNode* parentNode)
m_planetOpacity->appendChildNode(m_planetPic);
m_planetPic->setTexture(SkyMapLite::Instance()->window()->createTextureFromImage(
pb->image(), QQuickWindow::TextureCanUseAtlas));
+ m_planetPic->setOwnsTexture(true);
m_label = parentNode->labelsItem()->addLabel(pb, LabelsItem::label_t::PLANET_LABEL);
}
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
index c45d2e7..f6e2de6 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
@@ -27,7 +27,7 @@
PointSourceNode::PointSourceNode(SkyObject * skyObject, RootNode * parentNode,
LabelsItem::label_t labelType, char spType, float size, short trixel)
- :SkyNode(skyObject), m_point(0), m_sizeMagLim(10.), // has to be changed when stars will be introduced
+ :SkyNode(skyObject), m_point(0), // has to be changed when stars will be introduced
m_label(0), m_labelType(labelType), m_rootNode(parentNode), m_trixel(trixel)
{
m_point = new PointNode(parentNode,spType,starWidth(size));
@@ -35,6 +35,10 @@ PointSourceNode::PointSourceNode(SkyObject * skyObject, RootNode * parentNode,
m_opacity->appendChildNode(m_point);
}
+/*PointSourceNode::~PointSourceNode() {
+ m_rootNode->labelsItem()->deleteLabel(m_label);
+}*/
+
float PointSourceNode::starWidth(float mag) const
{
//adjust maglimit for ZoomLevel
@@ -46,6 +50,8 @@ float PointSourceNode::starWidth(float mag) const
float sizeFactor = maxSize + (lgz - lgmin);
+ float m_sizeMagLim = map()->sizeMagLim();
+
float size = ( sizeFactor*( m_sizeMagLim - mag ) / m_sizeMagLim ) + 1.;
if( size <= 1.0 ) size = 1.0;
if( size > maxSize ) size = maxSize;
@@ -74,7 +80,11 @@ 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!
- m_point->setSize(starWidth(m_skyObject->mag()));
+ if(m_labelType == LabelsItem::label_t::DEEP_SKY_LABEL){
+ m_point->setSize(14);//starWidth(m_skyObject->mag()));
+ } else {
+ m_point->setSize(starWidth(m_skyObject->mag()));
+ }
changePos(pos);
show();
//m_point->show();
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
index deb5f76..a05289e 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
@@ -46,6 +46,8 @@ 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();
+
/** @short Get the width of a star of magnitude mag */
float starWidth(float mag) const;
@@ -55,14 +57,11 @@ public:
*/
virtual void changePos(QPointF pos) override;
- void setSizeMagLim(float sizeMagLim) { m_sizeMagLim = sizeMagLim; }
-
virtual void update() override;
virtual void hide() override;
private:
PointNode * m_point;
//TODO deal setter for this when stars will be introduced
- float m_sizeMagLim;
RootNode *m_rootNode;
LabelNode *m_label;
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.h b/kstars/kstarslite/skyitems/skynodes/skynode.h
index 9476f0a..3155589 100644
--- a/kstars/kstarslite/skyitems/skynodes/skynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/skynode.h
@@ -57,7 +57,7 @@ public:
/** @short short function to access SkyMapLite
* @return pointer to instance of SkyMapLite class
*/
- inline const SkyMapLite* map() { return SkyMapLite::Instance(); }
+ inline SkyMapLite* map() const { return SkyMapLite::Instance(); }
/**
* @short updates coordinate of the object on SkyMapLite
@@ -70,6 +70,8 @@ public:
*/
void update(bool drawLabel);
+ inline void addChildNode(QSGNode *node) { m_opacity->appendChildNode(node); }
+
/**
* @short hides all child nodes (sets opacity of m_opacity to 0)
*/
diff --git a/kstars/kstarslite/skyitems/skynodes/skytexturenode.cpp b/kstars/kstarslite/skyitems/skynodes/skytexturenode.cpp
new file mode 100644
index 0000000..c30cca6
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/skytexturenode.cpp
@@ -0,0 +1,15 @@
+/** *************************************************************************
+ skytexturenode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 20/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. *
+ * *
+ ***************************************************************************/
diff --git a/kstars/kstarslite/skyitems/skynodes/skytexturenode.h b/kstars/kstarslite/skyitems/skynodes/skytexturenode.h
new file mode 100644
index 0000000..7d032c2
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/skytexturenode.h
@@ -0,0 +1,15 @@
+/** *************************************************************************
+ skytexturenode.h - K Desktop Planetarium
+ -------------------
+ begin : 20/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. *
+ * *
+ ***************************************************************************/
diff --git a/kstars/kstarslite/skyitems/skyopacitynode.h b/kstars/kstarslite/skyitems/skyopacitynode.h
index e121470..3a4c7bb 100644
--- a/kstars/kstarslite/skyitems/skyopacitynode.h
+++ b/kstars/kstarslite/skyitems/skyopacitynode.h
@@ -34,12 +34,12 @@ public:
/**
* @short makes this node visible
*/
- void show();
+ virtual void show();
/**
* @short hides this node
*/
- void hide();
+ virtual void hide();
/**
* @return true if node is visible
diff --git a/kstars/kstarslite/skyitems/staritem.cpp b/kstars/kstarslite/skyitems/staritem.cpp
index c4a402f..cb917a4 100644
--- a/kstars/kstarslite/skyitems/staritem.cpp
+++ b/kstars/kstarslite/skyitems/staritem.cpp
@@ -32,7 +32,7 @@ StarItem::StarItem(StarComponent *starComp, RootNode *rootNode)
,m_starLabels(rootNode->labelsItem()->getLabelNode(labelType())), m_stars(new SkyOpacityNode),
m_deepStars(new SkyOpacityNode)
{
- StarIndex *trixels = m_starComp->starIndex();
+ StarIndex *trixels = m_starComp->m_starIndex;
appendChildNode(m_stars);
//Test
@@ -73,17 +73,19 @@ void StarItem::update() {
hide();
return;
}
+ show();
SkyMapLite *map = SkyMapLite::Instance();
KStarsData* data = KStarsData::Instance();
bool checkSlewing = ( map->isSlewing() && Options::hideOnSlew() );
- bool hideLabels = checkSlewing || !( Options::showStarMagnitudes() || Options::showStarNames() );
+ bool hideLabel = checkSlewing || !( Options::showStarMagnitudes() || Options::showStarNames() );
+ if(hideLabel) hideLabels();
//shortcuts to inform whether to draw different objects
bool hideFaintStars = checkSlewing && Options::hideStars();
double hideStarsMag = Options::magLimitHideStar();
- m_starComp->reindex( data->updateNum() );
+ bool reIndex = m_starComp->reindex( data->updateNum() );
double lgmin = log10(MINZOOM);
double lgmax = log10(MAXZOOM);
@@ -92,6 +94,7 @@ void StarItem::update() {
double maglim;
double m_zoomMagLimit; //Check it later. Needed for labels
m_zoomMagLimit = maglim = StarComponent::zoomMagnitudeLimit();
+ map->setSizeMagLim(m_zoomMagLimit);
double labelMagLim = Options::starLabelDensity() / 5.0;
labelMagLim += ( 12.0 - labelMagLim ) * ( lgz - lgmin) / (lgmax - lgmin );
@@ -145,17 +148,39 @@ void StarItem::update() {
QSGNode *firstLabel = m_starLabels->firstChild();
TrixelNode *label = static_cast<TrixelNode *>(firstLabel);
+ StarIndex *index = m_starComp->m_starIndex;
+
+ if(reIndex) rootNode()->labelsItem()->deleteLabels(labelType());
+
while( trixel != 0 ) {
+ //All stars were reindexed so recreate the trixel nodes again
+ if(reIndex) {
+ StarList *skyList = index->at(trixelID);
+
+ QSGNode *n = trixel->firstChild();
+ while( n != 0 ) {
+ QSGNode *c = n;
+ n = n->nextSibling();
+
+ //Delete node
+ trixel->removeChildNode(c);
+ delete c;
+ }
+
+ 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);
+ }
+ }
+ }
+
if(trixelID != regionID) {
trixel->hide();
label->hide();
- trixel = static_cast<TrixelNode *>(trixel->nextSibling());
- label = static_cast<TrixelNode *>(label->nextSibling());
-
- trixelID++;
-
- continue;
} else {
trixel->show();
label->show();
@@ -163,33 +188,32 @@ void StarItem::update() {
if(region.hasNext()) {
regionID = region.next();
}
- }
- QSGNode *n = trixel->firstChild();
+ QSGNode *n = trixel->firstChild();
- bool hide = false;
+ bool hide = false;
- while(n != 0) {
- PointSourceNode *point = static_cast<PointSourceNode *>(n);
- n = n->nextSibling();
+ while(n != 0) {
+ PointSourceNode *point = static_cast<PointSourceNode *>(n);
+ n = n->nextSibling();
- StarObject *curStar = static_cast<StarObject *>(point->skyObject());
- float mag = curStar->mag();
+ StarObject *curStar = static_cast<StarObject *>(point->skyObject());
+ float mag = curStar->mag();
- bool drawLabel = false;
- // break loop if maglim is reached
- if(!hide) {
- if ( mag > maglim ) hide = true;
- if(!(hideLabels || mag > labelMagLim)) drawLabel = true;
- }
+ 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->setSizeMagLim(m_zoomMagLimit);
- point->SkyNode::update(drawLabel);
- } else {
- point->hide();
+ if(!hide) {
+ if ( curStar->updateID != KStarsData::Instance()->updateID() )
+ curStar->JITupdate();
+ point->SkyNode::update(drawLabel);
+ } else {
+ point->hide();
+ }
}
}
trixel = static_cast<TrixelNode *>(trixel->nextSibling());
diff --git a/kstars/main.cpp b/kstars/main.cpp
index 55d0d06..0211efc 100644
--- a/kstars/main.cpp
+++ b/kstars/main.cpp
@@ -239,6 +239,11 @@ int main(int argc, char *argv[])
Options::setTimeZone(1);
Options::setRunClock(false);
+ Options::setShowStarMagnitudes(false);
+ Options::setShowStarNames(true);
+ Options::setShowStars(true);
+
+ Options::setShowDeepSky(true);
Options::setShowCBounds(true);
Options::setShowCLines(true);
Options::setShowSolarSystem(true);
@@ -246,7 +251,7 @@ int main(int argc, char *argv[])
Options::setShowEquator(true);
Options::setShowEquatorialGrid(false);
Options::setShowHorizontalGrid(true);
- Options::setShowGround(true);
+ Options::setShowGround(false);
//Labels
Options::setShowCometNames(true);
@@ -254,6 +259,9 @@ int main(int argc, char *argv[])
Options::setShowAsteroids(true);
Options::setShowCNames(true);
+ Options::setShowNGC(true);
+ Options::setHideNGC(true);
+
Options::setAutoSelectGrid(false);
Options::setHideCBounds(true);
diff --git a/kstars/skycomponents/deepskycomponent.h b/kstars/skycomponents/deepskycomponent.h
index f60a5f7..f8ef7d2 100644
--- a/kstars/skycomponents/deepskycomponent.h
+++ b/kstars/skycomponents/deepskycomponent.h
@@ -35,6 +35,10 @@ class SkyPoint;
class SkyMesh;
class SkyLabeler;
+#ifdef KSTARS_LITE
+class DeepSkyItem;
+#endif
+
// NOTE: Although the following symbol has nothing to do with line
// number in any file, we use this name to keep consistency in naming
// conventions with StarComponent
@@ -54,6 +58,10 @@ typedef QHash< int, DeepSkyList*> DeepSkyIndex;
*/
class DeepSkyComponent: public SkyComponent
{
+#ifdef KSTARS_LITE
+friend class DeepSkyItem;
+#endif
+
public:
explicit DeepSkyComponent( SkyComposite* );
diff --git a/kstars/skycomponents/deepstarcomponent.h b/kstars/skycomponents/deepstarcomponent.h
index 2427844..911d6c2 100644
--- a/kstars/skycomponents/deepstarcomponent.h
+++ b/kstars/skycomponents/deepstarcomponent.h
@@ -48,7 +48,9 @@ class StarBlockList;
class DeepStarComponent: public ListComponent
{
+#ifdef KSTARS_LITE
friend class DeepStarItem; //Needs access to staticStars and buch of other facilities
+#endif
public:
diff --git a/kstars/skycomponents/highpmstarlist.cpp b/kstars/skycomponents/highpmstarlist.cpp
index de52719..d368eea 100644
--- a/kstars/skycomponents/highpmstarlist.cpp
+++ b/kstars/skycomponents/highpmstarlist.cpp
@@ -64,10 +64,10 @@ void HighPMStarList::setIndexTime( KSNumbers *num )
m_reindexNum = KSNumbers( *num );
}
-void HighPMStarList::reindex( KSNumbers *num, StarIndex* starIndex )
+bool HighPMStarList::reindex( KSNumbers *num, StarIndex* starIndex )
{
if ( fabs( num->julianCenturies() -
- m_reindexNum.julianCenturies() ) < m_reindexInterval ) return;
+ m_reindexNum.julianCenturies() ) < m_reindexInterval ) return false;
m_reindexNum = KSNumbers( *num );
m_skyMesh->setKSNumbers( num );
@@ -110,6 +110,7 @@ void HighPMStarList::reindex( KSNumbers *num, StarIndex* starIndex )
// printf(" %4.2f\n", list->at(j)->mag() );
//}
}
+ return true;
//printf("Re-indexed %d stars at interval %6.1f\n", cnt, 100.0 * m_reindexInterval );
}
diff --git a/kstars/skycomponents/highpmstarlist.h b/kstars/skycomponents/highpmstarlist.h
index f040a1b..7723c7d 100644
--- a/kstars/skycomponents/highpmstarlist.h
+++ b/kstars/skycomponents/highpmstarlist.h
@@ -71,7 +71,7 @@ public:
* more than our update interval then we re-index all the stars in our
* list that have actually changed trixels.
*/
- void reindex( KSNumbers *num, StarIndex* starIndex );
+ bool reindex( KSNumbers *num, StarIndex* starIndex );
/** @short prints out some brief statistics.
*/
diff --git a/kstars/skycomponents/skylabeler.cpp b/kstars/skycomponents/skylabeler.cpp
index 6311d38..fd4402c 100644
--- a/kstars/skycomponents/skylabeler.cpp
+++ b/kstars/skycomponents/skylabeler.cpp
@@ -79,7 +79,6 @@ void SkyLabeler::setZoomFont()
}
if(m_drawFont.pointSize() != font.pointSize()) {
m_drawFont = font;
- SkyMapLite::Instance()->setFontSizeChanged(true);
}
#endif
}
diff --git a/kstars/skycomponents/skylabeler.h b/kstars/skycomponents/skylabeler.h
index 2951e2f..216439b 100644
--- a/kstars/skycomponents/skylabeler.h
+++ b/kstars/skycomponents/skylabeler.h
@@ -332,8 +332,9 @@ public:
inline QFont stdFont() { return m_stdFont; }
inline QFont skyFont() { return m_skyFont; }
+#ifdef KSTARS_LITE
inline QFont drawFont() { return m_drawFont; }
-
+#endif
int hits() { return m_hits; }
int marks() { return m_marks; }
diff --git a/kstars/skycomponents/skymapcomposite.h b/kstars/skycomponents/skymapcomposite.h
index 45bdb72..22fd365 100644
--- a/kstars/skycomponents/skymapcomposite.h
+++ b/kstars/skycomponents/skymapcomposite.h
@@ -188,9 +188,9 @@ public:
inline ConstellationNamesComponent* constellationNamesComponent() { return m_CNames; }
+ inline DeepSkyComponent* deepSkyComponent() { return m_DeepSky; }
//Accessors for StarComponent
- inline StarComponent *starComponent() { return m_Stars; } //Used in StarItem (KStars Lite)
SkyObject* findStarByGenetiveName( const QString name );
virtual void emitProgressText( const QString &message );
QList<SkyObject*>& labelObjects() { return m_LabeledObjects; }
diff --git a/kstars/skycomponents/starblocklist.cpp b/kstars/skycomponents/starblocklist.cpp
index d57a573..f2497b7 100644
--- a/kstars/skycomponents/starblocklist.cpp
+++ b/kstars/skycomponents/starblocklist.cpp
@@ -49,6 +49,7 @@ int StarBlockList::releaseBlock( StarBlock *block ) {
qDebug() << "ERROR: Trying to release a block which is not the last block! Trixel = " << trixel << endl;
else if( blocks.size() > 0 ) {
+#ifdef KSTARS_LITE
for(int i = 0; i < block->getStarCount(); ++i) {
PointSourceNode * node = block->star(i)->starNode;
if(node) {
@@ -56,7 +57,7 @@ int StarBlockList::releaseBlock( StarBlock *block ) {
block->star(i)->starNode = 0;
}
}
-
+#endif
blocks.removeLast();
nBlocks--;
nStars -= block->getStarCount();
diff --git a/kstars/skycomponents/starcomponent.cpp b/kstars/skycomponents/starcomponent.cpp
index e337453..1bb4e6f 100644
--- a/kstars/skycomponents/starcomponent.cpp
+++ b/kstars/skycomponents/starcomponent.cpp
@@ -130,20 +130,22 @@ void StarComponent::update( KSNumbers*)
// We use the update hook to re-index all the stars when the date has changed by
// more than 150 years.
-void StarComponent::reindex( KSNumbers *num )
+bool StarComponent::reindex( KSNumbers *num )
{
- if ( ! num ) return;
+ if ( ! num ) return false;
// for large time steps we re-index all points
if ( fabs( num->julianCenturies() -
m_reindexNum.julianCenturies() ) > m_reindexInterval ) {
reindexAll( num );
- return;
+ return true;
}
+ bool highPM = true;
// otherwise we just re-index fast movers as needed
for ( int j = 0; j < m_highPMStars.size(); j++ )
- m_highPMStars.at( j )->reindex( num, m_starIndex );
+ highPM &= !(m_highPMStars.at( j )->reindex( num, m_starIndex ));
+ return !(highPM);
}
void StarComponent::reindexAll( KSNumbers *num )
diff --git a/kstars/skycomponents/starcomponent.h b/kstars/skycomponents/starcomponent.h
index c626b96..9543369 100644
--- a/kstars/skycomponents/starcomponent.h
+++ b/kstars/skycomponents/starcomponent.h
@@ -45,7 +45,11 @@
#include "binfilehelper.h"
#include "starblockfactory.h"
#include "skymesh.h"
-#include "kstarslite/skyitems/staritem.h"
+
+#ifdef KSTARS_LITE
+class StarItem;
+//#include "kstarslite/skyitems/staritem.h"
+#endif
class SkyMesh;
class StarObject;
@@ -59,7 +63,9 @@ class MeshIterator;
class StarComponent: public ListComponent
{
+#ifdef KSTARS_LITE
friend class StarItem; //Needs access to faintMagnitude() and reindex()
+#endif
protected:
@@ -93,9 +99,6 @@ public:
virtual SkyObject* findStarByGenetiveName( const QString name );
- /** @short get m_starIndex. Used in StarItem (KStars Lite)*/
- inline StarIndex* starIndex() { return m_starIndex; }
-
/**
*@short Find stars by name (including genetive name)
*
@@ -165,7 +168,8 @@ private:
/** @return the magnitude of the faintest star */
float faintMagnitude() const;
- void reindex( KSNumbers *num );
+ /** true if all stars(not only high PM ones) were reindexed else false**/
+ bool reindex( KSNumbers *num );
SkyMesh* m_skyMesh;
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index 474970f..0522162 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -86,7 +86,7 @@ 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)
+ nStarSizes(15), nSPclasses(7), pinch(false), m_loadingFinished(false), m_sizeMagLim(10.0)
{
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::AllButtons);
@@ -123,6 +123,7 @@ QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
qDeleteAll(m_deleteNodes);
m_deleteNodes.clear();
+
if(m_loadingFinished) {
if(!n) {
n = new RootNode();
@@ -130,6 +131,21 @@ QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
n->update();
}
+ //Debug
+ /*if(m_loadingFinished) {
+ if(!n) {
+ n = new RootNode();
+ }
+ n->testLeakAdd();
+ n->update();
+ m_loadingFinished = false;
+ } else {
+ if (n) {
+ n->testLeakDelete();
+ }
+ m_loadingFinished = true;
+ }*/
+
return n;
}
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 737f86e..13854f0 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -282,12 +282,11 @@ public:
@return a pointer to the current projector. */
inline const Projector * projector() const { return m_proj; }
- /**
- * @return true if font size was changed
- */
- inline bool fontSizeChanged() const { return m_fontSizeChanged; }
+ /** Set magnitude limit for size of stars. Used in StarItem **/
+ inline void setSizeMagLim(float sizeMagLim) { m_sizeMagLim = sizeMagLim; }
- inline void setFontSizeChanged(bool val) { m_fontSizeChanged = val; }
+ /** Used in PointSourceNode **/
+ inline float sizeMagLim() const { return m_sizeMagLim; }
/**
*@short Proxy method for SkyMapDrawAbstract::drawObjectLabels()
@@ -596,6 +595,8 @@ private:
//Holds SkyNodes that need to be deleted
QLinkedList<SkyNode *> m_deleteNodes;
+ float m_sizeMagLim; //Used in PointSourceNode
+
// Used to notify zoom-dependent labels about font size change
bool m_fontSizeChanged;
// Used for drawing labels
diff --git a/kstars/skyqpainter.cpp b/kstars/skyqpainter.cpp
index 1ac18c6..8142497 100644
--- a/kstars/skyqpainter.cpp
+++ b/kstars/skyqpainter.cpp
@@ -547,6 +547,8 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
float ya = y + dya;
float yb = y + dyb;
+ QString color;
+
float psize;
QBrush tempBrush;
@@ -566,6 +568,7 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
case 3: //Open cluster; draw circle of points
case 13: // Asterism
tempBrush = brush();
+ color = pen().color().name();
setBrush( pen().color() );
psize = 2.;
if ( size > 50. ) psize *= 2.;
@@ -599,6 +602,7 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
if (size<2.) size = 2.;
save();
translate( x, y );
+ color = pen().color().name();
rotate( positionAngle ); //rotate the coordinate system
if ( Options::useAntialias() ) {
@@ -622,7 +626,7 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
save();
translate( x, y );
rotate( positionAngle ); //rotate the coordinate system
-
+color = pen().color().name();
if ( Options::useAntialias() ) {
drawLine( QPointF(dx1, dy1), QPointF(dx2, dy1) );
drawLine( QPointF(dx2, dy1), QPointF(dx2, dy2) );
@@ -643,7 +647,7 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
save();
translate( x, y );
rotate( positionAngle ); //rotate the coordinate system
-
+color = pen().color().name();
if ( Options::useAntialias() ) {
drawEllipse( QRectF(dx1, dy1, size, e*size) );
drawLine( QPointF(0., dy1), QPointF(0., dy1 - e*size/2. ) );
@@ -667,7 +671,7 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
save();
translate( x, y );
rotate( positionAngle ); //rotate the coordinate system
-
+color = pen().color().name();
if ( Options::useAntialias() ) {
drawLine( QPointF(0., dy1), QPointF(dx2, 0.) );
drawLine( QPointF(dx2, 0.), QPointF(0., dy2) );
@@ -686,6 +690,7 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
break;
case 8: //Galaxy
case 16: // Quasar
+ color = pen().color().name();
if ( size <1. && zoom > 20*MINZOOM ) size = 3.; //force ellipse above zoomFactor 20
if ( size <1. && zoom > 5*MINZOOM ) size = 1.; //force points above zoomFactor 5
if ( size>2. ) {
@@ -711,7 +716,7 @@ void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, fl
setBrush( pen().color() );
psize = 1.;
if ( size > 50. ) psize *= 2.;
-
+color = pen().color().name();
if ( Options::useAntialias() ) {
drawLine( QLineF( xa - psize, y1, xa + psize, y1 ) );
drawLine( QLineF( xa, y1 - psize, xa, y1 + psize ) );