[Kstars-devel] KDE/kdeedu/kstars/kstars/tools

Alexey Khudyakov alexey.skladnoy at gmail.com
Tue Jun 16 20:05:03 CEST 2009


SVN commit 982730 by khudyakov:

* Replace switch with casts with single cast. Also case when Object1 is Moon weren't
handled. 

* Change indentation to make code more readable. 

CCMAIL: kstars-devel at kde.org


 M  +14 -24    ksconjunct.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/tools/ksconjunct.cpp #982729:982730
@@ -131,32 +131,22 @@
 
   // FIXME: This should be virtual functions or whatever
   if( Object1->isSolarSystem() ) {
-      switch( Object1->type() ) {
-      case 2: {
-          KSPlanet *Planet = (KSPlanet *)Object1;
-          Planet->findPosition(&num, geoPlace->lat(), &LST, (KSPlanetBase *)m_Earth);
-          break;
-      }
-      case 9: {
-          KSComet *Comet = (KSComet *)Object1;
-          Comet->findPosition(&num, geoPlace->lat(), &LST, (KSPlanetBase *)m_Earth);
-          break;
-      }
-      case 10: {
-          KSAsteroid *Asteroid = (KSAsteroid *)Object1;
-          Asteroid->findPosition(&num, geoPlace->lat(), &LST, (KSPlanetBase *)m_Earth);
-          break;
-      }
-      }
-  }
-  else
+      KSPlanetBase* p = reinterpret_cast<KSPlanetBase*>(Object1);
+      p->findPosition(&num, geoPlace->lat(), &LST, m_Earth);
+  } else {
       Object1->updateCoords( &num );
+  }
 
-  Object2->findPosition(&num, geoPlace->lat(), &LST, (KSPlanetBase *)m_Earth);
-  if(opposition) {  Object2->setRA( Object2->ra()->Hours() + 12.0); Object2->setDec( -Object2->dec()->Degrees()); }
-   dist.setRadians(Object1 -> angularDistanceTo(Object2).radians());
-  if(opposition) {  Object2->setRA( Object2->ra()->Hours() - 12.0); Object2->setDec( -Object2->dec()->Degrees()); }
-  
+  Object2->findPosition(&num, geoPlace->lat(), &LST, m_Earth);
+  if(opposition) {
+      Object2->setRA( Object2->ra()->Hours() + 12.0);
+      Object2->setDec( -Object2->dec()->Degrees());
+  }
+  dist.setRadians(Object1 -> angularDistanceTo(Object2).radians());
+  if(opposition) {
+      Object2->setRA( Object2->ra()->Hours() - 12.0);
+      Object2->setDec( -Object2->dec()->Degrees());
+  }
   return dist;
 }
 


More information about the Kstars-devel mailing list