[kstars] kstars: Fixing a few satellite issues including label color. Please test.
Jasem Mutlaq
mutlaqja at ikarustech.com
Thu Dec 1 15:47:59 UTC 2016
Git commit 58b197d0c8861dfb7411db320b8f781aa4a65b0e by Jasem Mutlaq.
Committed on 01/12/2016 at 14:52.
Pushed by mutlaqja into branch 'master'.
Fixing a few satellite issues including label color. Please test.
CCMAIL:kstars-devel at kde.org
M +1 -1 kstars/data/chart.colors
M +1 -1 kstars/data/classic.colors
M +1 -1 kstars/data/moonless-night.colors
M +1 -0 kstars/kstars.cpp
M +18 -5 kstars/options/opssatellites.cpp
M +5 -1 kstars/options/opssatellites.ui
M +20 -7 kstars/skycomponents/satellitescomponent.cpp
M +6 -0 kstars/skycomponents/skylabeler.cpp
M +3 -1 kstars/skycomponents/skymapcomposite.cpp
M +1 -1 kstars/skyglpainter.h
M +1 -1 kstars/skypainter.h
M +18 -10 kstars/skyqpainter.cpp
M +1 -1 kstars/skyqpainter.h
https://commits.kde.org/kstars/58b197d0c8861dfb7411db320b8f781aa4a65b0e
diff --git a/kstars/data/chart.colors b/kstars/data/chart.colors
index 6e4616a..7ca5dba 100644
--- a/kstars/data/chart.colors
+++ b/kstars/data/chart.colors
@@ -28,7 +28,7 @@
#990000 :ObsListColor
#00FF00 :VisibleSatColor
#FF0000 :SatColor
-#640000 :SatLabelColor
+#660000 :SatLabelColor
#FFA500 :SupernovaColor
#00FF00 :RAGuideError
#00A5FF :DEGuideError
diff --git a/kstars/data/classic.colors b/kstars/data/classic.colors
index c327ddc..2b24416 100644
--- a/kstars/data/classic.colors
+++ b/kstars/data/classic.colors
@@ -28,7 +28,7 @@
#FFFF00 :ObsListColor
#00FF00 :VisibleSatColor
#FF0000 :SatColor
-#640000 :SatLabelColor
+#BCAE12 :SatLabelColor
#FFA500 :SupernovaColor
#00FF00 :RAGuideError
#00A5FF :DEGuideError
diff --git a/kstars/data/moonless-night.colors b/kstars/data/moonless-night.colors
index ddf919a..0a48f76 100644
--- a/kstars/data/moonless-night.colors
+++ b/kstars/data/moonless-night.colors
@@ -28,7 +28,7 @@
#FF0000 :ObsListColor
#00FF00 :VisibleSatColor
#FF0000 :SatColor
-#640000 :SatLabelColor
+#AAAA7F :SatLabelColor
#FFA500 :SupernovaColor
#00FF00 :RAGuideError
#00A5FF :DEGuideError
diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index 2112f31..41dd993 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -270,6 +270,7 @@ void KStars::applyConfig( bool doApplyFocus ) {
actionCollection()->action("show_horizon" )->setChecked( Options::showGround() );
actionCollection()->action("show_flags" )->setChecked( Options::showFlags() );
actionCollection()->action("show_supernovae" )->setChecked( Options::showSupernovae() );
+ actionCollection()->action("show_satellites" )->setChecked( Options::showSatellites() );
statusBar()->setVisible( Options::showStatusBar() );
//color scheme
diff --git a/kstars/options/opssatellites.cpp b/kstars/options/opssatellites.cpp
index 696f757..36c4764 100644
--- a/kstars/options/opssatellites.cpp
+++ b/kstars/options/opssatellites.cpp
@@ -26,6 +26,7 @@
#include "skymapcomposite.h"
#include "skycomponents/satellitescomponent.h"
#include "satellitegroup.h"
+#include "skymap.h"
static const char *satgroup_strings_context = "Satellite group name";
@@ -154,18 +155,22 @@ void OpsSatellites::slotApply()
QStandardItem* sat_item;
// Retrieve each satellite in the list and select it if checkbox is checked
- for ( int i=0; i<m_Model->rowCount( SatListTreeView->rootIndex() ); ++i ) {
+ for ( int i=0; i<m_Model->rowCount( SatListTreeView->rootIndex() ); ++i )
+ {
group_index = m_Model->index( i, 0, SatListTreeView->rootIndex() );
group_item = m_Model->itemFromIndex( group_index );
- for ( int j=0; j<m_Model->rowCount( group_item->index() ); ++j ) {
+ for ( int j=0; j<m_Model->rowCount( group_item->index() ); ++j )
+ {
sat_index = m_Model->index( j, 0, group_index );
sat_item = m_Model->itemFromIndex( sat_index );
sat_name = sat_item->data( 0 ).toString();
Satellite *sat = data->skyComposite()->satellites()->findSatellite( sat_name );
- if ( sat ) {
- if ( sat_item->checkState() == Qt::Checked ) {
+ if ( sat )
+ {
+ if ( sat_item->checkState() == Qt::Checked )
+ {
int rc = sat->updatePos();
// If position calculation fails, unselect it
if (rc == 0)
@@ -179,7 +184,9 @@ void OpsSatellites::slotApply()
sat->setSelected( false );
sat_item->setCheckState(Qt::Unchecked);
}
- } else {
+ }
+ else
+ {
sat->setSelected( false );
}
}
@@ -187,6 +194,12 @@ void OpsSatellites::slotApply()
}
Options::setSelectedSatellites( selected_satellites );
+
+ // update time for all objects because they might be not initialized
+ // it's needed when using horizontal coordinates
+ KStars::Instance()->data()->setFullTimeUpdate();
+ KStars::Instance()->updateTime();
+ KStars::Instance()->map()->forceUpdate();
}
void OpsSatellites::slotCancel()
diff --git a/kstars/options/opssatellites.ui b/kstars/options/opssatellites.ui
index 224d381..c376351 100644
--- a/kstars/options/opssatellites.ui
+++ b/kstars/options/opssatellites.ui
@@ -119,6 +119,10 @@
<resources/>
<connections/>
<buttongroups>
- <buttongroup name="satelliteButtonGroup"/>
+ <buttongroup name="satelliteButtonGroup">
+ <property name="exclusive">
+ <bool>false</bool>
+ </property>
+ </buttongroup>
</buttongroups>
</ui>
diff --git a/kstars/skycomponents/satellitescomponent.cpp b/kstars/skycomponents/satellitescomponent.cpp
index fcc3177..d956d44 100644
--- a/kstars/skycomponents/satellitescomponent.cpp
+++ b/kstars/skycomponents/satellitescomponent.cpp
@@ -34,6 +34,7 @@
#include "ksfilereader.h"
#include "skylabeler.h"
#include "kstarsdata.h"
+#include "skymap.h"
SatellitesComponent::SatellitesComponent( SkyComposite *parent ) :
SkyComponent( parent )
@@ -103,16 +104,28 @@ void SatellitesComponent::draw( SkyPainter *skyp )
if( ! selected() )
return;
- foreach( SatelliteGroup *group, m_groups ) {
- for ( int i=0; i<group->size(); i++ ) {
+ bool hideLabels = (!Options::showSatellitesLabels() || ( SkyMap::Instance()->isSlewing() && Options::hideLabels() ));
+
+ foreach( SatelliteGroup *group, m_groups )
+ {
+ for ( int i=0; i<group->size(); i++ )
+ {
Satellite *sat = group->at( i );
- if ( sat->selected() ) {
- if ( Options::showVisibleSatellites() ) {
+ if ( sat->selected() )
+ {
+ bool drawn = false;
+ if ( Options::showVisibleSatellites() )
+ {
if ( sat->isVisible() )
- skyp->drawSatellite( sat );
- } else {
- skyp->drawSatellite( sat );
+ drawn = skyp->drawSatellite( sat );
}
+ else
+ {
+ drawn = skyp->drawSatellite( sat );
+ }
+
+ if (drawn && !hideLabels)
+ SkyLabeler::AddLabel( sat, SkyLabeler::SATELLITE_LABEL );
}
}
}
diff --git a/kstars/skycomponents/skylabeler.cpp b/kstars/skycomponents/skylabeler.cpp
index 79357cd..7ec09e7 100644
--- a/kstars/skycomponents/skylabeler.cpp
+++ b/kstars/skycomponents/skylabeler.cpp
@@ -564,10 +564,16 @@ void SkyLabeler::drawQueuedLabels()
resetFont();
}
+ // No colors for these fellas? Just following planets along?
drawQueuedLabelsType( ASTEROID_LABEL );
drawQueuedLabelsType( COMET_LABEL );
+ m_p.setPen( QColor( data->colorScheme()->colorNamed( "SatLabelColor" ) ) );
+ drawQueuedLabelsType( SATELLITE_LABEL );
+ // Whelp we're here and we don't have a Rude Label color?
+ // Will just set it to Planet color since this is how it used to be!!
+ m_p.setPen( QColor( data->colorScheme()->colorNamed( "PNameColor" ) ) );
LabelList list = labelList[ RUDE_LABEL ];
for ( int i = 0; i < list.size(); i ++ ) {
drawRudeNameLabel( list.at(i).obj, list.at(i).o );
diff --git a/kstars/skycomponents/skymapcomposite.cpp b/kstars/skycomponents/skymapcomposite.cpp
index a798778..bc9baeb 100644
--- a/kstars/skycomponents/skymapcomposite.cpp
+++ b/kstars/skycomponents/skymapcomposite.cpp
@@ -287,7 +287,9 @@ void SkyMapComposite::draw( SkyPainter *skyp )
// FIXME: REGRESSION. Labeler now know nothing about infoboxes
// map->infoBoxes()->reserveBoxes( psky );
- if( KStars::Instance() ) {
+ // JM 2016-12-01: Why is this done this way?!! It's too inefficient
+ if( KStars::Instance() )
+ {
auto& obsList = KStarsData::Instance()->observingList()->sessionList();
if( Options::obsListText() )
foreach( QSharedPointer<SkyObject> obj_clone, obsList ) {
diff --git a/kstars/skyglpainter.h b/kstars/skyglpainter.h
index f571dfb..705ae89 100644
--- a/kstars/skyglpainter.h
+++ b/kstars/skyglpainter.h
@@ -48,7 +48,7 @@ public:
virtual void setBrush(const QBrush& brush);
virtual void setPen(const QPen& pen);
virtual void drawHorizon( bool filled, SkyPoint *labelPoint = 0, bool *drawLabel = 0);
- virtual void drawSatellite( Satellite* sat );
+ virtual bool drawSatellite( Satellite* sat );
virtual bool drawSupernova(Supernova* sup);
void drawText( int x, int y, const QString text, QFont font, QColor color );
virtual bool drawConstellationArtImage(ConstellationsArt *obj);
diff --git a/kstars/skypainter.h b/kstars/skypainter.h
index aff1431..be5fd18 100644
--- a/kstars/skypainter.h
+++ b/kstars/skypainter.h
@@ -142,7 +142,7 @@ public:
/** @short Draw a satellite
*/
- virtual void drawSatellite( Satellite* sat ) = 0;
+ virtual bool drawSatellite( Satellite* sat ) = 0;
/** @short Draw a Supernova
*/
diff --git a/kstars/skyqpainter.cpp b/kstars/skyqpainter.cpp
index ba65574..3df31b6 100644
--- a/kstars/skyqpainter.cpp
+++ b/kstars/skyqpainter.cpp
@@ -793,25 +793,31 @@ void SkyQPainter::drawHorizon(bool filled, SkyPoint* labelPoint, bool* drawLabel
}
}
-void SkyQPainter::drawSatellite( Satellite* sat ) {
- KStarsData *data = KStarsData::Instance();
+bool SkyQPainter::drawSatellite( Satellite* sat )
+{
+ if( !m_proj->checkVisibility(sat) )
+ return false;
+
QPointF pos;
bool visible = false;
- sat->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
+ //sat->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
pos = m_proj->toScreen( sat, true, &visible );
if( !visible || !m_proj->onScreen( pos ) )
- return;
+ return false;
- if ( Options::drawSatellitesLikeStars() ) {
+ if ( Options::drawSatellitesLikeStars() )
+ {
drawPointSource(pos, 3.5, 'B');
- } else {
+ }
+ else
+ {
if ( sat->isVisible() )
- setPen( data->colorScheme()->colorNamed( "VisibleSatColor" ) );
+ setPen( KStarsData::Instance()->colorScheme()->colorNamed( "VisibleSatColor" ) );
else
- setPen( data->colorScheme()->colorNamed( "SatColor" ) );
+ setPen( KStarsData::Instance()->colorScheme()->colorNamed( "SatColor" ) );
drawLine( QPoint( pos.x() - 0.5, pos.y() - 0.5 ), QPoint( pos.x() + 0.5, pos.y() - 0.5 ) );
drawLine( QPoint( pos.x() + 0.5, pos.y() - 0.5 ), QPoint( pos.x() + 0.5, pos.y() + 0.5 ) );
@@ -819,8 +825,10 @@ void SkyQPainter::drawSatellite( Satellite* sat ) {
drawLine( QPoint( pos.x() - 0.5, pos.y() + 0.5 ), QPoint( pos.x() - 0.5, pos.y() - 0.5 ) );
}
- if ( Options::showSatellitesLabels() )
- data->skyComposite()->satellites()->drawLabel( sat, pos );
+ return true;
+
+ //if ( Options::showSatellitesLabels() )
+ //data->skyComposite()->satellites()->drawLabel( sat, pos );
}
bool SkyQPainter::drawSupernova(Supernova* sup)
diff --git a/kstars/skyqpainter.h b/kstars/skyqpainter.h
index c16cc04..ebf244b 100644
--- a/kstars/skyqpainter.h
+++ b/kstars/skyqpainter.h
@@ -82,7 +82,7 @@ public:
virtual void drawObservingList(const QList<SkyObject*>& obs);
virtual void drawFlags();
virtual void drawHorizon( bool filled, SkyPoint *labelPoint = 0, bool *drawLabel = 0);
- virtual void drawSatellite( Satellite* sat );
+ virtual bool drawSatellite( Satellite* sat );
virtual void drawDeepSkySymbol(const QPointF& pos, int type, float size, float e,
float positionAngle);
virtual bool drawSupernova(Supernova* sup);
More information about the Kstars-devel
mailing list