summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-09-21 14:18:23 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-09-21 14:18:23 (GMT)
commitd0ff31b443de6b7de21e2e75cd370eefa89b8985 (patch)
tree205cdb287a40bb2e8403f25b8a9b89b9928b7245
parent7d0b855e0cc2c9229441ca2749525f8ab01222c1 (diff)
Probable fix of bug with disappearing and re-appearing labels in regular KStars. Need to test on other devices
-rw-r--r--kstars/skycomponents/skylabeler.cpp83
-rw-r--r--kstars/skycomponents/skylabeler.h16
-rw-r--r--kstars/skycomponents/skymapcomposite.cpp2
-rw-r--r--kstars/skymaplite.cpp5
-rw-r--r--kstars/skymaplite.h21
5 files changed, 73 insertions, 54 deletions
diff --git a/kstars/skycomponents/skylabeler.cpp b/kstars/skycomponents/skylabeler.cpp
index de5ad7a..ff97ba5 100644
--- a/kstars/skycomponents/skylabeler.cpp
+++ b/kstars/skycomponents/skylabeler.cpp
@@ -24,9 +24,7 @@
#include "Options.h"
#include "kstarsdata.h" // MINZOOM
-#ifndef KSTARS_LITE
#include "skymap.h"
-#endif
#include "projections/projector.h"
//---------------------------------------------------------------------------//
@@ -92,29 +90,19 @@ 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()
{
for (int y = 0; y < screenRows.size(); y++ ) {
@@ -203,21 +191,21 @@ void SkyLabeler::setFont( const QFont& font )
void SkyLabeler::setPen(const QPen& pen)
{
-#ifdef KSTARS_LITE
- Q_UNUSED(pen);
-#else
- m_p.setPen(pen);
-#endif
+ #ifdef KSTARS_LITE
+ Q_UNUSED(pen);
+ #else
+ 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 );
+ #ifndef KSTARS_LITE
+ QFont font( m_p.font() );
+ #else
+ QFont font( m_drawFont );
+ #endif
+ font.setPointSize( font.pointSize() - delta );
setFont( font );
}
@@ -239,15 +227,24 @@ void SkyLabeler::getMargins( const QString& text, float *left,
float sideMargin = m_fontMetrics.width("MM") + width / 2.0;
// Create the margins within which it is okay to draw the label
- *right = m_p.window().width() - sideMargin;
+ double winHeight;
+ double winWidth;
+#ifdef KSTARS_LITE
+ winHeight = SkyMapLite::Instance()->height();
+ winWidth = SkyMapLite::Instance()->width();
+#else
+ winHeight = m_p.window().height();
+ winWidth = m_p.window().width();
+#endif
+
+ *right = winWidth - sideMargin;
*left = sideMargin;
*top = height;
- *bot = m_p.window().height() - 2.0 * height;
+ *bot = winHeight - 2.0 * height;
}
void SkyLabeler::reset( SkyMap* skyMap )
{
-
// ----- Set up Projector ---
m_proj = skyMap->projector();
// ----- Set up Painter -----
@@ -265,6 +262,7 @@ void SkyLabeler::reset( SkyMap* skyMap )
m_skyFont = m_p.font();
m_fontMetrics = QFontMetrics( m_skyFont );
m_minDeltaX = (int) m_fontMetrics.width("MMMMM");
+
// ----- Set up Zoom Dependent Offset -----
m_offset = SkyLabeler::ZoomOffset();
@@ -370,18 +368,14 @@ void SkyLabeler::reset()
void SkyLabeler::draw(QPainter& p)
{
-#ifdef KSTARS_LITE
- Q_UNUSED(p)
-#else
//FIXME: need a better soln. Apparently starting a painter
//clears the picture.
// But it's not like that's something that should be in the docs, right?
// 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.
- m_p.begin(&m_picture);
-#endif
+ //this is also undocumented btw.
+ //m_p.begin(&m_picture);
}
// We use Run Length Encoding to hold the information instead of an array of
@@ -524,6 +518,7 @@ bool SkyLabeler::markRegion( qreal left, qreal right, qreal top, qreal bot )
return true;
}
+
void SkyLabeler::addLabel( SkyObject *obj, SkyLabeler::label_t type )
{
bool visible = false;
@@ -532,14 +527,16 @@ void SkyLabeler::addLabel( SkyObject *obj, SkyLabeler::label_t type )
labelList[ (int)type ].append( SkyLabel( p, obj ) );
}
-void SkyLabeler::addLabel(SkyObject *obj, QPointF pos, label_t type) {
- labelList[ (int)type ].append( SkyLabel( pos, obj ) );
-}
+#ifdef KSTARS_LITE
+ void SkyLabeler::addLabel(SkyObject *obj, QPointF pos, label_t type) {
+ labelList[ (int)type ].append( SkyLabel( pos, obj ) );
+ }
+#endif
void SkyLabeler::drawQueuedLabels()
{
KStarsData* data = KStarsData::Instance();
-
+
resetFont();
m_p.setPen( QColor( data->colorScheme()->colorNamed( "PNameColor" ) ) );
drawQueuedLabelsType( PLANET_LABEL );
diff --git a/kstars/skycomponents/skylabeler.h b/kstars/skycomponents/skylabeler.h
index 216439b..67151cf 100644
--- a/kstars/skycomponents/skylabeler.h
+++ b/kstars/skycomponents/skylabeler.h
@@ -1,9 +1,9 @@
/***************************************************************************
- skylabeler.h - K Desktop Planetarium
- -------------------
- begin : 2007-07-10
- copyright : (C) 2007 by James B. Bowlin
- email : bowlin@mindspring.com
+ skylabeler.h - K Desktop Planetarium
+ -------------------
+ begin : 2007-07-10
+ copyright : (C) 2007 by James B. Bowlin
+ email : bowlin@mindspring.com
***************************************************************************/
/***************************************************************************
@@ -262,12 +262,13 @@ public:
*/
void addLabel( SkyObject *obj, label_t type );
+#ifdef KSTARS_LITE
/**
* @short queues the label in the "type" buffer for later drawing. Doesn't calculate the position of
* SkyObject but uses pos as a position of label.
*/
void addLabel(SkyObject *obj, QPointF pos, label_t type);
-
+#endif
/**
*@short draws the labels stored in all the buffers. You can change the
* priority by editing the .cpp file and changing the order in which
@@ -278,7 +279,7 @@ public:
/**
* @short a convenience routine that draws all the labels from a single
- * buffer. Currently this is only called from within draw() above.
+ * buffer. Currently this is only called from within draw() above.
*/
void drawQueuedLabelsType( SkyLabeler::label_t type );
@@ -335,6 +336,7 @@ public:
#ifdef KSTARS_LITE
inline QFont drawFont() { return m_drawFont; }
#endif
+
int hits() { return m_hits; }
int marks() { return m_marks; }
diff --git a/kstars/skycomponents/skymapcomposite.cpp b/kstars/skycomponents/skymapcomposite.cpp
index 442e352..1627981 100644
--- a/kstars/skycomponents/skymapcomposite.cpp
+++ b/kstars/skycomponents/skymapcomposite.cpp
@@ -242,7 +242,6 @@ void SkyMapComposite::draw( SkyPainter *skyp )
{
Q_UNUSED(skyp)
#ifndef KSTARS_LITE
-
SkyMap *map = SkyMap::Instance();
KStarsData *data = KStarsData::Instance();
@@ -311,7 +310,6 @@ void SkyMapComposite::draw( SkyPainter *skyp )
m_ConstellationArt->draw( skyp );
}
-
m_CLines->draw( skyp );
m_Equator->draw( skyp );
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index 3fb9441..549334b 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -786,6 +786,11 @@ void SkyMapLite::setSlewing(bool newSlewing) {
}
}
+void SkyMapLite::setCenterLocked(bool centerLocked) {
+ m_centerLocked = centerLocked;
+ emit centerLockedChanged(centerLocked);
+}
+
void SkyMapLite::initStarImages()
{
if(isInitialized) {
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 7cb549b..a93224f 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -85,6 +85,10 @@ class SkyMapLite : public QQuickItem {
Q_PROPERTY(QStringList FOVSymbols READ getFOVSymbols NOTIFY symbolsFOVChanged)
/** true if SkyMapLite is being panned **/
Q_PROPERTY(bool slewing READ getSlewing WRITE setSlewing NOTIFY slewingChanged)
+ /**
+ * @short true if SkyMapLite is centered on an object and only pinch-to-zoom needs to be available
+ **/
+ Q_PROPERTY(bool centerLocked READ getCenterLocked WRITE setCenterLocked NOTIFY centerLockedChanged)
protected:
/** Constructor. **/
explicit SkyMapLite();
@@ -340,16 +344,21 @@ public:
void initStarImages();
/**
- * @short getClickedPointLite getter for m_ClickedPointLite
+ * @short getter for clickedPointLite
*/
SkyPointLite *getClickedPointLite() { return m_ClickedPointLite; }
/**
- * @short getClickedObjectLite getter for m_ClickedObjectLite
+ * @short getter for clickedObjectLite
*/
SkyObjectLite *getClickedObjectLite() { return m_ClickedObjectLite; }
/**
+ * @short getter for centerLocked
+ */
+ bool getCenterLocked() { return m_centerLocked; }
+
+ /**
* @short Proxy method for SkyMapDrawAbstract::drawObjectLabels()
*/
//inline void drawObjectLabels( QList< SkyObject* >& labelObjects ) { dynamic_cast<SkyMapDrawAbstract *>(m_SkyMapDraw)->drawObjectLabels( labelObjects ); }
@@ -364,6 +373,11 @@ public:
*/
void setSlewing(bool newSlewing);
+ /**
+ * @short sets whether SkyMapLite is centered on an object and locked(olny pinch-to-zoom is available)
+ */
+ void setCenterLocked(bool centerLocked);
+
public slots:
/** Called whenever wrappers' width or height are changed. Probably will be used to
* update positions of items.
@@ -470,6 +484,7 @@ signals:
/** Emitted when SkyMapLite is being slewed or slewing is finished **/
void slewingChanged(bool);
+ void centerLockedChanged(bool);
protected:
/** Process keystrokes:
* @li arrow keys Slew the map
@@ -613,6 +628,8 @@ private:
SkyPointLite *m_ClickedPointLite;
SkyObjectLite *m_ClickedObjectLite;
+ bool m_centerLocked;
+
//SkyLine AngularRuler; //The line for measuring angles in the map
QRect ZoomRect; //The manual-focus circle.