Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CelestialBrowser Class Reference

#include <celestialbrowser.h>

Inheritance diagram for CelestialBrowser:

Inheritance graph
Collaboration diagram for CelestialBrowser:

Collaboration graph
List of all members.

Public Slots

void slotBrighter (bool)
void slotBrightest (bool)
void slotNearest (bool)
void slotRefresh ()
void slotRightClickOnStar (QListViewItem *, const QPoint &, int)
void slotWithPlanets (bool)

Public Member Functions

 CelestialBrowser (QWidget *parent, CelestiaCore *appCore)
 ~CelestialBrowser ()

Private Member Functions

QString getClassification (int c) const

Private Attributes

CelestiaCoreappCore
SimulationappSim
Selection browserSel
KdeAppparent
StarBrowser sbrowser

Constructor & Destructor Documentation

CelestialBrowser::CelestialBrowser QWidget *  parent,
CelestiaCore appCore
 

Definition at line 27 of file celestialbrowser.cpp.

References appCore, appSim, CelestiaCore::getSimulation(), parent, sbrowser, and StarBrowser::setSimulation().

00028     : CelestialBrowserBase( parent, i18n("Celestial Browser"))
00029 {
00030     this->parent = dynamic_cast<KdeApp*>(parent);
00031     this->appCore = appCore;
00032     this->appSim = appCore->getSimulation();
00033     listStars->setAllColumnsShowFocus(true);
00034     listStars->setRootIsDecorated(true);
00035     listStars->setColumnAlignment(1, Qt::AlignRight);
00036     listStars->setColumnAlignment(2, Qt::AlignRight);
00037     listStars->setColumnAlignment(3, Qt::AlignRight);
00038     listStars->setShowSortIndicator(true);
00039     
00040     sbrowser.setSimulation(appSim);
00041     radioNearest->setChecked(true);
00042     statusBar()->hide();
00043 }

CelestialBrowser::~CelestialBrowser  ) 
 

Definition at line 48 of file celestialbrowser.cpp.

00049 {
00050     // no need to delete child widgets, Qt does it all for us
00051 }


Member Function Documentation

QString CelestialBrowser::getClassification int  c  )  const [private]
 

Definition at line 172 of file celestialbrowser.cpp.

Referenced by slotRefresh().

00172                                                       {    
00173     QString cl;
00174     switch(c)
00175         {
00176         case Body::Planet:
00177             cl = i18n("Planet");
00178             break;
00179         case Body::Moon:
00180             cl = i18n("Moon");
00181             break;
00182         case Body::Asteroid:
00183             cl = i18n("Asteroid");
00184             break;
00185         case Body::Comet:
00186             cl = i18n("Comet");
00187             break;
00188         case Body::Spacecraft:
00189             cl = i18n("Spacecraft");
00190             break;
00191         case Body::Unknown:
00192         default:
00193             cl = i18n("-");
00194             break;
00195         }
00196     return cl;
00197 }

void CelestialBrowser::slotBrighter bool   )  [virtual, slot]
 

Reimplemented from CelestialBrowserBase.

Definition at line 76 of file celestialbrowser.cpp.

References sbrowser, StarBrowser::setPredicate(), and slotRefresh().

00077 {
00078     sbrowser.setPredicate(StarBrowser::BrighterStars);
00079     listStars->setSorting(2);
00080     slotRefresh();
00081 }

void CelestialBrowser::slotBrightest bool   )  [virtual, slot]
 

Reimplemented from CelestialBrowserBase.

Definition at line 66 of file celestialbrowser.cpp.

References sbrowser, StarBrowser::setPredicate(), and slotRefresh().

00067 {
00068     sbrowser.setPredicate(StarBrowser::BrightestStars);
00069     listStars->setSorting(3);
00070     slotRefresh();
00071 }

void CelestialBrowser::slotNearest bool   )  [virtual, slot]
 

Reimplemented from CelestialBrowserBase.

Definition at line 56 of file celestialbrowser.cpp.

References sbrowser, StarBrowser::setPredicate(), and slotRefresh().

00057 {
00058     sbrowser.setPredicate(StarBrowser::NearestStars);
00059     listStars->setSorting(1);
00060     slotRefresh();
00061 }

void CelestialBrowser::slotRefresh  )  [virtual, slot]
 

Reimplemented from CelestialBrowserBase.

Definition at line 96 of file celestialbrowser.cpp.

References astro::absToAppMag(), appSim, browserSel, Point3< T >::distanceFromOrigin(), Star::getAbsoluteMagnitude(), PlanetarySystem::getBody(), Star::getCatalogNumber(), Body::getClassification(), getClassification(), Body::getHeliocentricPosition(), Body::getName(), Simulation::getObserver(), SolarSystem::getPlanets(), Star::getPosition(), Observer::getPosition(), Body::getSatellites(), Universe::getSolarSystemCatalog(), Star::getSpectralType(), Universe::getStarCatalog(), StarDatabase::getStarName(), PlanetarySystem::getSystemSize(), Simulation::getTime(), Simulation::getUniverse(), KM_PER_AU, StarBrowser::listStars(), Selection::obj, StarBrowser::refresh(), sbrowser, stars, Selection::type, Point3< T >::x, UniversalCoord::x, Point3< T >::y, UniversalCoord::y, Point3< T >::z, and UniversalCoord::z.

Referenced by slotBrighter(), slotBrightest(), slotNearest(), and slotWithPlanets().

00097 {
00098     StarDatabase* stardb = appSim->getUniverse()->getStarCatalog();
00099     sbrowser.refresh();
00100     
00101     std::vector<const Star*> *stars = sbrowser.listStars(100);
00102     
00103     listStars->clear();  
00104     browserSel.obj = const_cast<Star*>((*stars)[0]);
00105     browserSel.type = Selection::Type_Star;
00106 
00107     SolarSystemCatalog* solarSystemCatalog = appSim->getUniverse()->getSolarSystemCatalog();
00108 
00109     UniversalCoord ucPos = appSim->getObserver().getPosition();
00110     Point3f obsPos( (double)ucPos.x * 1e-6,
00111                     (double)ucPos.y * 1e-6,
00112                     (double)ucPos.z * 1e-6);    
00113                     
00114     for (std::vector<const Star*>::iterator i = stars->begin(); 
00115          i != stars->end() ; 
00116          i++ )
00117     {
00118         const Star *star=(Star *)(*i);
00119 
00120         Point3f starPos = star->getPosition();
00121         Vec3d v(starPos.x - obsPos.x, 
00122                 starPos.y - obsPos.y, 
00123                 starPos.z - obsPos.z);
00124         double dist = v.length();
00125 
00126         QString starClass(star->getSpectralType());
00127         CelListViewItem *starItem = new CelListViewItem(listStars, stardb->getStarName(*star), dist, "ly",
00128                 astro::absToAppMag(star->getAbsoluteMagnitude(), dist),
00129                 star->getAbsoluteMagnitude(), starClass);
00130         
00131         SolarSystemCatalog::iterator iter = solarSystemCatalog->find(star->getCatalogNumber());
00132         if (iter != solarSystemCatalog->end())
00133         { 
00134             const PlanetarySystem* planets = 0;
00135             SolarSystem* solarSys = iter->second;
00136             planets = solarSys->getPlanets();
00137             
00138             for (int i = 0; i < solarSys->getPlanets()->getSystemSize(); i++)
00139             {
00140                 Body* body = solarSys->getPlanets()->getBody(i);
00141                 
00142                 Point3d bodyPos = body->getHeliocentricPosition(appSim->getTime());
00143                 double starBodyDist = bodyPos.distanceFromOrigin();
00144 
00145                 CelListViewItem *planetItem = new CelListViewItem(starItem, body->getName(true), 
00146                                             starBodyDist / KM_PER_AU, "au",
00147                                             0, 0, getClassification(body->getClassification()));
00148                 
00149                 const PlanetarySystem* satellites = body->getSatellites();
00150                 if (satellites != NULL && satellites->getSystemSize() != 0)
00151                 {
00152                         for (int i = 0; i < satellites->getSystemSize(); i++)
00153                         {
00154                                 Body* sat = satellites->getBody(i);
00155                                 
00156                                 Point3d satPos = sat->getHeliocentricPosition(appSim->getTime());
00157                                 Vec3d bodySatVec(bodyPos.x - satPos.x, bodyPos.y - satPos.y, bodyPos.z - satPos.z);
00158                                 double bodySatDist = bodySatVec.length();
00159                                 
00160                                 new CelListViewItem(planetItem, sat->getName(true),
00161                                     bodySatDist, "km", 0, 0, getClassification(sat->getClassification()));
00162 
00163                         }
00164                 }
00165             }
00166         }
00167     }
00168     delete(stars);
00169 }

void CelestialBrowser::slotRightClickOnStar QListViewItem *  ,
const QPoint &  ,
int 
[virtual, slot]
 

Reimplemented from CelestialBrowserBase.

Definition at line 200 of file celestialbrowser.cpp.

References appCore, appSim, Simulation::findObjectFromPath(), CelListViewItem::getName(), SelectionPopup::init(), and SelectionPopup::process().

00200                                                                                          {
00201     CelListViewItem *i = dynamic_cast<CelListViewItem*>(item);
00202     std::string name = i->getName();
00203     while ( (i = dynamic_cast<CelListViewItem*>(i->parent())) ) {
00204         name = i->getName() + "/" + name;
00205     }
00206     Selection sel = appSim->findObjectFromPath(name, true);
00207 
00208     SelectionPopup popup(this, appCore, sel);
00209     popup.init();
00210     int id = popup.exec(p);
00211     popup.process(id);
00212 }

void CelestialBrowser::slotWithPlanets bool   )  [virtual, slot]
 

Reimplemented from CelestialBrowserBase.

Definition at line 86 of file celestialbrowser.cpp.

References sbrowser, StarBrowser::setPredicate(), and slotRefresh().

00087 {
00088     sbrowser.setPredicate(StarBrowser::StarsWithPlanets);
00089     listStars->setSorting(1);
00090     slotRefresh();
00091 }


Member Data Documentation

CelestiaCore* CelestialBrowser::appCore [private]
 

Definition at line 33 of file celestialbrowser.h.

Referenced by CelestialBrowser(), and slotRightClickOnStar().

Simulation* CelestialBrowser::appSim [private]
 

Definition at line 34 of file celestialbrowser.h.

Referenced by CelestialBrowser(), slotRefresh(), and slotRightClickOnStar().

Selection CelestialBrowser::browserSel [private]
 

Definition at line 36 of file celestialbrowser.h.

Referenced by slotRefresh().

KdeApp* CelestialBrowser::parent [private]
 

Definition at line 32 of file celestialbrowser.h.

Referenced by CelestialBrowser().

StarBrowser CelestialBrowser::sbrowser [private]
 

Definition at line 35 of file celestialbrowser.h.

Referenced by CelestialBrowser(), slotBrighter(), slotBrightest(), slotNearest(), slotRefresh(), and slotWithPlanets().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:10 2006 for Celestia by  doxygen 1.4.1