summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-06-17 00:18:06 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-06-17 00:18:06 (GMT)
commit7fd5cf743a9a47255d635ebc48dd83a70cff86d9 (patch)
treea86c54772ded793d506eee4e8baa03d07faabdc5
parent9cd753ceddba4e62aac6afe3eedd55ddc7476250 (diff)
Added support for named stars. Added SkyOpacityNode (wrapper for
QSGOpacityNode)
-rw-r--r--kstars/CMakeLists.txt6
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.cpp72
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.h17
-rw-r--r--kstars/kstarslite/skyitems/lines/eclipticitem.cpp35
-rw-r--r--kstars/kstarslite/skyitems/lines/equatoritem.cpp36
-rw-r--r--kstars/kstarslite/skyitems/lines/linesitem.cpp58
-rw-r--r--kstars/kstarslite/skyitems/lines/linesitem.h5
-rw-r--r--kstars/kstarslite/skyitems/rootnode.cpp11
-rw-r--r--kstars/kstarslite/skyitems/rootnode.h6
-rw-r--r--kstars/kstarslite/skyitems/skyitem.cpp21
-rw-r--r--kstars/kstarslite/skyitems/skyitem.h17
-rw-r--r--kstars/kstarslite/skyitems/skynodes/labelnode.cpp35
-rw-r--r--kstars/kstarslite/skyitems/skynodes/labelnode.h6
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp63
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/linenode.h13
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp14
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h6
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp15
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/polynode.h7
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetnode.cpp17
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetnode.h3
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp17
-rw-r--r--kstars/kstarslite/skyitems/skynodes/pointsourcenode.h7
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.cpp25
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.h11
-rw-r--r--kstars/kstarslite/skyitems/skynodes/trixelnode.cpp66
-rw-r--r--kstars/kstarslite/skyitems/skynodes/trixelnode.h62
-rw-r--r--kstars/kstarslite/skyitems/skyopacitynode.cpp42
-rw-r--r--kstars/kstarslite/skyitems/skyopacitynode.h50
-rw-r--r--kstars/kstarslite/skyitems/staritem.cpp198
-rw-r--r--kstars/kstarslite/skyitems/staritem.h56
-rw-r--r--kstars/kstarslite/skyitems/typedeflite.h10
-rw-r--r--kstars/main.cpp10
-rw-r--r--kstars/skycomponents/skymapcomposite.h1
-rw-r--r--kstars/skycomponents/starcomponent.cpp4
-rw-r--r--kstars/skycomponents/starcomponent.h9
-rw-r--r--kstars/skymaplite.cpp1
37 files changed, 644 insertions, 388 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 9861e82..9154b08 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -546,6 +546,8 @@ if(BUILD_KSTARS_LITE)
skymapliteevents.cpp
#RootNode
kstarslite/skyitems/rootnode.cpp
+ kstarslite/skyitems/skyopacitynode.cpp
+ kstarslite/skyitems/typedeflite.h
#SkyItems
kstarslite/skyitems/skyitem.cpp
kstarslite/skyitems/planetsitem.cpp
@@ -554,6 +556,7 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/horizonitem.cpp
kstarslite/skyitems/labelsitem.cpp
kstarslite/skyitems/constellationnamesitem.cpp
+ kstarslite/skyitems/staritem.cpp
#Lines
kstarslite/skyitems/lines/linesitem.cpp
kstarslite/skyitems/lines/equatoritem.cpp
@@ -564,7 +567,8 @@ 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/trixelnode.cpp
+ #kstarslite/skyitems/skynodes/startrixelnode.cpp
kstarslite/skyitems/skynodes/labelnode.cpp
kstarslite/skyitems/skynodes/guidelabelnode.cpp
#Nodes
diff --git a/kstars/kstarslite/skyitems/labelsitem.cpp b/kstars/kstarslite/skyitems/labelsitem.cpp
index d983339..e7939cc 100644
--- a/kstars/kstarslite/skyitems/labelsitem.cpp
+++ b/kstars/kstarslite/skyitems/labelsitem.cpp
@@ -22,13 +22,23 @@
#include "skynodes/guidelabelnode.h"
#include "cometsitem.h"
+#include "staritem.h"
#include "rootnode.h"
+#include "skymesh.h"
LabelsItem::LabelsItem()
:m_rootNode(0)
{
LabelTypeNode *stars = new LabelTypeNode;
appendChildNode(stars);
+
+ //Add trixels to hold star labels
+ int trixelNum = SkyMesh::Instance()->size();
+
+ for(int i = 0; i < trixelNum; ++i) {
+ stars->appendChildNode(new TrixelNode);
+ }
+
m_labelsLists.insert(label_t::STAR_LABEL, stars);
LabelTypeNode *asteroids = new LabelTypeNode;
@@ -93,6 +103,13 @@ LabelNode *LabelsItem::addLabel(SkyObject *skyObject, label_t labelType) {
return label;
}
+LabelNode *LabelsItem::addLabel(SkyObject *skyObject, label_t labelType, Trixel trixel) {
+ Q_ASSERT(labelType == STAR_LABEL);
+ LabelNode *label = new LabelNode(skyObject, labelType);
+ m_labelsLists.value(labelType)->childAtIndex(trixel)->appendChildNode(label);
+ return label;
+}
+
LabelNode *LabelsItem::addLabel(QString name, label_t labelType) {
LabelNode *label = new LabelNode(name, labelType);
m_labelsLists.value(labelType)->appendChildNode(label);
@@ -109,10 +126,13 @@ void LabelsItem::update() {
SkyLabeler * skyLabeler = SkyLabeler::Instance();
skyLabeler->reset();
+ updateChildLabels(label_t::HORIZON_LABEL);
+
updateChildLabels(label_t::EQUATOR_LABEL);
updateChildLabels(label_t::ECLIPTIC_LABEL);
updateChildLabels(label_t::PLANET_LABEL);
+
updateChildLabels(label_t::JUPITER_MOON_LABEL);
updateChildLabels(label_t::SATURN_MOON_LABEL);
@@ -123,15 +143,10 @@ void LabelsItem::update() {
}
updateChildLabels(label_t::CONSTEL_NAME_LABEL);
- updateChildLabels(label_t::HORIZON_LABEL);
+ updateChildLabels(label_t::STAR_LABEL);
}
-void LabelsItem::hideLabels(label_t labelType) {
- QSGOpacityNode *node = m_labelsLists[labelType];
- node->setOpacity(0);
- node->markDirty(QSGNode::DirtyOpacity);
-}
void LabelsItem::setRootNode(RootNode *rootNode) {
//Remove from previous parent if had any
@@ -144,15 +159,14 @@ void LabelsItem::setRootNode(RootNode *rootNode) {
void LabelsItem::deleteLabels(label_t labelType) {
if(labelType != label_t::NO_LABEL) {
- QSGOpacityNode *node = m_labelsLists[labelType];
+ LabelTypeNode *node = m_labelsLists[labelType];
while(QSGNode *n = node->firstChild()) { node->removeChildNode(n); delete n; }
}
}
void LabelsItem::updateChildLabels(label_t labelType) {
- QSGOpacityNode *node = m_labelsLists[labelType];
- node->setOpacity(1);
- node->markDirty(QSGNode::DirtyOpacity);
+ LabelTypeNode *node = m_labelsLists[labelType];
+ node->show();
QSGNode *n = node->firstChild();
/*if( labelType == label_t::HORIZON_LABEL
@@ -172,17 +186,37 @@ void LabelsItem::updateChildLabels(label_t labelType) {
}
} else {*/
while( n != 0) {
- LabelNode *label = static_cast<LabelNode *>(n);
- if(label->visible()) {
- if(label->zoomFont()) skyLabeler->resetFont();
- if(skyLabeler->markText(label->labelPos, label->name())) {
- label->update();
- } else {
- label->hide();
+ if(labelType == STAR_LABEL) {
+ TrixelNode *trixel = static_cast<TrixelNode *>(n);
+
+ if(trixel->visible()) {
+ QSGNode *l = trixel->firstChild();
+
+ while(l != 0) {
+ LabelNode *label = static_cast<LabelNode *>(l);
+ l = l->nextSibling();
+
+ if(skyLabeler->markText(label->labelPos, label->name())) {
+ label->update();
+ } else {
+ label->hide();
+ }
+ }
+ }
+ } else {
+ LabelNode *label = static_cast<LabelNode *>(n);
+ //n = n->nextSibling();
+
+ if(label->visible()) {
+ if(label->zoomFont()) skyLabeler->resetFont();
+ if(skyLabeler->markText(label->labelPos, label->name())) {
+ label->update();
+ } else {
+ label->hide();
+ }
+ skyLabeler->useStdFont();
}
- skyLabeler->useStdFont();
}
n = n->nextSibling();
}
-
}
diff --git a/kstars/kstarslite/skyitems/labelsitem.h b/kstars/kstarslite/skyitems/labelsitem.h
index 342370b..1f42876 100644
--- a/kstars/kstarslite/skyitems/labelsitem.h
+++ b/kstars/kstarslite/skyitems/labelsitem.h
@@ -17,11 +17,12 @@
#define LABELSITEM_H_
#include "skylabeler.h"
+#include "typedef.h"
+#include "typedeflite.h"
-#include <QSGOpacityNode>
-
-typedef QSGOpacityNode LabelTypeNode;
+#include "skyopacitynode.h"
+class StarItem;
class LabelNode;
class GuideLabelNode;
class RootNode;
@@ -56,7 +57,7 @@ class SkyObject;
* @version 1.0
*/
-class LabelsItem : public QSGOpacityNode {
+class LabelsItem : public SkyOpacityNode {
public:
@@ -96,6 +97,12 @@ public:
*/
LabelNode *addLabel(SkyObject *skyObject, label_t labelType);
+ /** creates LabelNode and appends it to corresponding TrixelNode so that all labels
+ * can be hidden whenever Trixel is not displayed. Use for sky objects that are indexed by SkyMesh
+ * @param trixel id of trixel
+ **/
+ LabelNode *addLabel(SkyObject *skyObject, label_t labelType, Trixel trixel);
+
/**
* @short does the same as above but with QString instead of SkyObject
*/
@@ -139,7 +146,7 @@ public:
* @short hides all labels of type labelType
*/
- void hideLabels(label_t labelType);
+ inline void hideLabels(label_t labelType) { m_labelsLists[labelType]->hide(); }
/**
* @short sets m_rootNode and appends to it this node
diff --git a/kstars/kstarslite/skyitems/lines/eclipticitem.cpp b/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
index d4935d4..f0fb257 100644
--- a/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
@@ -20,7 +20,7 @@
#include "../labelsitem.h"
#include "ecliptic.h"
#include "../skynodes/labelnode.h"
-#include "../skynodes/trixelnode.h"
+#include "../skynodes/nodes/linenode.h"
EclipticItem::EclipticItem(Ecliptic *eclipticComp, RootNode *rootNode)
:SkyItem(LabelsItem::label_t::ECLIPTIC_LABEL, rootNode), m_eclipticComp(eclipticComp)
@@ -29,9 +29,18 @@ EclipticItem::EclipticItem(Ecliptic *eclipticComp, RootNode *rootNode)
QHash< Trixel, LineListList *>::const_iterator i = trixels->begin();
while( i != trixels->end()) {
+ LineListList *linesList = *i;
- TrixelNode *trixel = new TrixelNode(i.key(), i.value(), "EclColor", 1, Qt::SolidLine );
- appendChildNode(trixel);
+ if(linesList->size()) {
+ TrixelNode *trixel = new TrixelNode;
+ appendChildNode(trixel);
+
+ QColor schemeColor = KStarsData::Instance()->colorScheme()->colorNamed("EclColor");
+ for(int c = 0; c < linesList->size(); ++c) {
+ LineNode * ln = new LineNode(linesList->at(c), schemeColor, 1, Qt::SolidLine);
+ trixel->appendChildNode(ln);
+ }
+ }
++i;
}
@@ -59,10 +68,28 @@ void EclipticItem::update() {
if(m_eclipticComp->selected()) {
show();
QSGNode *n = firstChild();
+
+ DrawID drawID = SkyMesh::Instance()->drawID();
+ //UpdateID updateID = KStarsData::Instance()->updateID();
+
while(n != 0) {
TrixelNode * trixel = static_cast<TrixelNode *>(n);
+ trixel->show();
n = n->nextSibling();
- trixel->update();
+
+ QSGNode *l = trixel->firstChild();
+ while(l != 0) {
+ LineNode * lines = static_cast<LineNode *>(l);
+ l = l->nextSibling();
+
+ LineList * lineList = lines->lineList();
+ if ( lineList->drawID == drawID ) {
+ lines->hide();
+ continue;
+ }
+ lineList->drawID = drawID;
+ lines->updateGeometry();
+ }
}
const Projector *proj = SkyMapLite::Instance()->projector();
diff --git a/kstars/kstarslite/skyitems/lines/equatoritem.cpp b/kstars/kstarslite/skyitems/lines/equatoritem.cpp
index 46744065..f099c73 100644
--- a/kstars/kstarslite/skyitems/lines/equatoritem.cpp
+++ b/kstars/kstarslite/skyitems/lines/equatoritem.cpp
@@ -20,9 +20,9 @@
#include "equatoritem.h"
-#include "../skynodes/trixelnode.h"
#include "../rootnode.h"
#include "../labelsitem.h"
+#include "../skynodes/nodes/linenode.h"
#include "../skynodes/labelnode.h"
@@ -33,12 +33,22 @@ EquatorItem::EquatorItem(Equator *equatorComp, RootNode *rootNode)
QHash< Trixel, LineListList *>::const_iterator i = trixels->begin();
while( i != trixels->end()) {
+ LineListList *linesList = *i;
- TrixelNode *trixel = new TrixelNode(i.key(), i.value(), "EqColor", 1, Qt::SolidLine );
- appendChildNode(trixel);
+ if(linesList->size()) {
+ TrixelNode *trixel = new TrixelNode;
+ appendChildNode(trixel);
+
+ QColor schemeColor = KStarsData::Instance()->colorScheme()->colorNamed("EqColor");
+ for(int c = 0; c < linesList->size(); ++c) {
+ LineNode * ln = new LineNode(linesList->at(c), schemeColor, 1, Qt::SolidLine);
+ trixel->appendChildNode(ln);
+ }
+ }
++i;
}
+ //Add compass labels
for( int ra = 0; ra < 23; ra += 2 ) {
SkyPoint *o = new SkyPoint( ra, 0.0 );
@@ -54,10 +64,28 @@ void EquatorItem::update() {
if(m_equatorComp->selected()) {
show();
QSGNode *n = firstChild();
+
+ DrawID drawID = SkyMesh::Instance()->drawID();
+ //UpdateID updateID = KStarsData::Instance()->updateID();
+
while(n != 0) {
TrixelNode * trixel = static_cast<TrixelNode *>(n);
+ trixel->show();
n = n->nextSibling();
- trixel->update();
+
+ QSGNode *l = trixel->firstChild();
+ while(l != 0) {
+ LineNode * lines = static_cast<LineNode *>(l);
+ l = l->nextSibling();
+
+ LineList * lineList = lines->lineList();
+ if ( lineList->drawID == drawID ) {
+ lines->hide();
+ continue;
+ }
+ lineList->drawID = drawID;
+ lines->updateGeometry();
+ }
}
const Projector *proj = SkyMapLite::Instance()->projector();
diff --git a/kstars/kstarslite/skyitems/lines/linesitem.cpp b/kstars/kstarslite/skyitems/lines/linesitem.cpp
index 0e6a1d6..6c2b77f 100644
--- a/kstars/kstarslite/skyitems/lines/linesitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/linesitem.cpp
@@ -18,7 +18,6 @@
#include "projections/projector.h"
#include <QSGNode>
-#include "../skynodes/trixelnode.h"
#include "linesitem.h"
#include "linelist.h"
#include "linelistindex.h"
@@ -31,7 +30,7 @@ LinesItem::LinesItem(RootNode *rootNode)
}
void LinesItem::addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style) {
- QSGOpacityNode *node = new QSGOpacityNode;
+ LineIndexNode *node = new LineIndexNode;
appendChildNode(node);
m_lineIndexes.insert(node, linesComp);
@@ -39,18 +38,26 @@ void LinesItem::addLinesComponent(LineListIndex *linesComp, QString color, int w
QHash< Trixel, LineListList *>::const_iterator i = trixels->begin();
while( i != trixels->end()) {
+ LineListList *linesList = *i;
- TrixelNode *trixel = new TrixelNode(i.key(), i.value(), color, width, style);
- node->appendChildNode(trixel);
- //trixel->setStyle(color, width, style);
+ if(linesList->size()) {
+ TrixelNode *trixel = new TrixelNode;
+ node->appendChildNode(trixel);
+
+ 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);
+ }
+ }
++i;
}
}
void LinesItem::update() {
- QMap< QSGOpacityNode *, LineListIndex *>::const_iterator i = m_lineIndexes.begin();
+ QMap< LineIndexNode *, LineListIndex *>::const_iterator i = m_lineIndexes.begin();
while( i != m_lineIndexes.end()) {
- QVector<Trixel> visTrixels;
+ //QVector<Trixel> visTrixels;
SkyMesh * mesh = SkyMesh::Instance();
SkyMapLite *map = SkyMapLite::Instance();
double radius = map->projector()->fov();
@@ -60,29 +67,48 @@ void LinesItem::update() {
//mesh->aperture(map->focus(), radius);
}
- MeshIterator region (mesh,DRAW_BUF);
+ /*MeshIterator region (mesh,DRAW_BUF);
while ( region.hasNext() ) {
visTrixels.append(region.next());
- }
+ }*/
+
+ DrawID drawID = SkyMesh::Instance()->drawID();
+ //UpdateID updateID = KStarsData::Instance()->updateID();
- QSGOpacityNode * node = i.key();
+ LineIndexNode * node = i.key();
if(i.value()->selected()) {
- node->setOpacity(1);
- //for(int c = 0; c < node->childCount(); ++c) {
+ node->show();
+
QSGNode *n = node->firstChild();
while(n != 0) {
TrixelNode * trixel = static_cast<TrixelNode *>(n);
+ trixel->show();
+
n = n->nextSibling();
+
//if(visTrixels.contains(c)) {
- trixel->update();
- /* } else {
+
+ QSGNode *l = trixel->firstChild();
+ while(l != 0) {
+ LineNode * lines = static_cast<LineNode *>(l);
+ l = l->nextSibling();
+
+ LineList * lineList = lines->lineList();
+ if ( lineList->drawID == drawID ) {
+ lines->hide();
+ continue;
+ }
+ lineList->drawID = drawID;
+ lines->updateGeometry();
+ }
+
+ /* } else {
trixel->hide();
}*/
}
} else {
- node->setOpacity(0);
+ node->hide();
}
- node->markDirty(QSGNode::DirtyOpacity);
++i;
}
}
diff --git a/kstars/kstarslite/skyitems/lines/linesitem.h b/kstars/kstarslite/skyitems/lines/linesitem.h
index c3e08ab..8972a30 100644
--- a/kstars/kstarslite/skyitems/lines/linesitem.h
+++ b/kstars/kstarslite/skyitems/lines/linesitem.h
@@ -17,6 +17,8 @@
#define LINESITEM_H_
#include "../skyitem.h"
+#include "../skyopacitynode.h"
+#include "../typedeflite.h"
class LineListIndex;
@@ -57,7 +59,8 @@ public:
virtual void update();
private:
- QMap<QSGOpacityNode *,LineListIndex *> m_lineIndexes;
+ QMap<LineIndexNode *, LineListIndex *> m_lineIndexes;
+ //QMap<QSGOpacityNode *, QVector<TrixelNode *> > m_trixelNodes;
};
#endif
diff --git a/kstars/kstarslite/skyitems/rootnode.cpp b/kstars/kstarslite/skyitems/rootnode.cpp
index 0c4ec1e..dfed107 100644
--- a/kstars/kstarslite/skyitems/rootnode.cpp
+++ b/kstars/kstarslite/skyitems/rootnode.cpp
@@ -18,6 +18,7 @@
#include "equator.h"
//SkyItems
+#include "kstarslite/skyitems/staritem.h"
#include "kstarslite/skyitems/planetsitem.h"
#include "kstarslite/skyitems/asteroidsitem.h"
#include "kstarslite/skyitems/cometsitem.h"
@@ -38,7 +39,6 @@ RootNode::RootNode()
Options::setProjection(Projector::Lambert);
m_skyComposite = KStarsData::Instance()->skyComposite();
- m_solarSystem = m_skyComposite->solarSystemComposite();
// LabelsItem needs to be created first so that other items could insert their labels in labelsList
m_labelsItem = new LabelsItem();
@@ -51,6 +51,10 @@ 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_solarSystem = m_skyComposite->solarSystemComposite();
+
m_equator = new EquatorItem(m_skyComposite->equator(),this);
m_ecliptic = new EclipticItem(m_skyComposite->ecliptic(),this);
@@ -151,12 +155,15 @@ void RootNode::update() {
m_constelNamesItem->update();
- m_horizonItem->update();
+ m_starItem->update();
m_equator->update();
m_ecliptic->update();
m_linesItem->update();
+
+ m_horizonItem->update();
+
m_labelsItem->update();
}
diff --git a/kstars/kstarslite/skyitems/rootnode.h b/kstars/kstarslite/skyitems/rootnode.h
index 82470f9..1193b58 100644
--- a/kstars/kstarslite/skyitems/rootnode.h
+++ b/kstars/kstarslite/skyitems/rootnode.h
@@ -21,6 +21,8 @@
class QSGTexture;
class SkyMapLite;
+class StarItem;
+
class PlanetsItem;
class AsteroidsItem;
class CometsItem;
@@ -70,6 +72,8 @@ public:
inline CometsItem *cometsItem() { return m_cometsItem; }
inline LabelsItem *labelsItem() { return m_labelsItem; }
+
+ inline StarItem *starItem() { return m_starItem; }
private:
/**
* @short initializes textureCache with cached images of stars from SkyMapLite
@@ -82,6 +86,8 @@ private:
QPolygonF m_clipPoly;
QSGGeometry *m_clipGeometry;
+ StarItem *m_starItem;
+
PlanetsItem *m_planetsItem;
AsteroidsItem *m_asteroidsItem;
CometsItem *m_cometsItem;
diff --git a/kstars/kstarslite/skyitems/skyitem.cpp b/kstars/kstarslite/skyitems/skyitem.cpp
index e19e8a0..f45af1e 100644
--- a/kstars/kstarslite/skyitems/skyitem.cpp
+++ b/kstars/kstarslite/skyitems/skyitem.cpp
@@ -14,9 +14,7 @@
* *
***************************************************************************/
#include "skyitem.h"
-#include "../../skymaplite.h"
#include "rootnode.h"
-#include "skynodes/skynode.h"
SkyItem::SkyItem(LabelsItem::label_t labelType, RootNode* parent)
:m_rootNode(parent), m_labelType(labelType)
@@ -29,23 +27,6 @@ SkyItem::~SkyItem() {
}
void SkyItem::hide() {
- if(opacity()) {
- setOpacity(0);
- markDirty(QSGNode::DirtyOpacity);
- }
+ SkyOpacityNode::hide();
rootNode()->labelsItem()->hideLabels(labelType());
}
-
-void SkyItem::show() {
- if(!opacity()) {
- setOpacity(1);
- markDirty(QSGNode::DirtyOpacity);
- }
-}
-
-bool SkyItem::visible() {
- if(opacity() != 0) {
- return true;
- }
- return false;
-}
diff --git a/kstars/kstarslite/skyitems/skyitem.h b/kstars/kstarslite/skyitems/skyitem.h
index 3420a6b..1e60d60 100644
--- a/kstars/kstarslite/skyitems/skyitem.h
+++ b/kstars/kstarslite/skyitems/skyitem.h
@@ -17,7 +17,7 @@
#ifndef SKYITEM_H_
#define SKYITEM_H_
-#include <QSGOpacityNode>
+#include "skyopacitynode.h"
#include "labelsitem.h"
class SkyComponent;
@@ -37,7 +37,7 @@ class SkyNode;
*@version 1.0
*/
-class SkyItem : public QSGOpacityNode {
+class SkyItem : public SkyOpacityNode {
public:
/**
@@ -59,16 +59,11 @@ public:
virtual void update() =0;
/**
- * @short hides this item by setting its opacity to 0
+ * @short hides this item and corresponding labels
*/
void hide();
/**
- * @short shows this item by setting its opacity to 1
- */
- void show();
-
- /**
* @return RootNode that is the parent of this SkyItem in a node tree
*/
@@ -80,12 +75,6 @@ public:
inline LabelsItem::label_t labelType() { return m_labelType; }
- /**
- * @return false if opacity is 0 otherwise true
- */
-
- bool visible();
-
private:
RootNode *m_rootNode;
QVector<SkyNode *>m_skyNodes;
diff --git a/kstars/kstarslite/skyitems/skynodes/labelnode.cpp b/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
index f2eccc2..d3f0494 100644
--- a/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
@@ -22,31 +22,21 @@
#include "labelnode.h"
LabelNode::LabelNode(SkyObject * skyObject, LabelsItem::label_t type)
- :SkyNode(skyObject), m_name(skyObject->name()), m_textTexture(new QSGSimpleTextureNode),
+ :SkyNode(skyObject), m_name(skyObject->labelString()), m_textTexture(new QSGSimpleTextureNode),
m_zoomFont(false), m_labelType(type), m_fontSize(0)
{
- switch(type) {
- case LabelsItem::label_t::PLANET_LABEL:
- case LabelsItem::label_t::SATURN_MOON_LABEL:
- case LabelsItem::label_t::JUPITER_MOON_LABEL:
- case LabelsItem::label_t::COMET_LABEL:
- case LabelsItem::label_t::RUDE_LABEL:
- case LabelsItem::label_t::ASTEROID_LABEL:
- m_zoomFont = true;
- break;
- default:
- break;
- }
-
- createTexture();
- m_opacity->appendChildNode(m_textTexture);
-
+ initialize();
}
LabelNode::LabelNode(QString name, LabelsItem::label_t type)
- :m_name(name), m_textTexture(new QSGSimpleTextureNode), m_labelType(type), m_zoomFont(false)
+ :m_name(name), m_textTexture(new QSGSimpleTextureNode), m_labelType(type), m_zoomFont(false),
+ m_fontSize(0)
{
- switch(type) {
+ initialize();
+}
+
+void LabelNode::initialize() {
+ switch(m_labelType) {
case LabelsItem::label_t::PLANET_LABEL:
case LabelsItem::label_t::SATURN_MOON_LABEL:
case LabelsItem::label_t::JUPITER_MOON_LABEL:
@@ -89,6 +79,9 @@ void LabelNode::createTexture() {
case LabelsItem::label_t::CONSTEL_NAME_LABEL:
color = KStarsData::Instance()->colorScheme()->colorNamed( "CNameColor" );
break;
+ case LabelsItem::label_t::STAR_LABEL:
+ color = KStarsData::Instance()->colorScheme()->colorNamed( "SNameColor" );
+ break;
default:
color = KStarsData::Instance()->colorScheme()->colorNamed( "UserLabelColor" );
}
@@ -127,14 +120,16 @@ void LabelNode::changePos(QPointF pos) {
void LabelNode::setLabelPos(QPointF pos) {
show();
+
//We need to subtract the height of texture from final y to follow the way QPainter draws the text
if(m_skyObject) labelPos = QPointF(pos.x() + m_skyObject->labelOffset(), pos.y() + m_skyObject->labelOffset() - m_textSize.height());
- else labelPos = QPointF(pos.x()-(m_textSize.width()/2.0), pos.y());//QPointF(pos.x()-(m_textSize.width()/2.0), pos.y() + m_textSize.height());
+ else labelPos = QPointF(pos.x()-(m_textSize.width()/2.0), pos.y());
}
void LabelNode::update() {
if(m_zoomFont && m_fontSize != SkyLabeler::Instance()->skyFont().pointSize()) {
createTexture();
}
+
changePos(labelPos);
}
diff --git a/kstars/kstarslite/skyitems/skynodes/labelnode.h b/kstars/kstarslite/skyitems/skynodes/labelnode.h
index c5642b7..5f55c33 100644
--- a/kstars/kstarslite/skyitems/skynodes/labelnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/labelnode.h
@@ -46,8 +46,12 @@ public:
* @param size initial size of PointNode
*/
LabelNode(SkyObject * skyObject, LabelsItem::label_t type);
+
+ /** does the same as above function but with QString instead of skyObject **/
LabelNode(QString name, LabelsItem::label_t type);
+ void initialize();
+
/**
* @short changePos changes the position m_point
* @param pos new position
@@ -78,9 +82,9 @@ private:
QSGSimpleTextureNode *m_textTexture;
QSize m_textSize;
+ LabelsItem::label_t m_labelType;
int m_fontSize;
bool m_zoomFont;
- LabelsItem::label_t m_labelType;
};
#endif
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
index 00ac120..a56a0e4 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
@@ -16,7 +16,6 @@
#include "linenode.h"
#include <QSGFlatColorMaterial>
-#include <QSGVertexColorMaterial>
#include "skymaplite.h"
#include "projections/projector.h"
@@ -26,18 +25,12 @@ LineNode::LineNode(LineList *lineList, QColor color, int width, Qt::PenStyle dra
:m_lineList(lineList), m_geometryNode(new QSGGeometryNode), m_color(color), m_drawStyle(drawStyle)
{
- if(m_drawStyle == Qt::DotLine) {
- m_material = new QSGVertexColorMaterial;
- m_geometry = new QSGGeometry(QSGGeometry::defaultAttributes_ColoredPoint2D(),0);
- m_geometryNode->setMaterial(m_material);
- } else {
- 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_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);
setWidth(width);
@@ -49,9 +42,8 @@ LineNode::LineNode(LineList *lineList, QColor color, int width, Qt::PenStyle dra
}
void LineNode::setColor(QColor color) {
- //m_material->setColor(color);
+ m_material->setColor(color);
m_color = color;
-
m_geometryNode->markDirty(QSGNode::DirtyMaterial);
}
@@ -70,16 +62,6 @@ void LineNode::setStyle(QColor color, int width, Qt::PenStyle drawStyle) {
setDrawStyle(drawStyle);
}
-void LineNode::hide() {
- setOpacity(0);
- markDirty(QSGNode::DirtyOpacity);
-}
-
-void LineNode::show() {
- setOpacity(1);
- markDirty(QSGNode::DirtyOpacity);
-}
-
void LineNode::updateGeometry() {
SkyList *points = m_lineList->points();
@@ -122,30 +104,15 @@ void LineNode::updateGeometry() {
int size = newPoints.size();
m_geometry->allocate(size);
- if(m_drawStyle == Qt::DotLine) {
-
- QSGGeometry::ColoredPoint2D *vertex = m_geometry->vertexDataAsColoredPoint2D();
- QLinkedList<QPointF>::const_iterator i = newPoints.constBegin();
- int c = 0;
- int dot = 0;
- while ( i != newPoints.constEnd()) {
- //vertex[c].set((*i).x(), (*i).y(), m_color.red(), m_color.blue(), m_color.green(), 255);
- vertex[c].set((*i).x(), (*i).y(), m_color.red(), m_color.green(), m_color.blue(), 0);
- c++;
- i++;
- }
- } else {
+ QSGGeometry::Point2D * vertex = m_geometry->vertexDataAsPoint2D();
- QSGGeometry::Point2D * vertex = m_geometry->vertexDataAsPoint2D();
-
- QLinkedList<QPointF>::const_iterator i = newPoints.constBegin();
- int c = 0;
- while ( i != newPoints.constEnd()) {
- vertex[c].x = (*i).x();
- vertex[c].y = (*i).y();
- c++;
- i++;
- }
+ QLinkedList<QPointF>::const_iterator i = newPoints.constBegin();
+ int c = 0;
+ while ( i != newPoints.constEnd()) {
+ vertex[c].x = (*i).x();
+ vertex[c].y = (*i).y();
+ c++;
+ i++;
}
m_geometryNode->markDirty(QSGNode::DirtyGeometry);
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
index a0375f0..0391330 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h
@@ -18,10 +18,10 @@
#include <QSGGeometryNode>
#include "linelist.h"
#include <QColor>
+#include "../../skyopacitynode.h"
-class PlanetItemNode;
-class SkyMapLite;
class QSGFlatColorMaterial;
+class SkyMapLite;
/** @class LineNode
*
@@ -33,7 +33,7 @@ class QSGFlatColorMaterial;
*@version 1.0
*/
-class LineNode : public QSGOpacityNode {
+class LineNode : public SkyOpacityNode {
public:
/**
* @short Constructor
@@ -55,14 +55,13 @@ public:
void updateGeometry();
inline LineList *lineList() { return m_lineList; }
- void hide();
- void show();
-
private:
QSGGeometryNode *m_geometryNode;
LineList *m_lineList;
+
QSGGeometry *m_geometry;
- QSGMaterial *m_material;
+ QSGFlatColorMaterial *m_material;
+
Qt::PenStyle m_drawStyle;
QColor m_color;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
index 3c94527..03a6d9a 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.cpp
@@ -39,17 +39,3 @@ void PointNode::setSize(float size) {
m_size = size;
}
}
-
-void PointNode::show() {
- if(!opacity()) {
- setOpacity(1);
- markDirty(QSGNode::DirtyOpacity);
- }
-}
-
-void PointNode::hide() {
- if(opacity()) {
- setOpacity(0);
- markDirty(QSGNode::DirtyOpacity);
- }
-}
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
index f1ced54..5999126 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/pointnode.h
@@ -16,6 +16,7 @@
#ifndef POINTNODE_H_
#define POINTNODE_H_
#include <QSGSimpleTextureNode>
+#include "../../skyopacitynode.h"
class PlanetItemNode;
class SkyMapLite;
@@ -32,7 +33,7 @@ class SkyMapLite;
class RootNode;
-class PointNode : public QSGOpacityNode {
+class PointNode : public SkyOpacityNode {
public:
/**
* @short Constructor
@@ -48,9 +49,6 @@ public:
void setSize(float size);
inline QSizeF size() const { return texture->rect().size(); }
-
- void show();
- void hide();
private:
char spType;
QSGSimpleTextureNode *texture;
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
index b3738ff..5176bdc 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.cpp
@@ -109,18 +109,3 @@ void PolyNode::updateGeometry(QPolygonF polygon, bool filled) {
m_geometryNode->markDirty(QSGNode::DirtyGeometry);
}
-
-void PolyNode::show() {
- if(!opacity()) {
- setOpacity(1);
- markDirty(QSGNode::DirtyOpacity);
- }
-}
-
-void PolyNode::hide() {
- if(opacity()) {
- setOpacity(0);
- markDirty(QSGNode::DirtyOpacity);
- }
-}
-
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
index 0be2d91..6c1dcd3 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/polynode.h
@@ -15,7 +15,7 @@
***************************************************************************/
#ifndef POLYNODE_H_
#define POLYNODE_H_
-#include <QSGOpacityNode>
+#include "../../skyopacitynode.h"
/** @class PolyNode
*
@@ -31,7 +31,7 @@ class QSGGeometryNode;
class QSGGeometry;
class QSGFlatColorMaterial;
-class PolyNode : public QSGOpacityNode {
+class PolyNode : public SkyOpacityNode {
public:
PolyNode();
@@ -39,9 +39,6 @@ public:
void setLineWidth(int width);
void updateGeometry(QPolygonF polygon, bool filled);
-
- void show();
- void hide();
private:
QSGGeometryNode *m_geometryNode;
QSGGeometry *m_geometry;
diff --git a/kstars/kstarslite/skyitems/skynodes/planetnode.cpp b/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
index ac5aaec..cf2d682 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/planetnode.cpp
@@ -30,7 +30,7 @@
#include "labelnode.h"
PlanetNode::PlanetNode(KSPlanetBase* pb, RootNode* parentNode)
- :SkyNode(pb), m_planetPic(new QSGSimpleTextureNode), m_planetOpacity(new QSGOpacityNode)
+ :SkyNode(pb), m_planetPic(new QSGSimpleTextureNode), m_planetOpacity(new SkyOpacityNode)
{
// Draw them as bright stars of appropriate color instead of images
char spType;
@@ -120,26 +120,17 @@ void PlanetNode::setPlanetPicSize(float size) {
}
void PlanetNode::showPoint() {
- if(m_planetOpacity->opacity()) {
- m_planetOpacity->setOpacity(0);
- m_planetOpacity->markDirty(QSGNode::DirtyOpacity);
- }
+ m_planetOpacity->hide();
m_point->show();
}
void PlanetNode::showPlanetPic() {
- if(!m_planetOpacity->opacity()) {
- m_planetOpacity->setOpacity(1);
- m_planetOpacity->markDirty(QSGNode::DirtyOpacity);
- }
+ m_planetOpacity->show();
m_point->hide();
}
void PlanetNode::hide() {
- if(m_planetOpacity->opacity()) {
- m_planetOpacity->setOpacity(0);
- m_planetOpacity->markDirty(QSGNode::DirtyOpacity);
- }
+ m_planetOpacity->hide();
m_point->hide();
m_label->hide();
}
diff --git a/kstars/kstarslite/skyitems/skynodes/planetnode.h b/kstars/kstarslite/skyitems/skynodes/planetnode.h
index ade3b62..7f09827 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/planetnode.h
@@ -16,6 +16,7 @@
#ifndef PLANETNODE_H_
#define PLANETNODE_H_
#include "skynode.h"
+#include "../skyopacitynode.h"
class QSGSimpleTextureNode;
class QImage;
@@ -78,7 +79,7 @@ private:
// This opacity node is used to hide m_planetPic. m_point is subclass of QSGOpacityNode so it needs
// no explicit opacity node here.
- QSGOpacityNode *m_planetOpacity;
+ SkyOpacityNode *m_planetOpacity;
QSGSimpleTextureNode *m_planetPic;
LabelNode *m_label;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
index 3936548..b75a108 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.cpp
@@ -26,11 +26,11 @@
#include "labelnode.h"
PointSourceNode::PointSourceNode(SkyObject * skyObject, RootNode * parentNode,
- LabelsItem::label_t labelType, char spType, float size)
+ 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
- m_label(0), m_labelType(labelType), m_rootNode(parentNode)
+ m_label(0), m_labelType(labelType), m_rootNode(parentNode), m_trixel(trixel)
{
- m_point = new PointNode(parentNode,starWidth(size),spType);
+ m_point = new PointNode(parentNode,spType,starWidth(size));
appendChildNode(m_point);
}
@@ -79,7 +79,11 @@ void PointSourceNode::update() {
if(m_drawLabel) {
if(!m_label) { //This way labels will be created only when they are needed
- m_label = m_rootNode->labelsItem()->addLabel(m_skyObject, m_labelType);
+ if(m_trixel != -1) {
+ m_label = m_rootNode->labelsItem()->addLabel(m_skyObject, m_labelType, m_trixel);
+ } else {
+ m_label = m_rootNode->labelsItem()->addLabel(m_skyObject, m_labelType);
+ }
}
m_label->setLabelPos(pos);
} else {
@@ -93,11 +97,6 @@ void PointSourceNode::update() {
}
-/*void PointSourceNode::updateLabel() {
- if(!m_label) m_label = m_rootNode->labelsItem()->addLabel(skyObject, labelType);
- m_label->setLabelPos(pos);
-}*/
-
void PointSourceNode::hide() {
if(m_label) m_label->hide();
m_point->hide();
diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
index 7a0488f..deb5f76 100644
--- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
+++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h
@@ -44,7 +44,7 @@ public:
* @param size initial size of PointNode
*/
PointSourceNode(SkyObject * skyObject, RootNode * parentNode,
- LabelsItem::label_t labelType = LabelsItem::label_t::STAR_LABEL, char spType = 'A', float size = 1);
+ LabelsItem::label_t labelType = LabelsItem::label_t::STAR_LABEL, char spType = 'A', float size = 1, short trixel = -1);
/** @short Get the width of a star of magnitude mag */
float starWidth(float mag) const;
@@ -55,6 +55,8 @@ public:
*/
virtual void changePos(QPointF pos) override;
+ void setSizeMagLim(float sizeMagLim) { m_sizeMagLim = sizeMagLim; }
+
virtual void update() override;
virtual void hide() override;
private:
@@ -66,6 +68,9 @@ private:
LabelNode *m_label;
LabelsItem::label_t m_labelType;
+ short m_trixel; //Trixel to which this object belongs. Used only in stars. By default -1 for all
+ //other objects that are not indexed by SkyMesh
+
QPointF pos;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.cpp b/kstars/kstarslite/skyitems/skynodes/skynode.cpp
index 1d24aeb..8ee1ccc 100644
--- a/kstars/kstarslite/skyitems/skynodes/skynode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/skynode.cpp
@@ -18,13 +18,13 @@
#include "skynode.h"
SkyNode::SkyNode(SkyObject * skyObject)
- :m_skyObject(skyObject), m_opacity(new QSGOpacityNode), m_drawLabel(false)
+ :m_skyObject(skyObject), m_opacity(new SkyOpacityNode), m_drawLabel(false)
{
appendChildNode(m_opacity);
}
SkyNode::SkyNode()
- :m_skyObject(nullptr), m_opacity(new QSGOpacityNode), m_drawLabel(false)
+ :m_skyObject(nullptr), m_opacity(new SkyOpacityNode), m_drawLabel(false)
{
appendChildNode(m_opacity);
}
@@ -33,24 +33,3 @@ void SkyNode::update(bool drawLabel) {
m_drawLabel = drawLabel;
update();
}
-
-void SkyNode::hide() {
- if(m_opacity->opacity()) {
- m_opacity->setOpacity(0);
- m_opacity->markDirty(QSGNode::DirtyOpacity);
- }
-}
-
-void SkyNode::show() {
- if(!m_opacity->opacity()) {
- m_opacity->setOpacity(1);
- m_opacity->markDirty(QSGNode::DirtyOpacity);
- }
-}
-
-bool SkyNode::visible() {
- if(m_opacity->opacity() != 0) {
- return true;
- }
- return false;
-}
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.h b/kstars/kstarslite/skyitems/skynodes/skynode.h
index 91f4803..9476f0a 100644
--- a/kstars/kstarslite/skyitems/skynodes/skynode.h
+++ b/kstars/kstarslite/skyitems/skynodes/skynode.h
@@ -15,10 +15,13 @@
***************************************************************************/
#ifndef SKYNODE_H_
#define SKYNODE_H_
+
#include <QSGTransformNode>
#include "skymaplite.h"
#include "projections/projector.h"
+#include "../skyopacitynode.h"
+
class Projector;
class SkyMapLite;
@@ -70,12 +73,12 @@ public:
/**
* @short hides all child nodes (sets opacity of m_opacity to 0)
*/
- virtual void hide();
+ inline virtual void hide() { m_opacity->hide(); }
/**
* @short shows all child nodes (sets opacity of m_opacity to 1)
*/
- virtual void show();
+ inline virtual void show() { m_opacity->show(); }
/**
* @short changes the position of SkyNode on SkyMapLite. Has to be overriden by the classes
@@ -87,7 +90,7 @@ public:
/**
* @return true if object is visible (m_opacity->opacity() != 0) else returns false
*/
- bool visible();
+ inline bool visible() { return m_opacity->visible(); }
/**
* @short returns SkyObject associated with this SkyNode
@@ -96,7 +99,7 @@ public:
SkyObject * skyObject() const { return m_skyObject; }
protected:
SkyObject * m_skyObject;
- QSGOpacityNode *m_opacity;
+ SkyOpacityNode *m_opacity;
bool m_drawLabel;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp b/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp
deleted file mode 100644
index 88c788a..0000000
--- a/kstars/kstarslite/skyitems/skynodes/trixelnode.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/** *************************************************************************
- TrixelNode.cpp - K Desktop Planetarium
- -------------------
- begin : 16/05/2016
- copyright : (C) 2016 by Artem Fedoskin
- email : afedoskin3@gmail.com
- ***************************************************************************/
-/** *************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <QImage>
-#include <QQuickWindow>
-
-#include "kstarsdata.h"
-#include "trixelnode.h"
-#include "skyobject.h"
-#include "nodes/linenode.h"
-#include "Options.h"
-#include "skymesh.h"
-#include <QSGOpacityNode>
-
-TrixelNode::TrixelNode(Trixel trixelId, LineListList *linesList, QString color, int width, Qt::PenStyle style)
- :SkyNode(), trixel(trixelId), m_linesLists(linesList), m_opacity(new QSGOpacityNode)
-{
- appendChildNode(m_opacity);
- QColor c = KStarsData::Instance()->colorScheme()->colorNamed(color);
- for(int i = 0; i < m_linesLists->size(); ++i) {
- LineNode * ln = new LineNode(m_linesLists->at(i), c, width, style);
- m_opacity->appendChildNode(ln);
- }
-}
-
-void TrixelNode::setStyle(QString color, int width, Qt::PenStyle style) {
- QSGNode *n = m_opacity->firstChild();
- while(n != 0) {
- LineNode *ln = static_cast<LineNode *>(n);
- ln->setStyle(KStarsData::Instance()->colorScheme()->colorNamed( color ), width, style);
- n = n->nextSibling();
- }
-}
-
-void TrixelNode::update() {
- show();
- DrawID drawID = SkyMesh::Instance()->drawID();
- //UpdateID updateID = KStarsData::Instance()->updateID();
- //for(int i = 0; i < m_opacity->childCount(); ++i) {
- QSGNode *n = m_opacity->firstChild();
- while(n != 0) {
- LineNode * lines = static_cast<LineNode *>(n);
- n = n->nextSibling();
-
- LineList * lineList = lines->lineList();
- if ( lineList->drawID == drawID ) {
- lines->hide();
- continue;
- }
- lineList->drawID = drawID;
- lines->updateGeometry();
- }
-}
diff --git a/kstars/kstarslite/skyitems/skynodes/trixelnode.h b/kstars/kstarslite/skyitems/skynodes/trixelnode.h
deleted file mode 100644
index 3f1a774..0000000
--- a/kstars/kstarslite/skyitems/skynodes/trixelnode.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/** *************************************************************************
- trixelnode.h - K Desktop Planetarium
- -------------------
- begin : 16/05/2016
- copyright : (C) 2016 by Artem Fedoskin
- email : afedoskin3@gmail.com
- ***************************************************************************/
-/** *************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#ifndef TRIXELNODE_H_
-#define TRIXELNODE_H_
-#include <QSGSimpleTextureNode>
-#include "skynode.h"
-#include "linelist.h"
-
-class PlanetItemNode;
-class SkyMapLite;
-class LineNode;
-class QSGOpacityNode;
-
-/** @class TrixelNode
- *
- * 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 TrixelNode : 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
- */
- TrixelNode(Trixel trixel, LineListList *lineIndex, QString color, int width, Qt::PenStyle style);
-
- void setStyle(QString color, int width, Qt::PenStyle style);
-
- virtual void changePos(QPointF pos) {}
- virtual void update() override;
-private:
- QSGOpacityNode *m_opacity;
- Trixel trixel;
- LineListList *m_linesLists;
-};
-
-#endif
-
-
diff --git a/kstars/kstarslite/skyitems/skyopacitynode.cpp b/kstars/kstarslite/skyitems/skyopacitynode.cpp
new file mode 100644
index 0000000..8582077
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skyopacitynode.cpp
@@ -0,0 +1,42 @@
+/** *************************************************************************
+ skyopacitynode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 16/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 "skyopacitynode.h"
+
+SkyOpacityNode::SkyOpacityNode() {
+
+}
+
+void SkyOpacityNode::show() {
+ if(!opacity()) {
+ setOpacity(1);
+ markDirty(QSGNode::DirtyOpacity);
+ }
+}
+
+void SkyOpacityNode::hide() {
+ if(opacity()) {
+ setOpacity(0);
+ markDirty(QSGNode::DirtyOpacity);
+ }
+}
+
+bool SkyOpacityNode::visible() {
+ if(opacity() != 0) {
+ return true;
+ }
+ return false;
+}
diff --git a/kstars/kstarslite/skyitems/skyopacitynode.h b/kstars/kstarslite/skyitems/skyopacitynode.h
new file mode 100644
index 0000000..e121470
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skyopacitynode.h
@@ -0,0 +1,50 @@
+/** *************************************************************************
+ skyopacitynode.h - K Desktop Planetarium
+ -------------------
+ begin : 16/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 SKYOPACITYNODE_H_
+#define SKYOPACITYNODE_H_
+
+#include <QSGOpacityNode>
+
+/** @class SkyOpacityNode
+ *
+ *@short A wrapper for QSGOpacityNode that provides hide() and show() functions. If node is invisible
+ * (opacity is 0) it won't be rendered.
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class SkyOpacityNode : public QSGOpacityNode {
+public:
+ SkyOpacityNode();
+
+ /**
+ * @short makes this node visible
+ */
+ void show();
+
+ /**
+ * @short hides this node
+ */
+ void hide();
+
+ /**
+ * @return true if node is visible
+ */
+ bool visible();
+};
+
+#endif
diff --git a/kstars/kstarslite/skyitems/staritem.cpp b/kstars/kstarslite/skyitems/staritem.cpp
new file mode 100644
index 0000000..4514a54
--- /dev/null
+++ b/kstars/kstarslite/skyitems/staritem.cpp
@@ -0,0 +1,198 @@
+/** *************************************************************************
+ staritem.cpp - K Desktop Planetarium
+ -------------------
+ begin : 15/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/pointsourcenode.h"
+#include "labelsitem.h"
+#include "staritem.h"
+
+#include "starcomponent.h"
+#include "starblockfactory.h"
+#include "skymesh.h"
+#include "rootnode.h"
+
+StarItem::StarItem(StarComponent *starComp, RootNode *rootNode)
+ :SkyItem(LabelsItem::label_t::STAR_LABEL, rootNode), m_starComp(starComp)
+ ,m_starLabels(rootNode->labelsItem()->getLabelNode(labelType()))
+{
+ StarIndex *trixels = m_starComp->starIndex();
+
+ //Test
+ Options::setShowStarMagnitudes(false);
+ Options::setShowStarNames(true);
+
+ for(int i = 0; i < trixels->size(); ++i) {
+ StarList *skyList = trixels->at(i);
+ TrixelNode *trixel = new TrixelNode;
+ appendChildNode(trixel);
+
+ for(int c = 0; c < skyList->size(); ++c) {
+ StarObject *star = skyList->at(c);
+ if(star) {
+ PointSourceNode *point = new PointSourceNode(star, rootNode, LabelsItem::label_t::STAR_LABEL, star->spchar(),
+ star->mag(), i);
+ trixel->appendChildNode(point);
+ }
+ }
+ }
+
+ m_skyMesh = SkyMesh::Instance();
+ m_StarBlockFactory = StarBlockFactory::Instance();
+}
+
+void StarItem::update() {
+
+ if( !m_starComp->selected() ) {
+ hide();
+ return;
+ }
+
+ SkyMapLite *map = SkyMapLite::Instance();
+ const Projector *proj = map->projector();
+ KStarsData* data = KStarsData::Instance();
+ UpdateID updateID = data->updateID();
+
+ bool checkSlewing = ( map->isSlewing() && Options::hideOnSlew() );
+ bool hideLabels = checkSlewing || !( Options::showStarMagnitudes() || Options::showStarNames() );
+
+ //shortcuts to inform whether to draw different objects
+ bool hideFaintStars = checkSlewing && Options::hideStars();
+ double hideStarsMag = Options::magLimitHideStar();
+ m_starComp->reindex( data->updateNum() );
+
+ double lgmin = log10(MINZOOM);
+ double lgmax = log10(MAXZOOM);
+ double lgz = log10(Options::zoomFactor());
+
+ double maglim;
+ double m_zoomMagLimit; //Check it later. Needed for labels
+ m_zoomMagLimit = maglim = m_starComp->zoomMagnitudeLimit();
+
+ double labelMagLim = Options::starLabelDensity() / 5.0;
+ labelMagLim += ( 12.0 - labelMagLim ) * ( lgz - lgmin) / (lgmax - lgmin );
+ if( labelMagLim > 8.0 )
+ labelMagLim = 8.0;
+
+ //Calculate sizeMagLim
+ // Old formula:
+ // float sizeMagLim = ( 2.000 + 2.444 * Options::memUsage() / 10.0 ) * ( lgz - lgmin ) + 5.8;
+
+ // Using the maglim to compute the sizes of stars reduces
+ // discernability between brighter and fainter stars at high zoom
+ // levels. To fix that, we use an "arbitrary" constant in place of
+ // the variable star density.
+ // Not using this formula now.
+ // float sizeMagLim = 4.444 * ( lgz - lgmin ) + 5.0;
+
+ /*float sizeMagLim = zoomMagnitudeLimit();
+ if( sizeMagLim > faintMagnitude() * ( 1 - 1.5/16 ) )
+ sizeMagLim = faintMagnitude() * ( 1 - 1.5/16 );
+ skyp->setSizeMagLimit(sizeMagLim);*/
+
+ //Loop for drawing star images
+
+ MeshIterator region(m_skyMesh, DRAW_BUF);
+
+ // If we are hiding faint stars, then maglim is really the brighter of hideStarsMag and maglim
+ if( hideFaintStars && maglim > hideStarsMag )
+ maglim = hideStarsMag;
+
+ m_magLim = maglim;
+
+ m_StarBlockFactory->drawID = m_skyMesh->drawID();
+
+ int nTrixels = 0;
+
+ int regionID = -1;
+ if(region.hasNext()) {
+ regionID = region.next();
+ }
+
+ int trixelID = 0;
+ //++nTrixels;
+ QSGNode *firstTrixel = firstChild();
+ TrixelNode *trixel = static_cast<TrixelNode *>(firstTrixel);
+
+ QSGNode *firstLabel = m_starLabels->firstChild();
+ TrixelNode *label = static_cast<TrixelNode *>(firstLabel);
+
+ while( trixel != 0 ) {
+ 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();
+
+ if(region.hasNext()) {
+ regionID = region.next();
+ }
+ }
+
+ QSGNode *n = trixel->firstChild();
+
+ while(n != 0) {
+ PointSourceNode *point = static_cast<PointSourceNode *>(n);
+ n = n->nextSibling();
+
+ StarObject *curStar = static_cast<StarObject *>(point->skyObject());
+ float mag = curStar->mag();
+
+ bool hide = false;
+
+ // break loop if maglim is reached
+ if ( mag > m_magLim ) hide = true;
+ bool drawLabel = false;
+ if(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();
+ }
+ }
+ trixel = static_cast<TrixelNode *>(trixel->nextSibling());
+ label = static_cast<TrixelNode *>(label->nextSibling());
+
+ trixelID++;
+ }
+
+ // Draw focusStar if not null
+ /*if( focusStar ) {
+ if ( focusStar->updateID != updateID )
+ focusStar->JITupdate();
+ float mag = focusStar->mag();
+ skyp->drawPointSource(focusStar, mag, focusStar->spchar() );
+ }*/
+
+ // Now draw each of our DeepStarComponents
+ /*for( int i =0; i < m_DeepStarComponents.size(); ++i ) {
+ m_DeepStarComponents.at( i )->draw( skyp );
+ }*/
+}
+
diff --git a/kstars/kstarslite/skyitems/staritem.h b/kstars/kstarslite/skyitems/staritem.h
new file mode 100644
index 0000000..831d0df
--- /dev/null
+++ b/kstars/kstarslite/skyitems/staritem.h
@@ -0,0 +1,56 @@
+/** *************************************************************************
+ staritem.h - K Desktop Planetarium
+ -------------------
+ begin : 15/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 STARITEM_H_
+#define STARITEM_H_
+
+#include "skyitem.h"
+#include "skyopacitynode.h"
+#include "typedeflite.h"
+
+ /** @class StarItem
+ *
+ *@short Class that handles Stars
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class StarComponent;
+class SkyMesh;
+class StarBlockFactory;
+
+class StarItem : public SkyItem {
+public:
+ /**
+ * @short Constructor.
+ * @param rootNode parent RootNode that instantiated this object
+ */
+ StarItem(StarComponent *starComp, RootNode *rootNode);
+
+ /**
+ * @short updates all trixels that contain stars
+ */
+ float m_magLim;
+ virtual void update();
+
+private:
+ StarComponent *m_starComp;
+ SkyMesh *m_skyMesh;
+ StarBlockFactory *m_StarBlockFactory;
+ SkyOpacityNode *m_starLabels;
+ //QMap<QSGOpacityNode *,LineListIndex *> m_lineIndexes;
+};
+#endif
+
diff --git a/kstars/kstarslite/skyitems/typedeflite.h b/kstars/kstarslite/skyitems/typedeflite.h
new file mode 100644
index 0000000..6a74965
--- /dev/null
+++ b/kstars/kstarslite/skyitems/typedeflite.h
@@ -0,0 +1,10 @@
+#ifndef TYPEDEFLITE_H_
+#define TYPEDEFLITE_H_
+
+class SkyOpacityNode;
+
+typedef SkyOpacityNode LabelTypeNode;
+typedef SkyOpacityNode TrixelNode;
+typedef SkyOpacityNode LineIndexNode;
+
+#endif
diff --git a/kstars/main.cpp b/kstars/main.cpp
index ec83645..1e20793 100644
--- a/kstars/main.cpp
+++ b/kstars/main.cpp
@@ -56,6 +56,10 @@ int main(int argc, char *argv[])
* enable high dpi support
*/
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
+
+ QByteArray data = "1";
+ //qputenv("QSG_RENDER_TIMING", data);
+
#ifndef KSTARS_LITE
KCrash::initialize();
KLocalizedString::setApplicationDomain("kstars");
@@ -225,7 +229,6 @@ int main(int argc, char *argv[])
}
#endif
-
//Under construction
//[Location]
Options::setCityName("Saarbr├╝cken");
@@ -236,12 +239,12 @@ int main(int argc, char *argv[])
Options::setTimeZone(1);
Options::setRunClock(false);
- Options::setShowCBounds(true);
+ Options::setShowCBounds(false);
Options::setShowCLines(true);
Options::setShowSolarSystem(true);
Options::setShowEcliptic(true);
Options::setShowEquator(true);
- Options::setShowEquatorialGrid(true);
+ Options::setShowEquatorialGrid(false);
Options::setShowHorizontalGrid(true);
Options::setShowGround(true);
@@ -258,7 +261,6 @@ int main(int argc, char *argv[])
Options::setHideOnSlew(true);
Options::setHideGrids(false);
-
// Create writable data dir if it does not exist
QDir writableDir;
writableDir.mkdir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
diff --git a/kstars/skycomponents/skymapcomposite.h b/kstars/skycomponents/skymapcomposite.h
index 748a1e6..45bdb72 100644
--- a/kstars/skycomponents/skymapcomposite.h
+++ b/kstars/skycomponents/skymapcomposite.h
@@ -190,6 +190,7 @@ public:
//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/starcomponent.cpp b/kstars/skycomponents/starcomponent.cpp
index 03cfee1..6478e72 100644
--- a/kstars/skycomponents/starcomponent.cpp
+++ b/kstars/skycomponents/starcomponent.cpp
@@ -76,9 +76,7 @@ StarComponent::StarComponent(SkyComposite *parent )
loadStaticData();
// Load any deep star catalogs that are available
loadDeepStarCatalogs();
-#ifdef KSTARS_LITE
- //SkyMapLite::Instance()->initStarImages();
-#else
+#ifndef KSTARS_LITE
SkyQPainter::initStarImages();
#endif
}
diff --git a/kstars/skycomponents/starcomponent.h b/kstars/skycomponents/starcomponent.h
index ebe7fb6..c626b96 100644
--- a/kstars/skycomponents/starcomponent.h
+++ b/kstars/skycomponents/starcomponent.h
@@ -45,6 +45,7 @@
#include "binfilehelper.h"
#include "starblockfactory.h"
#include "skymesh.h"
+#include "kstarslite/skyitems/staritem.h"
class SkyMesh;
class StarObject;
@@ -58,12 +59,13 @@ class MeshIterator;
class StarComponent: public ListComponent
{
+ friend class StarItem; //Needs access to faintMagnitude() and reindex()
+
protected:
StarComponent( SkyComposite* );
public:
-
virtual ~StarComponent();
// TODO: Desingletonize StarComponent
@@ -91,6 +93,9 @@ 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)
*
@@ -130,7 +135,7 @@ public:
*@p center The center point of the aperture
*@p radius The radius around the center point that defines the
* aperture
- *@p maglim Optional parameter indicating the limiting magnitude.
+ *@p maglim Optional parameter indicating the limiting magnitude.
* If magnitude limit is numerically < -28, the limiting magnitude
* is assumed to be the limiting magnitude of the catalog (i.e. no
* magnitude limit)
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index 62e0fe3..a2e123b 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -125,6 +125,7 @@ QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
n->update();
}
+ ///DELETE
//Reset m_fontSizeChanged
setFontSizeChanged(false);
return n;