summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-06-15 16:51:12 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-06-15 16:51:12 (GMT)
commit923bdceb41d845f1aa28042e279594830414c7fd (patch)
tree8dc81cd687504382c83ae78e9c2e3556e7d8426f
parent8c675dc05d04bbae46615d16237111f6dd519d02 (diff)
Added support for zoom-dependent labels. Added comments to all SkyItems.
-rw-r--r--kstars/CMakeLists.txt2
-rw-r--r--kstars/kstarslite.cpp23
-rw-r--r--kstars/kstarslite.h5
-rw-r--r--kstars/kstarslite/skyitems/asteroidsitem.cpp4
-rw-r--r--kstars/kstarslite/skyitems/asteroidsitem.h30
-rw-r--r--kstars/kstarslite/skyitems/cometsitem.cpp4
-rw-r--r--kstars/kstarslite/skyitems/cometsitem.h31
-rw-r--r--kstars/kstarslite/skyitems/constellationnamesitem.cpp6
-rw-r--r--kstars/kstarslite/skyitems/constellationnamesitem.h38
-rw-r--r--kstars/kstarslite/skyitems/horizonitem.cpp69
-rw-r--r--kstars/kstarslite/skyitems/horizonitem.h23
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.cpp103
-rw-r--r--kstars/kstarslite/skyitems/labelsitem.h124
-rw-r--r--kstars/kstarslite/skyitems/lines/eclipticitem.cpp6
-rw-r--r--kstars/kstarslite/skyitems/lines/eclipticitem.h22
-rw-r--r--kstars/kstarslite/skyitems/lines/equatoritem.cpp11
-rw-r--r--kstars/kstarslite/skyitems/lines/equatoritem.h22
-rw-r--r--kstars/kstarslite/skyitems/lines/linesitem.cpp29
-rw-r--r--kstars/kstarslite/skyitems/lines/linesitem.h35
-rw-r--r--kstars/kstarslite/skyitems/planetsitem.h40
-rw-r--r--kstars/kstarslite/skyitems/rootnode.cpp18
-rw-r--r--kstars/kstarslite/skyitems/rootnode.h10
-rw-r--r--kstars/kstarslite/skyitems/skyitem.cpp1
-rw-r--r--kstars/kstarslite/skyitems/skyitem.h33
-rw-r--r--kstars/kstarslite/skyitems/skynodes/labelnode.cpp73
-rw-r--r--kstars/kstarslite/skyitems/skynodes/labelnode.h13
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp16
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h28
-rw-r--r--kstars/kstarslite/skyitems/skynodes/planetnode.h8
-rw-r--r--kstars/kstarslite/skyitems/skynodes/skynode.cpp4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/trixelnode.h4
-rw-r--r--kstars/main.cpp119
-rw-r--r--kstars/skycomponents/skylabeler.cpp55
-rw-r--r--kstars/skycomponents/skylabeler.h9
-rw-r--r--kstars/skymaplite.cpp39
-rw-r--r--kstars/skymaplite.h55
-rw-r--r--kstars/skymapliteevents.cpp (renamed from kstars/skymaplitevents.cpp)18
37 files changed, 739 insertions, 391 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 65a838d..9861e82 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -543,7 +543,7 @@ if(BUILD_KSTARS_LITE)
kstarslite.cpp
kstarsliteinit.cpp
skymaplite.cpp
- skymaplitevents.cpp
+ skymapliteevents.cpp
#RootNode
kstarslite/skyitems/rootnode.cpp
#SkyItems
diff --git a/kstars/kstarslite.cpp b/kstars/kstarslite.cpp
index 82508d5..8c3d644 100644
--- a/kstars/kstarslite.cpp
+++ b/kstars/kstarslite.cpp
@@ -189,3 +189,26 @@ void KStarsLite::slotAboutToQuit()
//synch the config file with the Config object
writeConfig();
}
+
+void KStarsLite::loadColorScheme( const QString &name ) {
+ bool ok = data()->colorScheme()->load( name );
+ QString filename = data()->colorScheme()->fileName();
+
+ if ( ok ) {
+ //set the application colors for the Night Vision scheme
+ if ( Options::darkAppColors() == false && filename == "night.colors" ) {
+ Options::setDarkAppColors( true );
+ OriginalPalette = QApplication::palette();
+ QApplication::setPalette( DarkPalette );
+ }
+
+ if ( Options::darkAppColors() && filename != "night.colors" ) {
+ Options::setDarkAppColors( false );
+ QApplication::setPalette( OriginalPalette );
+ }
+
+ Options::setColorSchemeFile( name );
+
+ map()->forceUpdate();
+ }
+}
diff --git a/kstars/kstarslite.h b/kstars/kstarslite.h
index 1e6ca9f..da66951 100644
--- a/kstars/kstarslite.h
+++ b/kstars/kstarslite.h
@@ -99,6 +99,11 @@ public Q_SLOTS:
*/
void writeConfig();
+ /** Load a color scheme.
+ * @param name the name of the color scheme to load (e.g., "Moonless Night")
+ */
+ void loadColorScheme( const QString &name );
+
private slots:
/** finish setting up after the KStarsData has finished
*/
diff --git a/kstars/kstarslite/skyitems/asteroidsitem.cpp b/kstars/kstarslite/skyitems/asteroidsitem.cpp
index 00fe6c6..a962723 100644
--- a/kstars/kstarslite/skyitems/asteroidsitem.cpp
+++ b/kstars/kstarslite/skyitems/asteroidsitem.cpp
@@ -33,7 +33,9 @@ AsteroidsItem::AsteroidsItem(const QList<SkyObject*>& asteroidsList, RootNode *r
}
void AsteroidsItem::recreateList() {
- removeAllChildNodes();
+ //Delete all child nodes
+ while(QSGNode *n = firstChild()) { removeChildNode(n); delete n; }
+
foreach(SkyObject *asteroid, m_asteroidsList) {
KSAsteroid *ast = static_cast<KSAsteroid *>(asteroid);
if (ast->image().isNull() == false) {
diff --git a/kstars/kstarslite/skyitems/asteroidsitem.h b/kstars/kstarslite/skyitems/asteroidsitem.h
index b980720..ddf6003 100644
--- a/kstars/kstarslite/skyitems/asteroidsitem.h
+++ b/kstars/kstarslite/skyitems/asteroidsitem.h
@@ -22,21 +22,33 @@ class KSAsteroid;
class SkyObject;
class RootNode;
+ /**
+ * @class AsteroidsItem
+ * This class handles asteroids in SkyMapLite
+ *
+ * @author Artem Fedoskin
+ * @version 1.0
+ */
+
class AsteroidsItem : public SkyItem {
public:
-
+ /**
+ * @short Constructor
+ * @param asteroidsList const reference to list of asteroids
+ * @param rootNode parent RootNode that instantiates PlanetsItem
+ */
AsteroidsItem(const QList<SkyObject*>& asteroidsList, RootNode *rootNode = 0);
- /** Adds an object of type KSAsteroid to m_toAdd. In the next call to
- * updatePaintNode() the object of type PlanetNode will be created and asteroid
- * will be moved to m_asteroids. PlanetNode represents graphically KSAsteroid on SkyMapLite.
- * This function should be called whenever an object of class KSAsteroid is created.
- *
- * @param KSAsteroid that should be displayed on SkyMapLite
+ /**
+ * @short recreates the node tree (deletes old nodes and appends new ones according to
+ * m_asteroidsList)
*/
- //void setAsteroidsList(QList<SkyObject*> *asteroidsList);
-
void recreateList();
+
+ /**
+ * @short Determines the visibility of the object and its label and hides/updates them accordingly
+ */
+
virtual void update() override;
private:
const QList<SkyObject*>& m_asteroidsList;
diff --git a/kstars/kstarslite/skyitems/cometsitem.cpp b/kstars/kstarslite/skyitems/cometsitem.cpp
index f5e5163..ed687e5 100644
--- a/kstars/kstarslite/skyitems/cometsitem.cpp
+++ b/kstars/kstarslite/skyitems/cometsitem.cpp
@@ -72,7 +72,9 @@ void CometsItem::update() {
}
void CometsItem::recreateList() {
- removeAllChildNodes();
+ //Delete all child nodes
+ while(QSGNode *n = firstChild()) { removeChildNode(n); delete n; }
+
foreach(SkyObject *comet, m_cometsList) {
KSComet *com = static_cast<KSComet *>(comet);
appendChildNode(new PointSourceNode(com, rootNode(),labelType()));
diff --git a/kstars/kstarslite/skyitems/cometsitem.h b/kstars/kstarslite/skyitems/cometsitem.h
index 8acaf94..d2bab30 100644
--- a/kstars/kstarslite/skyitems/cometsitem.h
+++ b/kstars/kstarslite/skyitems/cometsitem.h
@@ -21,21 +21,34 @@
class KSComet;
class SkyObject;
+ /**
+ * @class CometsItem
+ * This class handles comets in SkyMapLite
+ *
+ * @author Artem Fedoskin
+ * @version 1.0
+ */
+
class CometsItem : public SkyItem {
public:
+ /**
+ * @short Constructor
+ * @param cometsList const reference to list of comets
+ * @param rootNode parent RootNode that instantiates this object
+ */
CometsItem(const QList<SkyObject *>& cometsList, RootNode *rootNode = 0);
- /** Adds an object of type KSComet to m_toAdd. In the next call to
- * updatePaintNode() the object of type PointSourceNode will be created and comet
- * will be moved to m_comets. PointSourceNode represents graphically KSComet on SkyMapLite.
- * This function should be called whenever an object of class KSComet is
- * created.
- *
- * @param KSComet that should be displayed on SkyMapLite
+
+ /**
+ * @short recreates the node tree (deletes old nodes and appends new ones according to
+ * m_cometsList)
*/
- //void addComet(KSComet * comet);
+ void recreateList();
+ /**
+ * @short Determines the visibility of the object and its label and hides/updates them accordingly
+ */
virtual void update() override;
- void recreateList();
+
private:
const QList<SkyObject *>& m_cometsList;
};
diff --git a/kstars/kstarslite/skyitems/constellationnamesitem.cpp b/kstars/kstarslite/skyitems/constellationnamesitem.cpp
index d609665..da8b4ad 100644
--- a/kstars/kstarslite/skyitems/constellationnamesitem.cpp
+++ b/kstars/kstarslite/skyitems/constellationnamesitem.cpp
@@ -94,12 +94,12 @@ void ConstellationNamesItem::update() {
if(constName->latin) constName->latin->hide();
}
}
-
- //skyLabeler->resetFont();
}
void ConstellationNamesItem::recreateList() {
- removeAllChildNodes();
+ rootNode()->labelsItem()->deleteLabels(labelType());
+ m_names.clear();
+
foreach(SkyObject *skyObj, m_constelNamesComp->objectList()) {
m_names.append(new ConstellationName(skyObj));
}
diff --git a/kstars/kstarslite/skyitems/constellationnamesitem.h b/kstars/kstarslite/skyitems/constellationnamesitem.h
index 351b108..d433306 100644
--- a/kstars/kstarslite/skyitems/constellationnamesitem.h
+++ b/kstars/kstarslite/skyitems/constellationnamesitem.h
@@ -22,14 +22,9 @@
class ConstellationNamesComponent;
-/** @class SkyItem
- *
- *This is an interface for implementing SkyItems that are used to display SkyComponent
- *derived objects on the SkyMapLite.
- *
- *@short A base class that is used for displaying SkyComponents on SkyMapLite.
- *@author Artem Fedoskin
- *@version 1.0
+/**
+ * @short The ConstellationName struct. It holds SkyObject (coordinate of label) and 2 labels (latin and
+ * secondary names)
*/
struct ConstellationName {
@@ -39,22 +34,41 @@ struct ConstellationName {
LabelNode *latin;
LabelNode *secondary;
+ /**
+ * @short hides both latin and secondary labels
+ */
void hide();
};
-class ConstellationNamesItem : public SkyItem {
+/** @class ConstellationNamesItem
+ *
+ * This class handles representation of ConstellationNamesComponent in SkyMapLite
+ * @author Artem Fedoskin
+ * @version 1.0
+ */
+class ConstellationNamesItem : public SkyItem {
public:
/**
- *Constructor, add SkyItem to parent in a node tree
- *
+ * Constructor.
+ * @param constComp a pointer to ConstellationNamesComponent that this object has to represent in
+ * SkyMapLite
* @param parent a pointer to SkyItem's parent node
*/
-
explicit ConstellationNamesItem(ConstellationNamesComponent *constComp, RootNode *rootNode = 0);
+ /**
+ * Updates positions of labels of ConstellationName based on user settings and labels
+ * visibility. If the user chose latin names then label with secondary name won't be created until
+ * settings are not changed.
+ *
+ * @short updates positions of labels based on their visibility.
+ */
virtual void update();
+ /**
+ * @short deletes all labels and recreates m_names according to object list of m_constelNamesComp
+ */
void recreateList();
private:
ConstellationNamesComponent *m_constelNamesComp;
diff --git a/kstars/kstarslite/skyitems/horizonitem.cpp b/kstars/kstarslite/skyitems/horizonitem.cpp
index 23c3f4d..c51b8ae 100644
--- a/kstars/kstarslite/skyitems/horizonitem.cpp
+++ b/kstars/kstarslite/skyitems/horizonitem.cpp
@@ -54,16 +54,6 @@ HorizonItem::HorizonItem(HorizonComponent * hComp, RootNode *rootNode)
}
}
-void HorizonItem::hideLabels() {
- QMap<SkyPoint *,LabelNode *>::iterator i = m_compassLabels.begin();
-
- while ( i != m_compassLabels.end() ) {
- LabelNode * compass = (*i);
- compass->hide();
- i++;
- }
-}
-
void HorizonItem::update() {
if(!childCount()) {
appendChildNode(new HorizonNode(m_horizonComp->pointList()));
@@ -71,40 +61,37 @@ void HorizonItem::update() {
//HorizonNode *hNode = static_cast<HorizonNode *>(n->skyNodeAtIndex(0));
QSGNode *n = firstChild();
- while(n != 0) {
- SkyNode *hNode = static_cast<SkyNode *>(n);
- if(m_horizonComp->selected()) {
-
- QPointF cpoint;
- bool visible;
-
- const Projector *proj = SkyMapLite::Instance()->projector();
- KStarsData *data = KStarsData::Instance();
-
- QMap<SkyPoint *,LabelNode *>::iterator i = m_compassLabels.begin();
-
- while ( i != m_compassLabels.end() ) {
- SkyPoint *c = i.key();
- if ( !Options::useAltAz() ) {
- c->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
- }
-
- LabelNode * compass = (*i);
- cpoint = proj->toScreen( c, false, &visible );
- if ( visible && proj->onScreen(cpoint) ) {
- compass->setLabelPos(cpoint);
- } else {
- compass->hide();
- }
- i++;
+ SkyNode *hNode = static_cast<SkyNode *>(n);
+ if(m_horizonComp->selected()) {
+ QPointF cpoint;
+ bool visible;
+
+ const Projector *proj = SkyMapLite::Instance()->projector();
+ KStarsData *data = KStarsData::Instance();
+
+ QMap<SkyPoint *,LabelNode *>::iterator i = m_compassLabels.begin();
+
+ while ( i != m_compassLabels.end() ) {
+ SkyPoint *c = i.key();
+ if ( !Options::useAltAz() ) {
+ c->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
}
- hNode->update();
- } else {
- hNode->hide();
- hideLabels();
+ LabelNode * compass = (*i);
+ cpoint = proj->toScreen( c, false, &visible );
+ if ( visible && proj->onScreen(cpoint) ) {
+ compass->setLabelPos(cpoint);
+ } else {
+ compass->hide();
+ }
+ i++;
}
- n = n->nextSibling();
+
+ hNode->update();
+ } else {
+ hNode->hide();
+ rootNode()->labelsItem()->hideLabels(LabelsItem::label_t::HORIZON_LABEL);
}
+ n = n->nextSibling();
}
diff --git a/kstars/kstarslite/skyitems/horizonitem.h b/kstars/kstarslite/skyitems/horizonitem.h
index 9f75ccf..c974b84 100644
--- a/kstars/kstarslite/skyitems/horizonitem.h
+++ b/kstars/kstarslite/skyitems/horizonitem.h
@@ -21,13 +21,32 @@
class HorizonComponent;
class GuideLabelNode;
+ /** @class SkyMapLite
+ * Handles representation of HorizonComponent in SkyMapLite (lines, filled polygon and compass
+ * labels).
+ *
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
class HorizonItem : public SkyItem {
public:
+ /**
+ * @short Constructor.
+ * @param hComp pointer to HorizonComponent which HorizonItem represents in SkyMapLite
+ * @param rootNode parent RootNode that instantiated this object
+ */
HorizonItem(HorizonComponent * hComp, RootNode *rootNode);
- inline void setHorizonComp(HorizonComponent * hComp) { m_horizonComp = hComp; }
- void hideLabels();
+ /**
+ * @short setter for m_horizonComp
+ * @param hComp pointer to HorizonComponent
+ */
+ inline void setHorizonComp(HorizonComponent * hComp) { m_horizonComp = hComp; }
+ /**
+ * @short calls update() of HorizonNode and updates/hides compass labels based on their visibility
+ */
virtual void update();
private:
HorizonComponent *m_horizonComp;
diff --git a/kstars/kstarslite/skyitems/labelsitem.cpp b/kstars/kstarslite/skyitems/labelsitem.cpp
index 318627a..d983339 100644
--- a/kstars/kstarslite/skyitems/labelsitem.cpp
+++ b/kstars/kstarslite/skyitems/labelsitem.cpp
@@ -1,7 +1,7 @@
/** *************************************************************************
labelsitem.cpp - K Desktop Planetarium
-------------------
- begin : 09/06/2016
+ begin : 10/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -24,81 +24,84 @@
#include "cometsitem.h"
#include "rootnode.h"
-LabelsItem::LabelsItem(RootNode *rootNode)
- :m_rootNode(rootNode)
+LabelsItem::LabelsItem()
+ :m_rootNode(0)
{
LabelTypeNode *stars = new LabelTypeNode;
appendChildNode(stars);
- labelsLists.insert(label_t::STAR_LABEL, stars);
+ m_labelsLists.insert(label_t::STAR_LABEL, stars);
LabelTypeNode *asteroids = new LabelTypeNode;
appendChildNode(asteroids);
- labelsLists.insert(label_t::ASTEROID_LABEL, asteroids);
+ m_labelsLists.insert(label_t::ASTEROID_LABEL, asteroids);
LabelTypeNode *comets = new LabelTypeNode;
appendChildNode(comets);
- labelsLists.insert(label_t::COMET_LABEL, comets);
+ m_labelsLists.insert(label_t::COMET_LABEL, comets);
LabelTypeNode *planets = new LabelTypeNode;
appendChildNode(planets);
- labelsLists.insert(label_t::PLANET_LABEL, planets);
+ m_labelsLists.insert(label_t::PLANET_LABEL, planets);
LabelTypeNode *jupiter_moons = new LabelTypeNode;
appendChildNode(jupiter_moons);
- labelsLists.insert(label_t::JUPITER_MOON_LABEL, jupiter_moons);
+ m_labelsLists.insert(label_t::JUPITER_MOON_LABEL, jupiter_moons);
LabelTypeNode *saturn_moons = new LabelTypeNode;
appendChildNode(saturn_moons);
- labelsLists.insert(label_t::SATURN_MOON_LABEL, saturn_moons);
+ m_labelsLists.insert(label_t::SATURN_MOON_LABEL, saturn_moons);
LabelTypeNode *deep_sky = new LabelTypeNode;
appendChildNode(deep_sky);
- labelsLists.insert(label_t::DEEP_SKY_LABEL, deep_sky);
+ m_labelsLists.insert(label_t::DEEP_SKY_LABEL, deep_sky);
LabelTypeNode *constellation = new LabelTypeNode;
appendChildNode(constellation);
- labelsLists.insert(label_t::CONSTEL_NAME_LABEL, constellation);
+ m_labelsLists.insert(label_t::CONSTEL_NAME_LABEL, constellation);
LabelTypeNode *satellite = new LabelTypeNode;
appendChildNode(satellite);
- labelsLists.insert(label_t::SATELLITE_LABEL, satellite);
+ m_labelsLists.insert(label_t::SATELLITE_LABEL, satellite);
LabelTypeNode *rude = new LabelTypeNode;
appendChildNode(rude);
- labelsLists.insert(label_t::RUDE_LABEL, rude);
+ m_labelsLists.insert(label_t::RUDE_LABEL, rude);
LabelTypeNode *num_label = new LabelTypeNode;
appendChildNode(num_label);
- labelsLists.insert(label_t::NUM_LABEL_TYPES, num_label);
+ m_labelsLists.insert(label_t::NUM_LABEL_TYPES, num_label);
LabelTypeNode *horizon_label = new LabelTypeNode;
appendChildNode(horizon_label);
- labelsLists.insert(label_t::HORIZON_LABEL, horizon_label);
+ m_labelsLists.insert(label_t::HORIZON_LABEL, horizon_label);
LabelTypeNode *equator = new LabelTypeNode;
appendChildNode(equator);
- labelsLists.insert(label_t::EQUATOR_LABEL, equator);
+ m_labelsLists.insert(label_t::EQUATOR_LABEL, equator);
LabelTypeNode *ecliptic = new LabelTypeNode;
appendChildNode(ecliptic);
- labelsLists.insert(label_t::ECLIPTIC_LABEL, ecliptic);
+ m_labelsLists.insert(label_t::ECLIPTIC_LABEL, ecliptic);
+
+ skyLabeler = SkyLabeler::Instance();
+ skyLabeler->reset();
}
-LabelNode *LabelsItem::addLabel(SkyObject *skyObject, label_t type) {
- LabelNode *label = new LabelNode(skyObject, type);
- labelsLists.value(type)->appendChildNode(label);
+LabelNode *LabelsItem::addLabel(SkyObject *skyObject, label_t labelType) {
+ LabelNode *label = new LabelNode(skyObject, labelType);
+ m_labelsLists.value(labelType)->appendChildNode(label);
return label;
}
-LabelNode *LabelsItem::addLabel(QString name, label_t type) {
- LabelNode *label = new LabelNode(name, type);
- labelsLists.value(type)->appendChildNode(label);
+LabelNode *LabelsItem::addLabel(QString name, label_t labelType) {
+ LabelNode *label = new LabelNode(name, labelType);
+ m_labelsLists.value(labelType)->appendChildNode(label);
return label;
}
-GuideLabelNode *LabelsItem::addGuideLabel(QString name, label_t type) {
- GuideLabelNode *label = new GuideLabelNode(name, type);
- labelsLists.value(type)->appendChildNode(label);
+GuideLabelNode *LabelsItem::addGuideLabel(QString name, label_t labelType) {
+ GuideLabelNode *label = new GuideLabelNode(name, labelType);
+ m_labelsLists.value(labelType)->appendChildNode(label);
return label;
}
@@ -106,50 +109,54 @@ void LabelsItem::update() {
SkyLabeler * skyLabeler = SkyLabeler::Instance();
skyLabeler->reset();
- updateChildLabels(label_t::PLANET_LABEL);
- updateChildLabels(label_t::JUPITER_MOON_LABEL);
-
- 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);
updateChildLabels(label_t::ASTEROID_LABEL);
- if(rootNode()->cometsItem()->visible()) {
+ if(getLabelNode(label_t::COMET_LABEL)->opacity()) {
updateChildLabels(label_t::COMET_LABEL);
- } else {
- hideLabels(label_t::COMET_LABEL);
}
updateChildLabels(label_t::CONSTEL_NAME_LABEL);
+ updateChildLabels(label_t::HORIZON_LABEL);
+
}
-void LabelsItem::hideLabels(label_t type) {
- QSGOpacityNode *node = labelsLists[type];
+void LabelsItem::hideLabels(label_t labelType) {
+ QSGOpacityNode *node = m_labelsLists[labelType];
node->setOpacity(0);
node->markDirty(QSGNode::DirtyOpacity);
}
-void LabelsItem::deleteLabels(label_t type) {
- QSGOpacityNode *node = labelsLists[type];
- QSGNode *n = node->firstChild();
- while( n != 0) {
- delete n;
- n = n->nextSibling();
+void LabelsItem::setRootNode(RootNode *rootNode) {
+ //Remove from previous parent if had any
+ if(m_rootNode && parent() == m_rootNode) m_rootNode->removeChildNode(this);
+
+ //Append to new parent if haven't already
+ m_rootNode = rootNode;
+ if(parent() != m_rootNode) m_rootNode->appendChildNode(this);
+}
+
+void LabelsItem::deleteLabels(label_t labelType) {
+ if(labelType != label_t::NO_LABEL) {
+ QSGOpacityNode *node = m_labelsLists[labelType];
+ while(QSGNode *n = node->firstChild()) { node->removeChildNode(n); delete n; }
}
- node->removeAllChildNodes();
}
-void LabelsItem::updateChildLabels(label_t type) {
- QSGOpacityNode *node = labelsLists[type];
+void LabelsItem::updateChildLabels(label_t labelType) {
+ QSGOpacityNode *node = m_labelsLists[labelType];
node->setOpacity(1);
node->markDirty(QSGNode::DirtyOpacity);
QSGNode *n = node->firstChild();
- /*if( type == label_t::HORIZON_LABEL
- || type == label_t::ECLIPTIC_LABEL || type == label_t::EQUATOR_LABEL) {
+ /*if( labelType == label_t::HORIZON_LABEL
+ || labelType == label_t::ECLIPTIC_LABEL || labelType == label_t::EQUATOR_LABEL) {
while( n != 0) {
GuideLabelNode *label = static_cast<GuideLabelNode *>(n);
if(label->visible()) {
@@ -167,11 +174,13 @@ void LabelsItem::updateChildLabels(label_t type) {
while( n != 0) {
LabelNode *label = static_cast<LabelNode *>(n);
if(label->visible()) {
- if(SkyLabeler::Instance()->markText(label->labelPos, label->name())) {
+ if(label->zoomFont()) skyLabeler->resetFont();
+ if(skyLabeler->markText(label->labelPos, label->name())) {
label->update();
} else {
label->hide();
}
+ skyLabeler->useStdFont();
}
n = n->nextSibling();
}
diff --git a/kstars/kstarslite/skyitems/labelsitem.h b/kstars/kstarslite/skyitems/labelsitem.h
index 57ba27b..342370b 100644
--- a/kstars/kstarslite/skyitems/labelsitem.h
+++ b/kstars/kstarslite/skyitems/labelsitem.h
@@ -1,7 +1,7 @@
/** *************************************************************************
- asteroidsitem.h - K Desktop Planetarium
+ labelsitem.h - K Desktop Planetarium
-------------------
- begin : 16/05/2016
+ begin : 10/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -22,18 +22,53 @@
typedef QSGOpacityNode LabelTypeNode;
-class KSAsteroid;
-class LineListIndex;
class LabelNode;
class GuideLabelNode;
-class SkyObject;
class RootNode;
+class SkyObject;
+
+/**
+ * @class LabelsItem
+ *
+ * This class is in charge of labels in SkyMapLite. Labels can be instantiated by calling addLabel with
+ * either SkyObject or plain QString as a name. There are two types of label nodes available - LabelNode
+ * that can't be rotated and GuideLabelNode that supports rotation (but it not used now anywhere).
+ *
+ * To prevent labels from overlapping this class uses SkyLabeler. We check LabelNode for overlapping by
+ * calling SkyLabeler::markText() (SkyLabeler::markRegion() for GuideLabelNode) update().
+ *
+ * Each of SkyItems that uses labels has its own label type in enum label_t (copied from SkyLabeler but
+ * was a bit extended). Labels of particular type are reparented to LabelTypeNode(QSGOpacityNode) so
+ * to hide all labels of some type you just need to set opacity of LabelTypeNode that corresponds to
+ * this type to 0.
+ *
+ * Order of drawing can be changed in LabelsItem's constructor. Order of labels update can be changed in
+ * update().
+ *
+ * This class is not derived from SkyItem as it doesn't have label type and SkyItem's header needs an
+ * inclusion of this header to allow use of label_t enum. (Might be a good idea to fix this)
+ *
+ * @note font size is set in SkyLabeler::SkyLabeler() by initializing m_stdFont with default font
+ *
+ * @short handles labels in SkyMapLite
+ * @author Artem Fedoskin
+ * @version 1.0
+ */
+
class LabelsItem : public QSGOpacityNode {
public:
- LabelsItem(RootNode *rootNode);
+ /**
+ * @brief Constructor
+ * @param rootNode parent RootNode that instantiates this object
+ */
+ LabelsItem();
+
+ /**
+ * @short The label_t enum. Holds types of labels
+ */
enum label_t {
STAR_LABEL,
ASTEROID_LABEL,
@@ -48,26 +83,85 @@ public:
NUM_LABEL_TYPES,
HORIZON_LABEL,
EQUATOR_LABEL,
- ECLIPTIC_LABEL
+ ECLIPTIC_LABEL,
+ NO_LABEL //used in LinesItem
};
- LabelNode *addLabel(SkyObject *skyObject, label_t type);
- LabelNode *addLabel(QString name, label_t type);
+ /**
+ * creates LabelNode with given skyObject and appends it to LabelTypeNode that corresponds
+ * to type
+ * @param skyObject for which the label is created
+ * @param labelType type of LabelTypeNode to which this label has to be reparented
+ * @return pointer to newly created LabelNode
+ */
+ LabelNode *addLabel(SkyObject *skyObject, label_t labelType);
+
+ /**
+ * @short does the same as above but with QString instead of SkyObject
+ */
+
+ LabelNode *addLabel(QString name, label_t labelType);
+
+ /**
+ * @short does the same as above but instead creates GuideLabelNode
+ * @note currently GuideLabelNode is not used anywhere so it is not fully supported yet
+ */
+
+ GuideLabelNode *addGuideLabel(QString name, label_t labelType);
+
+ /**
+ * The order of labels update can be changed here.
+ * @short updates all child labels
+ */
- GuideLabelNode *addGuideLabel(QString name, label_t type);
void update();
- void updateChildLabels(label_t type);
- QSGOpacityNode *getLabelNode(label_t type) { return labelsLists.value(type); }
- void deleteLabels(label_t type);
+ /**
+ * @short updates child labels of LabelTypeNode that corresponds to type in m_labelsLists
+ * @param labelType type of LabelTypeNode (see m_labelsLists)
+ */
- void hideLabels(label_t type);
+ void updateChildLabels(label_t labelType);
+
+ /**
+ * @return LabelTypeNode that holds labels of labelType
+ */
+
+ LabelTypeNode *getLabelNode(label_t labelType) { return m_labelsLists.value(labelType); }
+
+ /**
+ * @short deletes all labels of type labelType
+ */
+
+ void deleteLabels(label_t labelType);
+
+ /**
+ * @short hides all labels of type labelType
+ */
+
+ void hideLabels(label_t labelType);
+
+ /**
+ * @short sets m_rootNode and appends to it this node
+ * @param rootNode
+ */
+ void setRootNode(RootNode *rootNode);
+
+ /**
+ * @return pointer to RootNode that instantiated this object
+ */
RootNode *rootNode() { return m_rootNode; }
private:
- QMap<label_t, LabelTypeNode *> labelsLists;
+ QMap<label_t, LabelTypeNode *> m_labelsLists;
+
+ /**
+ * @short because this class is not derived from SkyItem it has to store pointer to RootNode
+ */
+
RootNode *m_rootNode;
+ SkyLabeler *skyLabeler;
};
#endif
diff --git a/kstars/kstarslite/skyitems/lines/eclipticitem.cpp b/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
index eab335e..d4935d4 100644
--- a/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/eclipticitem.cpp
@@ -1,7 +1,7 @@
/** *************************************************************************
- EclipticItem.cpp - K Desktop Planetarium
+ eclipticitem.cpp - K Desktop Planetarium
-------------------
- begin : 16/05/2016
+ begin : 10/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -67,7 +67,6 @@ void EclipticItem::update() {
const Projector *proj = SkyMapLite::Instance()->projector();
KStarsData *data = KStarsData::Instance();
- //SkyLabeler* skyLabeler = SkyLabeler::Instance();
QMap<SkyPoint *,LabelNode *>::iterator i = m_compassLabels.begin();
@@ -89,7 +88,6 @@ void EclipticItem::update() {
} else {
hide();
- rootNode()->labelsItem()->hideLabels(labelType());
}
}
diff --git a/kstars/kstarslite/skyitems/lines/eclipticitem.h b/kstars/kstarslite/skyitems/lines/eclipticitem.h
index 0b8ff65..ef37a43 100644
--- a/kstars/kstarslite/skyitems/lines/eclipticitem.h
+++ b/kstars/kstarslite/skyitems/lines/eclipticitem.h
@@ -1,7 +1,7 @@
/** *************************************************************************
- asteroidsitem.h - K Desktop Planetarium
+ eclipticitem.h - K Desktop Planetarium
-------------------
- begin : 16/05/2016
+ begin : 10/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -20,14 +20,32 @@
class Ecliptic;
+ /** @class EclipticItem
+ *
+ *@short Represents Ecliptic in SkyMapLite
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
class EclipticItem : public SkyItem {
public:
+ /**
+ * @short Constructor. Creates TrixelNodes for lines and LabelNodes for compass labels
+ * @param eclipticComp Ecliptic that needs to be represented in SkyMapLite
+ * @param rootNode parent RootNode that instantiated this object
+ */
+
EclipticItem(Ecliptic *eclipticComp, RootNode *rootNode);
+ /**
+ * @short updates positions of lines and compass labels
+ */
virtual void update();
private:
Ecliptic *m_eclipticComp;
+
+ //Holds compass labels each associated with SkyPoint that is coordinate of this label
QMap<SkyPoint *, LabelNode *> m_compassLabels;
};
#endif
diff --git a/kstars/kstarslite/skyitems/lines/equatoritem.cpp b/kstars/kstarslite/skyitems/lines/equatoritem.cpp
index d237630..46744065 100644
--- a/kstars/kstarslite/skyitems/lines/equatoritem.cpp
+++ b/kstars/kstarslite/skyitems/lines/equatoritem.cpp
@@ -1,7 +1,7 @@
/** *************************************************************************
- EquatorItem.cpp - K Desktop Planetarium
+ equatoritem.cpp - K Desktop Planetarium
-------------------
- begin : 16/05/2016
+ begin : 10/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -39,7 +39,6 @@ EquatorItem::EquatorItem(Equator *equatorComp, RootNode *rootNode)
++i;
}
-
for( int ra = 0; ra < 23; ra += 2 ) {
SkyPoint *o = new SkyPoint( ra, 0.0 );
@@ -63,10 +62,9 @@ void EquatorItem::update() {
const Projector *proj = SkyMapLite::Instance()->projector();
KStarsData *data = KStarsData::Instance();
- //SkyLabeler* skyLabeler = SkyLabeler::Instance();
QMap<SkyPoint *,LabelNode *>::iterator i = m_compassLabels.begin();
- KSNumbers num( data->ut().djd() );
+
while ( i != m_compassLabels.end() ) {
SkyPoint *c = i.key();
c->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
@@ -85,8 +83,5 @@ void EquatorItem::update() {
} else {
hide();
- rootNode()->labelsItem()->hideLabels(labelType());
}
}
-
-/**/
diff --git a/kstars/kstarslite/skyitems/lines/equatoritem.h b/kstars/kstarslite/skyitems/lines/equatoritem.h
index 1131a6e..d74d47f 100644
--- a/kstars/kstarslite/skyitems/lines/equatoritem.h
+++ b/kstars/kstarslite/skyitems/lines/equatoritem.h
@@ -1,7 +1,7 @@
/** *************************************************************************
- asteroidsitem.h - K Desktop Planetarium
+ equatoritem.h - K Desktop Planetarium
-------------------
- begin : 16/05/2016
+ begin : 10/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -22,14 +22,32 @@
class KSAsteroid;
class LineListIndex;
+ /** @class EquatorItem
+ *
+ *@short Represents Equator in SkyMapLite
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
class EquatorItem : public SkyItem {
public:
+ /**
+ * @short Constructor. Creates TrixelNodes for lines and LabelNodes for compass labels
+ * @param equatorComp Equator that needs to be represented in SkyMapLite
+ * @param rootNode parent RootNode that instantiated this object
+ */
+
EquatorItem(Equator *equatorComp, RootNode *rootNode);
+ /**
+ * @short updates positions of lines and compass labels
+ */
virtual void update();
private:
Equator *m_equatorComp;
+
+ //Holds compass labels each associated with SkyPoint that is coordinate of this label
QMap<SkyPoint *, LabelNode *> m_compassLabels;
};
#endif
diff --git a/kstars/kstarslite/skyitems/lines/linesitem.cpp b/kstars/kstarslite/skyitems/lines/linesitem.cpp
index e2134d9..0e6a1d6 100644
--- a/kstars/kstarslite/skyitems/lines/linesitem.cpp
+++ b/kstars/kstarslite/skyitems/lines/linesitem.cpp
@@ -1,7 +1,7 @@
/** *************************************************************************
- EquatorItem.cpp - K Desktop Planetarium
+ linesitem.cpp - K Desktop Planetarium
-------------------
- begin : 16/05/2016
+ begin : 1/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -25,32 +25,9 @@
#include "../skynodes/nodes/linenode.h"
LinesItem::LinesItem(RootNode *rootNode)
- :SkyItem(LabelsItem::label_t::RUDE_LABEL, rootNode)
+ :SkyItem(LabelsItem::label_t::NO_LABEL, rootNode)
{
- //Under construction
- Options::setShowCBounds(true);
- Options::setShowCLines(true);
- Options::setShowSolarSystem(true);
- Options::setShowEcliptic(true);
- Options::setShowEquator(true);
- Options::setShowEquatorialGrid(true);
- Options::setShowHorizontalGrid(true);
- Options::setShowGround(true);
- //Labels
- Options::setShowCometNames(true);
- Options::setShowAsteroidNames(true);
- Options::setShowAsteroids(true);
- Options::setShowCNames(true);
-
- Options::setAutoSelectGrid(true);
-
- Options::setHideCBounds(true);
- Options::setHideCLines(false);
- Options::setHideOnSlew(true);
- Options::setHideGrids(false);
-
- Options::setRunClock(false);
}
void LinesItem::addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style) {
diff --git a/kstars/kstarslite/skyitems/lines/linesitem.h b/kstars/kstarslite/skyitems/lines/linesitem.h
index 3099b94..c3e08ab 100644
--- a/kstars/kstarslite/skyitems/lines/linesitem.h
+++ b/kstars/kstarslite/skyitems/lines/linesitem.h
@@ -1,7 +1,7 @@
/** *************************************************************************
- asteroidsitem.h - K Desktop Planetarium
+ linesitem.h - K Desktop Planetarium
-------------------
- begin : 16/05/2016
+ begin : 1/06/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -18,16 +18,43 @@
#include "../skyitem.h"
-class KSAsteroid;
class LineListIndex;
+ /** @class LinesItem
+ *
+ * Class that handles lines (Constellation lines and boundaries and both coordinate grids) in
+ * SkyMapLite.
+ *
+ * To display lines component use addLinesComponent.
+ *
+ *@note see RootNode::RootNode() for example of adding lines
+ *@short Class that handles most of the lines in SkyMapLite
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
class LinesItem : public SkyItem {
public:
-
+ /**
+ * @short Constructor.
+ * @param rootNode parent RootNode that instantiated this object
+ */
LinesItem(RootNode *rootNode);
+ /**
+ * @short adds LinesListIndex that is needed to be displayed to m_lineIndexes
+ * @param linesComp LineListIndex derived object
+ * @param color desired color of lines specified as name of entry in ColorScheme
+ * @param width thickness of lines
+ * @param style desired style (currently supports only Qt::SolidLine)
+ */
void addLinesComponent(LineListIndex *linesComp, QString color, int width, Qt::PenStyle style);
+ /**
+ * @short updates all trixels that are associated with LineListIndex or hide them if selected()
+ * of this LineListIndex returns false
+ */
+
virtual void update();
private:
QMap<QSGOpacityNode *,LineListIndex *> m_lineIndexes;
diff --git a/kstars/kstarslite/skyitems/planetsitem.h b/kstars/kstarslite/skyitems/planetsitem.h
index ed12ebd..5e74cc7 100644
--- a/kstars/kstarslite/skyitems/planetsitem.h
+++ b/kstars/kstarslite/skyitems/planetsitem.h
@@ -23,33 +23,39 @@ class PlanetMoonsComponent;
class RootNode;
class SkyObject;
+ /**
+ * @class PlanetsItem
+ * This class handles planets and their moons in SkyMapLite
+ *
+ * @author Artem Fedoskin
+ * @version 1.0
+ */
+
class PlanetsItem : public SkyItem {
public:
- PlanetsItem(QList<SolarSystemSingleComponent *> planets, QList<PlanetMoonsComponent *> moons, RootNode *rootNode = 0);
- /** Add a pointer to an object of type SolarSystemSingleComponent to m_toAdd. In the next call to
- * updatePaintNode() the object of type PlanetNode will be created and planetComponent
- * will be moved to m_planetComponents. PlanetNode represents graphically KSPlanetBase on SkyMapLite.
- * This function should be called whenever an object of class SolarSystemSingleComponent is
- * created.
+ /**
+ * @short Constructor. Takes lists of pointers to planets(SolarSystemSingleComponent) and their
+ * moons (PlanetMoonsComponent) to instantiate PlanetMoonsNodes for each of the planet.
*
- * @param SolarSystemSingleComponent that should be displayed on SkyMapLite
+ * @param planets list of pointers to planets
+ * @param moons list of pointers to moons
+ * @param rootNode parent RootNode that instantiates this object
*/
-
-// void addPlanet(SolarSystemSingleComponent* planetComp);
+ PlanetsItem(QList<SolarSystemSingleComponent *> planets, QList<PlanetMoonsComponent *> moons, RootNode *rootNode = 0);
/**
- * Add a pointer to an object of type PlanetMoonsComponent to m_moonsToAdd. In the next call to
- * updatePaintNode() PlanetMoons will be added to existing PlanetMoonsNode, which will then control
- * the drawing of moons and planet.
- * @param pMoons pointer to PlanetMoonsComponent which moons should be displayed on SkyMapLite
+ * @short returns SolarSystemSingleComponent that corresponds to the planet. Used to determine
+ * whether the planet has to be drawn according to its selected() function
+ * @param planet
+ * @return corresponding SolarSystemSingleComponent
*/
-// void addMoons(PlanetMoonsComponent * pMoons);
-
SolarSystemSingleComponent * getParentComponent(SkyObject * planet);
+ /**
+ * @short calls update() of all child PlanetMoonsNodes
+ * @note see PlanetMoonsNodes::update()
+ */
void update() override;
-protected:
- //virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
private:
QList<SolarSystemSingleComponent *> m_planetComponents;
diff --git a/kstars/kstarslite/skyitems/rootnode.cpp b/kstars/kstarslite/skyitems/rootnode.cpp
index 09c47fe..0c4ec1e 100644
--- a/kstars/kstarslite/skyitems/rootnode.cpp
+++ b/kstars/kstarslite/skyitems/rootnode.cpp
@@ -41,33 +41,30 @@ RootNode::RootNode()
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(this);
+ m_labelsItem = new LabelsItem();
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->equator(), "EqColor", 1, Qt::SolidLine );
- m_equator = new EquatorItem(m_skyComposite->equator(),this);
- m_ecliptic = new EclipticItem(m_skyComposite->ecliptic(),this);
- m_linesItem->addLinesComponent( m_skyComposite->ecliptic(), "EclColor", 1, Qt::SolidLine );
-
m_linesItem->addLinesComponent( m_skyComposite->constellationBoundary(), "CBoundColor", 1, Qt::SolidLine );
m_linesItem->addLinesComponent( m_skyComposite->constellationLines(), "CLineColor", 1, Qt::SolidLine );
+ 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);
setIsRectangular(false);
updateClipPoly();
- appendChildNode(m_labelsItem);
+ m_labelsItem->setRootNode(this);
/*
m_linesItem(new LinesItem(this)), m_horizonItem(new HorizonItem(this))
@@ -129,6 +126,7 @@ void RootNode::updateClipPoly() {
void RootNode::update() {
updateClipPoly();
+
//TODO: Move this check somewhere else (create a separate function)
if(Options::showSolarSystem()) {
m_planetsItem->update();
@@ -147,8 +145,8 @@ void RootNode::update() {
}
} else {
m_planetsItem->hide();
- if(m_asteroidsItem) m_asteroidsItem->hide();
- if(m_cometsItem) m_cometsItem->hide();
+ if(m_asteroidsItem) delete m_asteroidsItem;
+ if(m_cometsItem) delete m_cometsItem;
}
m_constelNamesItem->update();
diff --git a/kstars/kstarslite/skyitems/rootnode.h b/kstars/kstarslite/skyitems/rootnode.h
index 48d5d49..82470f9 100644
--- a/kstars/kstarslite/skyitems/rootnode.h
+++ b/kstars/kstarslite/skyitems/rootnode.h
@@ -1,4 +1,3 @@
-
/** *************************************************************************
rootnode.h - K Desktop Planetarium
-------------------
@@ -47,7 +46,7 @@ class SolarSystemComposite;
*@version 1.0
*/
-class RootNode : public QSGClipNode { //Clipping under construction
+class RootNode : public QSGClipNode {
public:
RootNode();
/**
@@ -73,9 +72,10 @@ public:
inline LabelsItem *labelsItem() { return m_labelsItem; }
private:
/**
- * @short initializes textureCache with cached images of stars in SkyMapLite
+ * @short initializes textureCache with cached images of stars from SkyMapLite
*/
void genCachedTextures();
+
QVector<QVector<QSGTexture *>> m_textureCache;
SkyMapLite *m_skyMapLite;
@@ -96,9 +96,5 @@ private:
SkyMapComposite *m_skyComposite;
SolarSystemComposite *m_solarSystem;
-
- //To hold nodes that represent sky objects
- //QVector<SkyNode *> m_skyNodes;
- //bool m_hidden;
};
#endif
diff --git a/kstars/kstarslite/skyitems/skyitem.cpp b/kstars/kstarslite/skyitems/skyitem.cpp
index 97fde47..e19e8a0 100644
--- a/kstars/kstarslite/skyitems/skyitem.cpp
+++ b/kstars/kstarslite/skyitems/skyitem.cpp
@@ -33,6 +33,7 @@ void SkyItem::hide() {
setOpacity(0);
markDirty(QSGNode::DirtyOpacity);
}
+ rootNode()->labelsItem()->hideLabels(labelType());
}
void SkyItem::show() {
diff --git a/kstars/kstarslite/skyitems/skyitem.h b/kstars/kstarslite/skyitems/skyitem.h
index 37575cf..3420a6b 100644
--- a/kstars/kstarslite/skyitems/skyitem.h
+++ b/kstars/kstarslite/skyitems/skyitem.h
@@ -28,8 +28,9 @@ class SkyNode;
/** @class SkyItem
*
- *This is an interface for implementing SkyItems that are used to display SkyComponent
- *derived objects on the SkyMapLite.
+ *This is an interface for implementing SkyItems that represent SkyComponent derived objects on
+ *the SkyMapLite. It is derived from QSGOpacityNode to make it possible to hide the whole node tree
+ *by simply setting opacity to 0.
*
*@short A base class that is used for displaying SkyComponents on SkyMapLite.
*@author Artem Fedoskin
@@ -40,23 +41,49 @@ class SkyItem : public QSGOpacityNode {
public:
/**
- *Constructor, add SkyItem to parent in a node tree
+ * Constructor, appends SkyItem to rootNode as a child in a node tree
*
+ * @param labelType type of label that corresponds to this item
+ * @note see LabelsItem::label_t
* @param parent a pointer to SkyItem's parent node
*/
explicit SkyItem(LabelsItem::label_t labelType, RootNode *rootNode = 0);
virtual ~SkyItem();
+ /**
+ * @short updates the coordinates and visibility of child node. Similiar to draw routine in
+ * SkyComponent derived classes
+ */
+
virtual void update() =0;
+ /**
+ * @short hides this item by setting its opacity to 0
+ */
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
+ */
+
inline RootNode *rootNode() { return m_rootNode; }
+ /**
+ * @return label type of this SkyItem
+ */
+
inline LabelsItem::label_t labelType() { return m_labelType; }
+ /**
+ * @return false if opacity is 0 otherwise true
+ */
+
bool visible();
private:
diff --git a/kstars/kstarslite/skyitems/skynodes/labelnode.cpp b/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
index 6bc1614..f2eccc2 100644
--- a/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/labelnode.cpp
@@ -22,20 +22,60 @@
#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->name()), m_textTexture(new QSGSimpleTextureNode),
+ m_zoomFont(false), m_labelType(type), m_fontSize(0)
{
- createTexture(type);
+ 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);
+
}
LabelNode::LabelNode(QString name, LabelsItem::label_t type)
- :m_name(name), m_textTexture(new QSGSimpleTextureNode)
+ :m_name(name), m_textTexture(new QSGSimpleTextureNode), m_labelType(type), m_zoomFont(false)
{
- createTexture(type);
+ 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);
}
-void LabelNode::createTexture(LabelsItem::label_t type) {
+void LabelNode::createTexture() {
QColor color;
- switch(type) {
+
+ switch(m_labelType) {
+ case LabelsItem::label_t::SATURN_MOON_LABEL:
+ case LabelsItem::label_t::JUPITER_MOON_LABEL:
+ SkyLabeler::Instance()->shrinkFont(2);
+ break;
+ default:
+ break;
+ }
+
+ switch(m_labelType) {
case LabelsItem::label_t::PLANET_LABEL:
case LabelsItem::label_t::SATURN_MOON_LABEL:
case LabelsItem::label_t::JUPITER_MOON_LABEL:
@@ -53,8 +93,21 @@ void LabelNode::createTexture(LabelsItem::label_t type) {
color = KStarsData::Instance()->colorScheme()->colorNamed( "UserLabelColor" );
}
- m_textTexture->setTexture(SkyMapLite::Instance()->textToTexture(m_name, color));
- m_opacity->appendChildNode(m_textTexture);
+ 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) {
+ case LabelsItem::label_t::SATURN_MOON_LABEL:
+ case LabelsItem::label_t::JUPITER_MOON_LABEL:
+ SkyLabeler::Instance()->resetFont();
+ break;
+ default:
+ break;
+ }
+
+ if(oldTexture) delete oldTexture;
m_textSize = m_textTexture->texture()->textureSize();
QRectF oldRect = m_textTexture->rect();
@@ -62,7 +115,6 @@ void LabelNode::createTexture(LabelsItem::label_t type) {
}
void LabelNode::changePos(QPointF pos) {
- //QSizeF size = m_point->size();
QMatrix4x4 m (1,0,0,pos.x(),
0,1,0,pos.y(),
0,0,1,0,
@@ -81,5 +133,8 @@ void LabelNode::setLabelPos(QPointF pos) {
}
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 d126c65..c5642b7 100644
--- a/kstars/kstarslite/skyitems/skynodes/labelnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/labelnode.h
@@ -63,15 +63,24 @@ public:
inline QString name() { return m_name; }
- void createTexture(LabelsItem::label_t type);
+ void createTexture();
+
+ /**
+ * @return true if the size of text depends on zoom
+ */
+ inline bool zoomFont() { return m_zoomFont; }
void update();
QPointF labelPos;
private:
+ QString m_name;
QSGSimpleTextureNode *m_textTexture;
QSize m_textSize;
- QString m_name;
+
+ int m_fontSize;
+ bool m_zoomFont;
+ LabelsItem::label_t m_labelType;
};
#endif
diff --git a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp
index 369829b..66e52c6 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.cpp
@@ -7,6 +7,8 @@
#include "ksplanetbase.h"
#include "skylabeler.h"
+#include "Options.h"
+
PlanetMoonsNode::PlanetMoonsNode(KSPlanetBase* planet, RootNode* parentNode)
:SkyNode(planet), m_rootNode(parentNode), pmoons(0),
m_planetNode(new PlanetNode(planet, parentNode))
@@ -22,7 +24,7 @@ void PlanetMoonsNode::update() {
void PlanetMoonsNode::hide() {
m_planetNode->hide();
- foreach(PointSourceNode *moon, m_moonNodes) {
+ foreach(SkyNode *moon, m_moonNodes) {
moon->hide();
}
}
@@ -45,20 +47,26 @@ void PlanetMoonsNode::updateMoons() {
// We need to reappend node that draws the planet
appendChildNode(m_planetNode);
+ bool drawLabel = true;
+
+ 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();
+ 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();
+ m_moonNodes[i]->update(drawLabel);
}
}
/* //Draw Moon name labels if at high zoom
- /*if ( ! (Options::showPlanetNames() && Options::zoomFactor() > 50.*MINZOOM) ) return;
+ return;
for ( int i=0; i<nmoons; ++i ) {
/*
if (planet ==KSPlanetBase::SATURN)
diff --git a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h
index 5def5a2..4e664af 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/planetmoonsnode.h
@@ -27,10 +27,10 @@ class QSGSimpleTextureNode;
/** @class PlanetMoonsNode
*
* A SkyNode derived class used as a container for displaying a planet with its moons (if any). Unlike
- * PlanetMoons in SkyComponents PlanetMoonsNode represents both planet and moons. Thus the planet has to
- * be created only using this class that in turn will create an object of type PlanetNode. Although all
- * SkyNodes are "movable" objects this class is just a container that provides z-order for moons and
- * planets, which changes their positions on their own.
+ * PlanetMoons derived from SkyComponent PlanetMoonsNode represents both planet and moons. Ths PlanetNode
+ * shouldn't be instantiated outside of this class (exception is AsteroidsItem). Although all SkyNodes
+ * are "movable" objects (they change transform matrix to move across the SkyMapLite) this class is
+ * just a container that provides z-order for moons and planets that change their positions on their own.
*
*@short A container for planets and moons that provides z-order.
*@author Artem Fedoskin
@@ -39,6 +39,12 @@ class QSGSimpleTextureNode;
class PlanetMoonsNode : public SkyNode {
public:
+ /**
+ * @short Constructor
+ * @param planet pointer to planet object
+ * @param parentNode pointer to the RootNode. It is needed for PointSourceNodes that use textures,
+ * which are cached in RootNode.
+ */
PlanetMoonsNode(KSPlanetBase* planet, RootNode* parentNode);
/**
@@ -47,7 +53,14 @@ public:
*/
inline void addMoons(PlanetMoons * planetMoons) { pmoons = planetMoons; }
+ /**
+ * If planet has any moons first updateMoons() is called then the planet is updated
+ */
virtual void update() override;
+
+ /**
+ * @short Hides both planet and its moons
+ */
virtual void hide() override;
/**
* @note PlanetMoonsNode is not meant to be moved. PlanetNode and PointSourceNodes handle this on
@@ -56,7 +69,10 @@ public:
virtual void changePos(QPointF pos) { }
/**
- * @short update position of moons if planet has them
+ * Update position of moons if planet has them. To allow z-ordering we need to change the structure
+ * of node tree by removing all child nodes of this tree and adding them again so that moons that
+ * are behind the planet are before the m_planetNode in the hierarchy and all others are appended
+ * after m_planetNode.
*/
void updateMoons();
@@ -64,7 +80,7 @@ private:
PlanetNode *m_planetNode;
PlanetMoons *pmoons;
- QList<PointSourceNode *> m_moonNodes;
+ QList<SkyNode *> m_moonNodes;
RootNode *m_rootNode;
};
diff --git a/kstars/kstarslite/skyitems/skynodes/planetnode.h b/kstars/kstarslite/skyitems/skynodes/planetnode.h
index cfaf16a..ade3b62 100644
--- a/kstars/kstarslite/skyitems/skynodes/planetnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/planetnode.h
@@ -27,8 +27,8 @@ class LabelNode;
/** @class PlanetNode
*
* A SkyNode derived class used as a container for holding two other nodes: PointNode
- * and QSGSimpleTextureNode(displays object as image) that are displayed depending on the conditions
- * (zoom level, user options)
+ * and QSGSimpleTextureNode(displays object as image) that are displayed depending according to the
+ * conditions (zoom level, user options)
*
*@short A container for PointNode and QSGSimpleTextureNode used for displaying some solar system objects
*@author Artem Fedoskin
@@ -68,8 +68,10 @@ public:
*/
virtual void changePos(QPointF pos) override;
+ /**
+ * @note similar to SolarSystemSingleComponent::draw()
+ */
virtual void update() override;
-
virtual void hide() override;
private:
PointNode *m_point;
diff --git a/kstars/kstarslite/skyitems/skynodes/skynode.cpp b/kstars/kstarslite/skyitems/skynodes/skynode.cpp
index a4474ad..1d24aeb 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_skyObject(skyObject), m_opacity(new QSGOpacityNode), m_drawLabel(false)
{
appendChildNode(m_opacity);
}
SkyNode::SkyNode()
- :m_skyObject(nullptr), m_opacity(new QSGOpacityNode)
+ :m_skyObject(nullptr), m_opacity(new QSGOpacityNode), m_drawLabel(false)
{
appendChildNode(m_opacity);
}
diff --git a/kstars/kstarslite/skyitems/skynodes/trixelnode.h b/kstars/kstarslite/skyitems/skynodes/trixelnode.h
index 9c4e151..3f1a774 100644
--- a/kstars/kstarslite/skyitems/skynodes/trixelnode.h
+++ b/kstars/kstarslite/skyitems/skynodes/trixelnode.h
@@ -1,5 +1,5 @@
/** *************************************************************************
- TrixelNode.h - K Desktop Planetarium
+ trixelnode.h - K Desktop Planetarium
-------------------
begin : 16/05/2016
copyright : (C) 2016 by Artem Fedoskin
@@ -13,6 +13,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
+
#ifndef TRIXELNODE_H_
#define TRIXELNODE_H_
#include <QSGSimpleTextureNode>
@@ -21,7 +22,6 @@
class PlanetItemNode;
class SkyMapLite;
-class PointNode;
class LineNode;
class QSGOpacityNode;
diff --git a/kstars/main.cpp b/kstars/main.cpp
index 7650cd3..ec83645 100644
--- a/kstars/main.cpp
+++ b/kstars/main.cpp
@@ -43,9 +43,9 @@
static const char description[] =
- I18N_NOOP("Desktop Planetarium");
+ I18N_NOOP("Desktop Planetarium");
static const char notice[] =
- I18N_NOOP("Some images in KStars are for non-commercial use only. See README.images.");
+ I18N_NOOP("Some images in KStars are for non-commercial use only. See README.images.");
int main(int argc, char *argv[])
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
* enable high dpi support
*/
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
- #ifndef KSTARS_LITE
+#ifndef KSTARS_LITE
KCrash::initialize();
KLocalizedString::setApplicationDomain("kstars");
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
aboutData.addCredit(i18n("Ana-Maria Constantin"), i18n("Technical documentation on Astronomy and KStars") );
aboutData.addCredit(i18n("Andrew Stepanenko"), i18n("Guiding code based on lin_guider") );
aboutData.addCredit(i18n("Nuno Pinheiro"), i18n("Artwork") );
- aboutData.addCredit(i18n("Utkarsh Simha"), i18n("Improvements to observation plan execution, star hopper etc.") );
+ aboutData.addCredit(i18n("Utkarsh Simha"), i18n("Improvements to observation plan execution, star hopper etc.") );
aboutData.addCredit(i18n("Daniel Holler"), i18n("Extensive testing and suggestions for Ekos/INDI.") );
aboutData.addCredit(i18n("Stephane Lucas"), i18n("Extensive testing and suggestions for Ekos Scheduler.") );
@@ -135,7 +135,7 @@ int main(int argc, char *argv[])
if ( !ok ) {
qWarning() << "Unable to parse arguments: " ;
qWarning() << "Width: " << parser.value( "width" )
- << " Height: " << parser.value( "height" ) << endl;
+ << " Height: " << parser.value( "height" ) << endl;
return 1;
}
@@ -224,80 +224,41 @@ int main(int argc, char *argv[])
datestring.clear();
}
-#else
- Options::setAngularRulerColor("#ffffff");
- Options::setArtificialHorizonColor("#c82828");
- Options::setBoxBGColor("#223344");
- Options::setBoxGrabColor("#ff0000v");
- Options::setBoxTextColor("#ffffff");
- Options::setCBoundColor("#333333");
- Options::setCBoundHighColor("#555555");
- Options::setCLineColor("#555555");
- Options::setCNameColor("#aaaa77");
- Options::setColorSchemeFile("classic.colors");
- Options::setCompassColor("#ffffff");
- //Options::setDEGuideError("#00a5ff");
- //Options::setDSNameColor("#77aaaa");
- //Options::setEclColor("#666633");
- //Options::setEqColor("#ffffff");
- Options::setEquatorialGridColor("#445566");
- //Options::setHSTColor("#aa0000");
- Options::setHorizontalGridColor("#55aa33");
- //Options::setHorzColor("#55aa33");
- Options::setICColor("#443399");
- //Options::setMWColor("#112233");
- //Options::setMessColor("#00ff00");
- Options::setNGCColor("#006666");
- //Options::setObsListColor("#ffff00");
- //Options::setPNameColor("#aa7777");
- Options::setPlanetTrailColor("#996633");
- //Options::setRAGuideError("#00ff00");
- //Options::setSNameColor("#77aaaa");
- Options::setSatColor("#ff0000");
- Options::setSatLabelColor("#640000");
- Options::setSkyColor("#000022");
- Options::setSolverFOVColor("#ffffff");
- Options::setStarColorIntensity(4);
- Options::setStarColorMode(0);
- //Options::setStarHopRouteColor("#00ffff");
- Options::setSupernovaColor("#ffa500");
- //Options::setTargetColor("#88bb88");
- Options::setUserLabelColor("#ffffff");
- Options::setVisibleSatColor("#00ff00");
-
- Options::setShowEquatorialGrid(true);
- Options::setShowHorizontalGrid(true);
-
- //[Location]
- Options::setCityName("Saarbr├╝cken");
- Options::setCountryName("Germany");
- Options::setDST("EU");
- Options::setLatitude(49.233333333333334);
- Options::setLongitude(7);
- Options::setTimeZone(1);
-
- //[MainWindow]
- /*Options::setHeight 768("709");
- Options::setState("AAAA/wAAAAD9AAAAAQAAAAEAAAKAAAACb/wCAAAAAfsAAAAkAFcAaABhAHQAJwBzACAASQBuAHQAZQByAGUAcwB0AGkAbgBnAAAAADgAAAJvAAAAAAAAAAAAAAVWAAACYgAAAAQAAAAEAAAACAAAAAj8AAAAAQAAAAIAAAACAAAAGgBrAHMAdABhAHIAcwBUAG8AbwBsAEIAYQByAQAAAAD/////AAAAAAAAAAAAAAAWAHYAaQBlAHcAVABvAG8AbABCAGEAcgEAAAGT/////wAAAAAAAAAA");
- Options::setToolBarsMovable("Disabled");
- Options::setWidth 1366("1366");
- Options::setWindow-Maximized 768x1366("true");*/
-
- //[Satellites]
- Options::setShowSatellites("true");
-
- //[View]
- //Options::setFOVNames("
-
- //[WISettings]
- //Options::setScopeListWidget("4294967295");
-
- //[Xplanet]
- Options::setXplanetBackgroundColorValue("#000000");
- Options::setXplanetColor("#ff0000");
-
#endif
+ //Under construction
+ //[Location]
+ Options::setCityName("Saarbr├╝cken");
+ Options::setCountryName("Germany");
+ Options::setDST("EU");
+ Options::setLatitude(49.233333333333334);
+ Options::setLongitude(7);
+ Options::setTimeZone(1);
+ Options::setRunClock(false);
+
+ Options::setShowCBounds(true);
+ Options::setShowCLines(true);
+ Options::setShowSolarSystem(true);
+ Options::setShowEcliptic(true);
+ Options::setShowEquator(true);
+ Options::setShowEquatorialGrid(true);
+ Options::setShowHorizontalGrid(true);
+ Options::setShowGround(true);
+
+ //Labels
+ Options::setShowCometNames(true);
+ Options::setShowAsteroidNames(true);
+ Options::setShowAsteroids(true);
+ Options::setShowCNames(true);
+
+ Options::setAutoSelectGrid(false);
+
+ Options::setHideCBounds(true);
+ Options::setHideCLines(false);
+ Options::setHideOnSlew(true);
+ Options::setHideGrids(false);
+
+
// Create writable data dir if it does not exist
QDir writableDir;
writableDir.mkdir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
@@ -313,8 +274,8 @@ int main(int argc, char *argv[])
const QRegExp withProtocolChecker( QStringLiteral("^[a-zA-Z]+:") );
foreach (const QString &url, urls) {
const QUrl u = (withProtocolChecker.indexIn(url) == 0) ?
- QUrl::fromUserInput( url ) :
- QUrl::fromLocalFile(QDir::current().absoluteFilePath(url));
+ QUrl::fromUserInput( url ) :
+ QUrl::fromLocalFile(QDir::current().absoluteFilePath(url));
KStars::Instance()->openFITS(u);
}
diff --git a/kstars/skycomponents/skylabeler.cpp b/kstars/skycomponents/skylabeler.cpp
index 5b75952..6311d38 100644
--- a/kstars/skycomponents/skylabeler.cpp
+++ b/kstars/skycomponents/skylabeler.cpp
@@ -57,17 +57,31 @@ SkyLabeler* SkyLabeler::Instance( )
void SkyLabeler::setZoomFont()
{
+#ifndef KSTARS_LITE
QFont font( m_p.font() );
+#else
+ QFont font( m_stdFont );
+#endif
int deltaSize = 0;
if ( Options::zoomFactor() < 2.0 * MINZOOM )
deltaSize = 2;
else if ( Options::zoomFactor() < 10.0 * MINZOOM )
deltaSize = 1;
+#ifndef KSTARS_LITE
if ( deltaSize ) {
font.setPointSize( font.pointSize() - deltaSize );
m_p.setFont( font );
}
+#else
+ if ( deltaSize ) {
+ font.setPointSize( font.pointSize() - deltaSize );
+ }
+ if(m_drawFont.pointSize() != font.pointSize()) {
+ m_drawFont = font;
+ SkyMapLite::Instance()->setFontSizeChanged(true);
+ }
+#endif
}
double SkyLabeler::ZoomOffset()
@@ -79,18 +93,28 @@ double SkyLabeler::ZoomOffset()
//----- Constructor ---------------------------------------------------------//
SkyLabeler::SkyLabeler() :
- m_maxY(0),
- m_size(0),
- m_fontMetrics( QFont() ),
- m_picture(-1),
- labelList( NUM_LABEL_TYPES ),
- m_proj(0)
+ m_maxY(0),
+ m_size(0),
+ m_fontMetrics( QFont() ),
+ m_picture(-1),
+ labelList( NUM_LABEL_TYPES ),
+ m_proj(0)
{
m_errors = 0;
m_minDeltaX = 30; // when to merge two adjacent regions
m_marks = m_hits = m_misses = m_elements = 0;
-}
+#ifdef KSTARS_LITE
+ //Painter is needed to get default font and we use it only once to have only one warning
+ m_stdFont = QFont();
+
+ //For some reason there is no point size in default font on Android
+#ifdef ANDROID
+ m_stdFont.setPointSize(10);
+#endif
+
+#endif
+}
SkyLabeler::~SkyLabeler()
{
@@ -170,18 +194,29 @@ bool SkyLabeler::drawNameLabel(SkyObject* obj, const QPointF& _p)
void SkyLabeler::setFont( const QFont& font )
{
+#ifndef KSTARS_LITE
m_p.setFont( font );
+#else
+ m_drawFont = font;
+#endif
m_fontMetrics = QFontMetrics( font );
}
void SkyLabeler::setPen(const QPen& pen)
{
+#ifndef KSTARS_LITE
+ Q_UNUSED(pen);
m_p.setPen(pen);
+#endif
}
void SkyLabeler::shrinkFont( int delta )
{
+#ifndef KSTARS_LITE
QFont font( m_p.font() );
+#else
+ QFont font( m_drawFont );
+#endif
font.setPointSize( font.pointSize() - delta );
setFont( font );
}
@@ -282,9 +317,9 @@ void SkyLabeler::reset()
// ----- Set up Projector ---
m_proj = skyMap->projector();
- m_stdFont = QFont( skyMap->skyFont() );
+ //m_stdFont was moved to constructor
setZoomFont();
- m_skyFont = skyMap->skyFont() ;
+ m_skyFont = m_drawFont;
m_fontMetrics = QFontMetrics( m_skyFont );
m_minDeltaX = (int) m_fontMetrics.width("MMMMM");
// ----- Set up Zoom Dependent Offset -----
@@ -341,7 +376,7 @@ void SkyLabeler::draw(QPainter& p)
// No, that's definitely better to leave to people to figure out on their own.
if( m_p.isActive() ) { m_p.end(); }
m_picture.play(&p); //can't replay while it's being painted on
- //this is also undocumented btw.
+ //this is also undocumented btw.
//m_p.begin(&m_picture);
}
diff --git a/kstars/skycomponents/skylabeler.h b/kstars/skycomponents/skylabeler.h
index 2597d1a..2951e2f 100644
--- a/kstars/skycomponents/skylabeler.h
+++ b/kstars/skycomponents/skylabeler.h
@@ -330,6 +330,10 @@ public:
*/
void printInfo();
+ inline QFont stdFont() { return m_stdFont; }
+ inline QFont skyFont() { return m_skyFont; }
+ inline QFont drawFont() { return m_drawFont; }
+
int hits() { return m_hits; }
int marks() { return m_marks; }
@@ -353,6 +357,11 @@ private:
QFont m_stdFont, m_skyFont;
QFontMetricsF m_fontMetrics;
+ //In KStars Lite this font should be used wherever font of m_p was changed or used
+#ifdef KSTARS_LITE
+ QFont m_drawFont;
+#endif
+
QPainter m_p;
QPicture m_picture;
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index f6fb132..62e0fe3 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -26,7 +26,7 @@
#include "projections/azimuthalequidistantprojector.h"
#include "projections/equirectangularprojector.h"
-#include "solarsystemsinglecomponent.h"
+#include "skylabeler.h"
#include "Options.h"
#include "skymesh.h"
@@ -125,6 +125,8 @@ QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
n->update();
}
+ //Reset m_fontSizeChanged
+ setFontSizeChanged(false);
return n;
}
@@ -369,6 +371,7 @@ void SkyMapLite::slotZoomDefault() {
void SkyMapLite::setZoomFactor(double factor) {
Options::setZoomFactor( KSUtils::clamp(factor, MINZOOM, MAXZOOM) );
+
forceUpdate();
emit zoomChanged();
}
@@ -504,37 +507,39 @@ QVector<QVector<QPixmap*>> SkyMapLite::getImageCache()
return imageCache;
}
-QSGTexture *SkyMapLite::textToTexture(QString text, QColor color, QFont font) {
- QPainter painter;
+QSGTexture *SkyMapLite::textToTexture(QString text, QColor color, bool zoomFont) {
+ QFont f;
- QFontMetrics fm = painter.fontMetrics();
- QFont f = painter.font();
- if(font != f) {
- fm = QFontMetrics(font);
+ if(zoomFont) {
+ f = SkyLabeler::Instance()->drawFont();
+ } else {
+ f = SkyLabeler::Instance()->stdFont();
}
- if(m_skyFont != f) {
- m_skyFont = f;
- }
+ QFontMetrics fm(f);
int width = fm.width(text);
int height = fm.height();
QImage label(width, height, QImage::Format_ARGB32_Premultiplied);
label.fill(0);
- painter.begin(&label);
- painter.setPen( color );
- painter.drawText(0,height-fm.descent(),text);
+ m_painter.begin(&label);
- painter.end();
+ m_painter.setFont(f);
- QFile file("/home/polaris/label.png");
- file.open(QIODevice::WriteOnly);
- label.save(&file, "PNG");
+ m_painter.setPen( color );
+ m_painter.drawText(0,height - fm.descent(),text);
+
+ m_painter.end();
QSGTexture *texture = window()->createTextureFromImage(label,
QQuickWindow::TextureCanUseAtlas & QQuickWindow::TextureHasAlphaChannel);
+
+ /*texture->setFiltering(QSGTexture::Linear);
+ texture->setHorizontalWrapMode(QSGTexture::ClampToEdge);
+ texture->setVerticalWrapMode(QSGTexture::ClampToEdge);*/
+
return texture;
}
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 7d94488..fd647a3 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -21,6 +21,7 @@
#include "skyobjects/skyline.h"
#include <QTimer>
+#include <QPainter>
#include <config-kstars.h>
#include <QQuickItem>
@@ -41,18 +42,18 @@ class LinesItem;
class QSGTexture;
-/** @class SkyMapLite
- *
- *This is the main item that displays all SkyItems. After its instantiation it is reparanted
- *to an object with objectName SkyMapLiteWrapper in main.qml. To display SkyItems they are reparanted
- *to instance of SkyMapLite.
- *
- *SkyMapLite handles most user interaction events (both mouse and keyboard).
- *
- *@short Item for displaying sky objects; also handles user interaction events.
- *@author Artem Fedoskin
- *@version 1.0
- */
+ /** @class SkyMapLite
+ *
+ *This is the main item that displays all SkyItems. After its instantiation it is reparanted
+ *to an object with objectName SkyMapLiteWrapper in main.qml. To display SkyItems they are reparanted
+ *to instance of SkyMapLite.
+ *
+ *SkyMapLite handles most user interaction events (both mouse and keyboard).
+ *
+ *@short Item for displaying sky objects; also handles user interaction events.
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
class SkyMapLite : public QQuickItem {
@@ -84,14 +85,6 @@ public:
/** Destructor (empty) */
~SkyMapLite();
- /*enum Projection { Lambert,
- AzimuthalEquidistant,
- Orthographic,
- Equirectangular,
- Stereographic,
- Gnomonic,
- UnknownProjection };*/
-
/** @short Retrieve the Focus point; the position on the sky at the
*center of the skymap.
*@return a pointer to the central focus point of the sky map
@@ -242,7 +235,16 @@ public:
*/
QVector<QVector<QPixmap*>> getImageCache();
- QSGTexture *textToTexture(QString text, QColor color = QColor(255,255,255), QFont font = QFont());
+ /**
+ * @short creates QImage from text and converts it to QSGTexture
+ * @param color text color
+ * @param zoomFont if true zoom-dependent font from SkyLabeler will be used else standart
+ * font is used
+ * @return QSGTexture with text
+ * @note font size is set in SkyLabeler::SkyLabeler() by initializing m_stdFont with default font
+ */
+
+ QSGTexture *textToTexture(QString text, QColor color = QColor(255,255,255), bool zoomFont = false);
/**
* @short returns cached texture from textureCache.
@@ -273,9 +275,11 @@ public:
inline const Projector * projector() const { return m_proj; }
/**
- * @return font of labels
+ * @return true if font size was changed
*/
- inline QFont skyFont() const { return m_skyFont; }
+ inline bool fontSizeChanged() const { return m_fontSizeChanged; }
+
+ inline void setFontSizeChanged(bool val) { m_fontSizeChanged = val; }
/**
*@short Proxy method for SkyMapDrawAbstract::drawObjectLabels()
@@ -581,7 +585,10 @@ private:
static SkyMapLite *pinstance;
QQuickItem *m_SkyMapLiteWrapper;
- QFont m_skyFont;
+ // Used to notify zoom-dependent labels about font size change
+ bool m_fontSizeChanged;
+ // Used for drawing labels
+ QPainter m_painter;
static int starColorMode;
diff --git a/kstars/skymaplitevents.cpp b/kstars/skymapliteevents.cpp
index 415de50..eb9026d 100644
--- a/kstars/skymaplitevents.cpp
+++ b/kstars/skymapliteevents.cpp
@@ -272,12 +272,6 @@ void SkyMapLite::touchEvent( QTouchEvent *e) {
old_vec = QPointF(old_vec.x()/old_vec_len, old_vec.y()/old_vec_len);
new_vec = QPointF(new_vec.x()/new_vec_len, new_vec.y()/new_vec_len);
- if(rotation() > 360) {
- setRotation(0);
- } else if(rotation() < 0) {
- setRotation(360);
- }
-
double old_atan = qAtan2(old_vec.y(), old_vec.x());
double new_atan = qAtan2(new_vec.y(), new_vec.x());
@@ -290,10 +284,16 @@ void SkyMapLite::touchEvent( QTouchEvent *e) {
//Get the angle between two vectors
double delta = new_atan - old_atan;
+ if(rotation() > 360) {
+ setRotation(0);
+ } else if(rotation() < 0) {
+ setRotation(360);
+ }
+
//Scale the angle to speed up the rotation
delta *= 100;
setRotation(rotation() + delta);
- update(); //Apply rotation
+ //update(); //Apply rotation
//Allow movement of SkyMapLite while rotating or zooming
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, pinchCenter,
@@ -352,7 +352,7 @@ void SkyMapLite::zoomInOrMagStep( const int modifier ) {
if ( modifier & Qt::AltModifier )
incMagLimit( modifier );
else if( modifier & Qt::MetaModifier) {//Used in pinch-to-zoom gesture
- setZoomFactor (Options::zoomFactor() + Options::zoomFactor()*0.04);
+ setZoomFactor (Options::zoomFactor() + Options::zoomFactor()*0.05);
}
else
setZoomFactor( Options::zoomFactor() * zoomFactor( modifier ) );
@@ -363,7 +363,7 @@ void SkyMapLite::zoomOutOrMagStep( const int modifier ) {
if ( modifier & Qt::AltModifier )
decMagLimit( modifier );
else if( modifier & Qt::MetaModifier) {//Used in pinch-to-zoom gesture
- setZoomFactor (Options::zoomFactor() - Options::zoomFactor()*0.04);
+ setZoomFactor (Options::zoomFactor() - Options::zoomFactor()*0.05);
}
else
setZoomFactor( Options::zoomFactor() / zoomFactor (modifier ) );