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

StarBrowser Class Reference

#include <starbrowser.h>

Collaboration diagram for StarBrowser:

Collaboration graph
List of all members.

Public Types

enum  { NearestStars = 0, BrighterStars = 1, BrightestStars = 2, StarsWithPlanets = 3 }

Public Member Functions

std::vector< const Star * > * listStars (unsigned int)
const StarnearestStar (void)
void refresh ()
bool setPredicate (int pred)
void setSimulation (Simulation *_appSim)
 StarBrowser (HINSTANCE, HWND, CelestiaCore *)
 StarBrowser (Simulation *_appSim, int pred=NearestStars)
 StarBrowser ()
 ~StarBrowser ()

Public Attributes

CelestiaCoreappCore
HWND hwnd
int nStars
HWND parent
Point3f pos
UniversalCoord ucPos

Private Attributes

SimulationappSim
int predicate

Member Enumeration Documentation

anonymous enum
 

Enumeration values:
NearestStars 
BrighterStars 
BrightestStars 
StarsWithPlanets 

Definition at line 27 of file starbrowser.h.

00027          {
00028         NearestStars = 0,
00029         BrighterStars = 1,
00030         BrightestStars = 2,
00031         StarsWithPlanets = 3,
00032     };


Constructor & Destructor Documentation

StarBrowser::StarBrowser  ) 
 

Definition at line 241 of file starbrowser.cpp.

References NearestStars.

00241                          :
00242     pos(0.0, 0.0, 0.0),
00243     ucPos(0.0, 0.0, 0.0),
00244     appSim(NULL),
00245     predicate(NearestStars)
00246 {
00247 }
}

StarBrowser::StarBrowser Simulation _appSim,
int  pred = NearestStars
 

Definition at line 231 of file starbrowser.cpp.

References appSim, Simulation::getObserver(), Observer::getPosition(), pos, predicate, and ucPos.

00231                                                       :
00232     appSim(_appSim)
00233 {
00234     ucPos = appSim->getObserver().getPosition();
00235     pos = (Point3f) ucPos;
00236 
00237     predicate = pred;
00238 }

StarBrowser::StarBrowser HINSTANCE  ,
HWND  ,
CelestiaCore
 

Definition at line 592 of file winstarbrowser.cpp.

References appCore, appInstance, DefaultListStars, fromMicroLY(), Simulation::getObserver(), Observer::getPosition(), CelestiaCore::getSimulation(), hwnd, IDD_STARBROWSER, NearestStars, nStars, parent, pos, predicate, StarBrowserProc(), and ucPos.

00594                                                  :
00595     appCore(_appCore),
00596     parent(_parent)
00597 {
00598     ucPos = appCore->getSimulation()->getObserver().getPosition();
00599     pos = fromMicroLY((Point3f) ucPos);
00600 
00601     predicate = NearestStars;
00602     nStars = DefaultListStars;
00603 
00604     hwnd = CreateDialogParam(appInstance,
00605                              MAKEINTRESOURCE(IDD_STARBROWSER),
00606                              parent,
00607                              StarBrowserProc,
00608                              reinterpret_cast<LONG>(this));
00609 }

StarBrowser::~StarBrowser  ) 
 

Definition at line 612 of file winstarbrowser.cpp.

References hwnd.

00613 {
00614     SetWindowLong(hwnd, DWL_USER, 0);
00615 }


Member Function Documentation

std::vector< const Star * > * StarBrowser::listStars unsigned  int  ) 
 

Definition at line 160 of file starbrowser.cpp.

References appSim, BrighterStars, BrightestStars, findStars(), Universe::getSolarSystemCatalog(), Universe::getStarCatalog(), Simulation::getUniverse(), MIN, NearestStars, CloserStarPredicate::pos, SolarSystemPredicate::pos, pos, BrighterStarPredicate::pos, predicate, SolarSystemPredicate::solarSystems, StarsWithPlanets, ucPos, and BrighterStarPredicate::ucPos.

Referenced by CelestialBrowser::slotRefresh().

00161 {
00162     Universe* univ = appSim->getUniverse();
00163     switch(predicate)
00164     {
00165     case BrighterStars:
00166         {
00167             BrighterStarPredicate brighterPred;
00168             brighterPred.pos = pos;
00169             brighterPred.ucPos = ucPos;
00170             return findStars(*(univ->getStarCatalog()), brighterPred, nStars);
00171         }
00172         break;
00173 
00174     case BrightestStars:
00175         {
00176             BrightestStarPredicate brightestPred;
00177             return findStars(*(univ->getStarCatalog()), brightestPred, nStars);
00178         }
00179         break;
00180 
00181     case StarsWithPlanets:
00182         {
00183             SolarSystemCatalog* solarSystems = univ->getSolarSystemCatalog();
00184             if (solarSystems == NULL)
00185                 return NULL;
00186             SolarSystemPredicate solarSysPred;
00187             solarSysPred.pos = pos;
00188             solarSysPred.solarSystems = solarSystems;
00189             return findStars(*(univ->getStarCatalog()), solarSysPred,
00190                              MIN(nStars, solarSystems->size()));
00191         }
00192         break;
00193 
00194     case NearestStars:
00195     default:
00196         {
00197             CloserStarPredicate closerPred;
00198             closerPred.pos = pos;
00199             return findStars(*(univ->getStarCatalog()), closerPred, nStars);
00200         }
00201         break;
00202     }
00203 
00204     return NULL;  // keep compiler happy
00205 }

const Star * StarBrowser::nearestStar void   ) 
 

Definition at line 147 of file starbrowser.cpp.

References appSim, findStars(), Universe::getStarCatalog(), Simulation::getUniverse(), pos, CloserStarPredicate::pos, and stars.

00148 {
00149     Universe* univ = appSim->getUniverse();
00150     CloserStarPredicate closerPred;
00151     closerPred.pos = pos;
00152     std::vector<const Star*>* stars = findStars(*(univ->getStarCatalog()), closerPred, 1);
00153     const Star *star = (*stars)[0];
00154     delete stars;
00155     return star;
00156 }

void StarBrowser::refresh  ) 
 

Definition at line 217 of file starbrowser.cpp.

References appSim, Simulation::getObserver(), Observer::getPosition(), pos, and ucPos.

Referenced by setSimulation(), and CelestialBrowser::slotRefresh().

00218 {
00219     ucPos = appSim->getObserver().getPosition();
00220     pos = (Point3f) ucPos;
00221 }

bool StarBrowser::setPredicate int  pred  ) 
 

Definition at line 208 of file starbrowser.cpp.

References predicate, and StarsWithPlanets.

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

00209 {
00210     if ((pred < NearestStars) || (pred > StarsWithPlanets))
00211         return false;
00212     predicate = pred;
00213     return true;
00214 }

void StarBrowser::setSimulation Simulation _appSim  ) 
 

Definition at line 224 of file starbrowser.cpp.

References appSim, and refresh().

Referenced by CelestialBrowser::CelestialBrowser(), and dialogStarBrowser().

00225 {
00226     appSim = _appSim;
00227     refresh();
00228 }


Member Data Documentation

CelestiaCore* StarBrowser::appCore
 

Definition at line 25 of file winstarbrowser.h.

Referenced by StarBrowser(), and StarBrowserProc().

Simulation* StarBrowser::appSim [private]
 

Definition at line 50 of file starbrowser.h.

Referenced by listStars(), nearestStar(), refresh(), setSimulation(), and StarBrowser().

HWND StarBrowser::hwnd
 

Definition at line 27 of file winstarbrowser.h.

Referenced by StarBrowser(), WinMain(), and ~StarBrowser().

int StarBrowser::nStars
 

Definition at line 36 of file winstarbrowser.h.

Referenced by StarBrowser(), and StarBrowserProc().

HWND StarBrowser::parent
 

Definition at line 26 of file winstarbrowser.h.

Referenced by StarBrowser(), and StarBrowserProc().

Point3f StarBrowser::pos
 

Definition at line 32 of file winstarbrowser.h.

Referenced by listStars(), nearestStar(), refresh(), StarBrowser(), and StarBrowserProc().

int StarBrowser::predicate [private]
 

Definition at line 35 of file winstarbrowser.h.

Referenced by listStars(), setPredicate(), StarBrowser(), and StarBrowserProc().

UniversalCoord StarBrowser::ucPos
 

Definition at line 33 of file winstarbrowser.h.

Referenced by listStars(), refresh(), StarBrowser(), and StarBrowserProc().


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