[Kstars-devel] KDE/kdeedu/kstars/kstars
Alexey Khudyakov
alexey.skladnoy at gmail.com
Sun Aug 16 12:31:27 CEST 2009
SVN commit 1011915 by khudyakov:
Replace ks data member with calls to KStars::Instance. This solution
isn't pretty but it's required for further reordering and simplification
of KStars initiliazation code.
Ideally those calls to KStars intance should be absent.
CCMAIL: kstars-devel at kde.org
M +20 -17 skymap.cpp
M +0 -1 skymap.h
M +22 -20 skymapdraw.cpp
M +18 -13 skymapevents.cpp
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #1011914:1011915
@@ -74,10 +74,11 @@
return pinstance;
}
-SkyMap::SkyMap()
- : QWidget( KStars::Instance() ), computeSkymap(true), angularDistanceMode(false),
- ks( KStars::Instance() ), data( KStarsData::Instance() ), pmenu(0), sky(0), sky2(0), IBoxes(0),
- ClickedObject(0), FocusObject(0), TransientObject(0)
+SkyMap::SkyMap() :
+ QWidget( KStars::Instance() ),
+ computeSkymap(true), angularDistanceMode(false),
+ data( KStarsData::Instance() ), pmenu(0), sky(0), sky2(0), IBoxes(0),
+ ClickedObject(0), FocusObject(0), TransientObject(0)
{
m_Scale = 1.0;
@@ -104,7 +105,7 @@
sky = new QPixmap( width(), height() );
sky2 = new QPixmap( width(), height() );
- pmenu = new KSPopupMenu( ks );
+ pmenu = new KSPopupMenu( KStars::Instance() );
//Initialize Transient label stuff
TransientTimeout = 100; //fade label color every 0.1 sec
@@ -252,6 +253,8 @@
}
void SkyMap::slotCenter() {
+ KStars* kstars = KStars::Instance();
+
setFocusPoint( clickedPoint() );
if ( Options::useAltAz() )
focusPoint()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
@@ -283,9 +286,9 @@
//destination to previous object...
setFocusObject( ClickedObject );
Options::setIsTracking( true );
- if ( ks ) {
- ks->actionCollection()->action("track_object")->setIcon( KIcon("document-encrypt") );
- ks->actionCollection()->action("track_object")->setText( i18n( "Stop &Tracking" ) );
+ if ( kstars ) {
+ kstars->actionCollection()->action("track_object")->setIcon( KIcon("document-encrypt") );
+ kstars->actionCollection()->action("track_object")->setText( i18n( "Stop &Tracking" ) );
}
//If focusObject is a SS body and doesn't already have a trail, set the temporaryTrail
@@ -310,19 +313,19 @@
focusPoint()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
//display coordinates in statusBar
- if ( ks ) {
+ if ( kstars ) {
if ( Options::showAltAzField() ) {
QString sX = focusPoint()->az()->toDMSString();
QString sY = focusPoint()->alt()->toDMSString(true);
if ( Options::useAltAz() && Options::useRefraction() )
sY = refract( focusPoint()->alt(), true ).toDMSString(true);
QString s = sX + ", " + sY;
- ks->statusBar()->changeItem( s, 1 );
+ kstars->statusBar()->changeItem( s, 1 );
}
if ( Options::showRADecField() ) {
QString s = focusPoint()->ra()->toHMSString() + ", " + focusPoint()->dec()->toDMSString(true);
- ks->statusBar()->changeItem( s, 2 );
+ kstars->statusBar()->changeItem( s, 2 );
}
}
@@ -451,7 +454,7 @@
angularDistance = AngularRuler.angularSize();
sbMessage += i18n( "Angular distance: %1", angularDistance.toDMSString() );
- ks->statusBar()->changeItem( sbMessage, 0 );
+ KStars::Instance()->statusBar()->changeItem( sbMessage, 0 );
AngularRuler.clear();
}
@@ -489,7 +492,7 @@
KUrl url ( sURL );
if ( url.isEmpty() ) return;
- ks->addImageViewer( url, clickedObject()->messageFromTitle(message) );
+ KStars::Instance()->addImageViewer( url, clickedObject()->messageFromTitle(message) );
}
void SkyMap::slotInfo() {
@@ -525,7 +528,6 @@
foreach ( SkyObject *o, data->skyComposite()->labelObjects() ) {
if ( o == object ) return true;
}
-
return false;
}
@@ -563,7 +565,7 @@
KMessageBox::sorry( this, i18n("No object selected."), i18n("Object Details") );
return;
}
- QPointer<DetailDialog> detail = new DetailDialog( clickedObject(), data->ut(), data->geo(), ks );
+ QPointer<DetailDialog> detail = new DetailDialog( clickedObject(), data->ut(), data->geo(), KStars::Instance() );
detail->exec();
delete detail;
}
@@ -574,8 +576,9 @@
data->clock()->setManualMode( !clockSlewing );
clockSlewing = !clockSlewing;
// don't change automatically the DST status
- if( ks )
- ks->updateTime( false );
+ KStars* kstars = KStars::Instance();
+ if( kstars )
+ kstars->updateTime( false );
}
}
--- trunk/KDE/kdeedu/kstars/kstars/skymap.h #1011914:1011915
@@ -879,7 +879,6 @@
bool isPoleVisible;
double XRange;
- KStars *ks;
KStarsData *data;
KSPopupMenu *pmenu;
QPixmap *sky, *sky2;
--- trunk/KDE/kdeedu/kstars/kstars/skymapdraw.cpp #1011914:1011915
@@ -127,31 +127,33 @@
void SkyMap::drawOverlays( QPixmap *pm ) {
- if ( ks ) { //only if we are drawing in the GUI window
- QPainter p;
- p.begin( pm );
- p.setRenderHint(QPainter::Antialiasing, Options::useAntialias() );
+ if( !KStars::Instance() )
+ return;
- if ( Options::showHighlightedCBound() )
- drawHighlightConstellation( p );
+ QPainter p;
+ p.begin( pm );
+ p.setRenderHint(QPainter::Antialiasing, Options::useAntialias() );
- showFocusCoords( true );
- drawBoxes( p );
+ if ( Options::showHighlightedCBound() )
+ drawHighlightConstellation( p );
- //draw FOV symbol
- foreach( FOV* fov, KStarsData::Instance()->visibleFOVs ) {
- fov->draw(p, Options::zoomFactor());
- }
- drawTelescopeSymbols( p );
- drawObservingList( p );
- drawZoomBox( p );
+ showFocusCoords( true );
+ drawBoxes( p );
- if ( transientObject() ) drawTransientLabel( p );
- if (isAngleMode()) {
- updateAngleRuler();
- drawAngleRuler( p );
- }
+ //draw FOV symbol
+ foreach( FOV* fov, KStarsData::Instance()->visibleFOVs ) {
+ fov->draw(p, Options::zoomFactor());
}
+ drawTelescopeSymbols( p );
+ drawObservingList( p );
+ drawZoomBox( p );
+
+ if ( transientObject() )
+ drawTransientLabel( p );
+ if (isAngleMode()) {
+ updateAngleRuler();
+ drawAngleRuler( p );
+ }
}
void SkyMap::drawAngleRuler( QPainter &p ) {
--- trunk/KDE/kdeedu/kstars/kstars/skymapevents.cpp #1011914:1011915
@@ -57,7 +57,8 @@
// if ( testWState( Qt::WState_AutoMask ) ) updateMask();
// avoid phantom positions of infoboxes
- if ( ks && ( isVisible() || width() == ks->width() || height() == ks->height() ) ) {
+ KStars* kstars = KStars::Instance();
+ if ( kstars && ( isVisible() || width() == kstars->width() || height() == kstars->height() ) ) {
infoBoxes()->resize( width(), height() );
}
*sky = sky->scaled( width(), height() );
@@ -65,6 +66,7 @@
}
void SkyMap::keyPressEvent( QKeyEvent *e ) {
+ KStars* kstars = KStars::Instance();
QString s;
bool arrowKeyPressed( false );
bool shiftPressed( false );
@@ -144,14 +146,12 @@
case Qt::Key_Plus: //Zoom in
case Qt::Key_Equal:
- if ( ks )
- zoomInOrMagStep( e->modifiers() );
+ zoomInOrMagStep( e->modifiers() );
break;
case Qt::Key_Minus: //Zoom out
case Qt::Key_Underscore:
- if ( ks )
- zoomOutOrMagStep( e->modifiers() );
+ zoomOutOrMagStep( e->modifiers() );
break;
case Qt::Key_0: //center on Sun
@@ -293,7 +293,7 @@
}
if ( clickedObject() ) {
- ks->observingList()->slotAddObject();
+ kstars->observingList()->slotAddObject();
}
if ( orig ) {
@@ -451,7 +451,8 @@
}
void SkyMap::stopTracking() {
- if ( ks && Options::isTracking() ) ks->slotTrack();
+ KStars* kstars = KStars::Instance();
+ if ( kstars && Options::isTracking() ) kstars->slotTrack();
}
void SkyMap::keyReleaseEvent( QKeyEvent *e ) {
@@ -597,7 +598,8 @@
forceUpdate(); // must be new computed
} else { //mouse button not down
- if ( ks ) {
+ KStars* kstars = KStars::Instance();
+ if ( kstars ) {
QString sX, sY, s;
if ( Options::showAltAzField() ) {
@@ -608,14 +610,14 @@
sY = a.toDMSString(true); //true: force +/- symbol
s = sX + ", " + sY;
- ks->statusBar()->changeItem( s, 1 );
+ kstars->statusBar()->changeItem( s, 1 );
}
if ( Options::showRADecField() ) {
sX = mousePoint()->ra()->toHMSString();
sY = mousePoint()->dec()->toDMSString(true); //true: force +/- symbol
s = sX + ", " + sY;
- ks->statusBar()->changeItem( s, 2 );
+ kstars->statusBar()->changeItem( s, 2 );
}
}
}
@@ -675,6 +677,8 @@
}
void SkyMap::mousePressEvent( QMouseEvent *e ) {
+ KStars* kstars = KStars::Instance();
+
//did we Grab an infoBox?
if ( e->button() == Qt::LeftButton && infoBoxes()->grabBox( e ) ) {
update(); //refresh without redrawing skymap
@@ -722,8 +726,8 @@
clickedObject()->showPopupMenu( pmenu, QCursor::pos() );
}
- if ( ks && e->button() == Qt::LeftButton ) {
- ks->statusBar()->changeItem( clickedObject()->translatedLongName(), 0 );
+ if ( kstars && e->button() == Qt::LeftButton ) {
+ kstars->statusBar()->changeItem( clickedObject()->translatedLongName(), 0 );
}
} else {
//Empty sky selected. If left-click, display "nothing" in the status bar.
@@ -732,7 +736,8 @@
switch (e->button()) {
case Qt::LeftButton:
- if ( ks ) ks->statusBar()->changeItem( i18n( "Empty sky" ), 0 );
+ if ( kstars )
+ kstars->statusBar()->changeItem( i18n( "Empty sky" ), 0 );
break;
case Qt::RightButton:
{
More information about the Kstars-devel
mailing list