#include <selectionpopup.h>
Collaboration diagram for SelectionPopup:

Public Member Functions | |
| void | init () |
| void | process (int id) |
| SelectionPopup (QWidget *parent, CelestiaCore *appCore, Selection sel) | |
Protected Member Functions | |
| Selection | getSelectionFromId (Selection sel, int id) const |
| const char * | getSelectionName (const Selection &sel) const |
| void | insert (KPopupMenu *popup, Selection sel, int baseId, bool showSubObjects=true) |
Protected Attributes | |
| CelestiaCore * | appCore |
| Selection | sel |
|
||||||||||||||||
|
Definition at line 32 of file selectionpopup.cpp.
|
|
||||||||||||
|
Definition at line 267 of file selectionpopup.cpp. References appCore, Selection::body(), Universe::find(), PlanetarySystem::getBody(), Star::getCatalogNumber(), SolarSystem::getPlanets(), Body::getSatellites(), CelestiaCore::getSimulation(), Universe::getSolarSystemCatalog(), PlanetarySystem::getSystemSize(), Simulation::getUniverse(), MENUMAXSIZE, and Selection::star(). Referenced by process(). 00268 {
00269 if (id == 0) return sel;
00270
00271 int subId = id;
00272 int level = 1;
00273 while (id > MENUMAXSIZE) {
00274 id /= MENUMAXSIZE;
00275 level *= MENUMAXSIZE;
00276 }
00277 subId -= id * level;
00278 if (subId < 0) subId = 0;
00279
00280 if (sel.body() != NULL)
00281 {
00282 const PlanetarySystem* satellites = sel.body()->getSatellites();
00283 if (satellites != NULL && satellites->getSystemSize() != 0)
00284 {
00285 Body* body = satellites->getBody(id - 1);
00286 Selection satSel(body);
00287 return getSelectionFromId(satSel, subId);
00288 }
00289 }
00290 else if (sel.star() != NULL)
00291 {
00292 Simulation *sim = appCore->getSimulation();
00293 SolarSystemCatalog* solarSystemCatalog = sim->getUniverse()->getSolarSystemCatalog();
00294 SolarSystemCatalog::iterator iter = solarSystemCatalog->find(sel.star()->getCatalogNumber());
00295 if (iter != solarSystemCatalog->end())
00296 {
00297 SolarSystem* solarSys = iter->second;
00298 Body* body = solarSys->getPlanets()->getBody(id - 1);
00299 Selection satSel(body);
00300 return getSelectionFromId(satSel, subId);
00301 }
00302 }
00303
00304 return sel;
00305 }
|
|
|
Definition at line 255 of file selectionpopup.cpp. References appCore, Selection::body(), Selection::deepsky(), Universe::getDSOCatalog(), DSODatabase::getDSOName(), Body::getName(), CelestiaCore::getSimulation(), Universe::getStarCatalog(), StarDatabase::getStarName(), Simulation::getUniverse(), sel, and Selection::star(). Referenced by init(). 00256 {
00257 if (sel.body() != NULL)
00258 return sel.body()->getName(true).c_str();
00259 else if (sel.star() != NULL)
00260 return appCore->getSimulation()->getUniverse()->getStarCatalog()->getStarName(*(sel.star())).c_str();
00261 else if (sel.deepsky() != NULL)
00262 return appCore->getSimulation()->getUniverse()->getDSOCatalog()->getDSOName(sel.deepsky()).c_str();
00263
00264 return "";
00265 }
|
|
|
Definition at line 40 of file selectionpopup.cpp. References abs(), astro::absToAppMag(), appCore, Selection::body(), Selection::deepsky(), distance(), Star::getAbsoluteMagnitude(), Universe::getDSOCatalog(), DSODatabase::getDSOName(), Universe::getMarkers(), Body::getName(), Simulation::getObserver(), Observer::getPosition(), Selection::getPosition(), Star::getRadius(), getSelectionName(), CelestiaCore::getSimulation(), Star::getSpectralType(), Universe::getStarCatalog(), StarDatabase::getStarName(), Star::getTemperature(), Simulation::getTime(), Simulation::getUniverse(), insert(), Vector3< T >::length(), MENUMAXSIZE, ReplaceGreekLetterAbbr(), sel, and Selection::star(). Referenced by CelestialBrowser::slotRightClickOnStar(). 00041 {
00042 QLabel *lab = new QLabel("", this);
00043 QPalette pal( lab->palette() );
00044 pal.setColor( QPalette::Normal, QColorGroup::Background, QColor( "White" ) );
00045 pal.setColor( QPalette::Normal, QColorGroup::Foreground, QColor( "Black" ) );
00046 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, QColor( "Black" ) );
00047
00048 QFont rsFont = lab->font();
00049 rsFont.setPointSize( rsFont.pointSize() - 2 );
00050
00051 Simulation *sim = appCore->getSimulation();
00052 Vec3d v = sel.getPosition(sim->getTime()) - sim->getObserver().getPosition();
00053
00054 if (sel.body() != NULL)
00055 {
00056 insertTitle(QString::fromUtf8(sel.body()->getName(true).c_str()), 0, 0);
00057 insert(this, sel, MENUMAXSIZE);
00058 }
00059 else if (sel.star() != NULL)
00060 {
00061 std::string name = sim->getUniverse()->getStarCatalog()->getStarName(*sel.star());
00062
00063 double distance = v.length() * 1e-6;
00064 char buff[50];
00065
00066 ostringstream o;
00067
00068 if (abs(distance) >= astro::AUtoLightYears(1000.0f))
00069 sprintf(buff, "%.3f ly", distance);
00070 else if (abs(distance) >= astro::kilometersToLightYears(10000000.0))
00071 sprintf(buff, "%.3f au", astro::lightYearsToAU(distance));
00072 else if (abs(distance) > astro::kilometersToLightYears(1.0f))
00073 sprintf(buff, "%.3f km", astro::lightYearsToKilometers(distance));
00074 else
00075 sprintf(buff, "%.3f m", astro::lightYearsToKilometers(distance) * 1000.0f);
00076
00077 o << i18n("Distance: ") << buff << "\n";
00078
00079 o << i18n("Abs (app) mag: ");
00080
00081 sprintf(buff, "%.2f (%.2f)",
00082 sel.star()->getAbsoluteMagnitude(),
00083 astro::absToAppMag(sel.star()->getAbsoluteMagnitude(),
00084 (float) distance));
00085 o << buff << "\n";
00086
00087 o << i18n("Class: ");
00088 sprintf(buff, "%s", sel.star()->getSpectralType());
00089 o << buff << "\n";
00090
00091 o << i18n("Surface Temp: ");
00092 sprintf(buff, "%.0f K", sel.star()->getTemperature());
00093 o << buff << "\n";
00094
00095 o << i18n("Radius: ");
00096 sprintf(buff, "%.2f Rsun", sel.star()->getRadius() / 696000.0f);
00097 o << buff;
00098
00099 QLabel *starDetails = new QLabel(QString(o.str().c_str()), this);
00100 starDetails->setPalette(pal);
00101 starDetails->setFont(rsFont);
00102
00103 insertTitle(QString::fromUtf8(ReplaceGreekLetterAbbr(name).c_str()), 0, 0);
00104 insertItem(starDetails);
00105 insertSeparator();
00106 insert(this, sel, MENUMAXSIZE);
00107 }
00108 else if (sel.deepsky() != NULL)
00109 {
00110 insertTitle(QString::fromUtf8(sim->getUniverse()->getDSOCatalog()->getDSOName(sel.deepsky()).c_str()), 0);
00111 insert(this, sel, MENUMAXSIZE);
00112 }
00113
00114 if (sim->getUniverse() != NULL)
00115 {
00116 MarkerList* markers = sim->getUniverse()->getMarkers();
00117 if (markers->size() > 0)
00118 {
00119 KPopupMenu *markMenu = new KPopupMenu(this);
00120 int j=1;
00121 for (std::vector<Marker>::iterator i = markers->begin(); i < markers->end() && j < MENUMAXSIZE; i++)
00122 {
00123 KPopupMenu *objMenu = new KPopupMenu(this);
00124 insert(objMenu, (*i).getObject(), (2 * MENUMAXSIZE + j) * MENUMAXSIZE, false);
00125 markMenu->insertItem(QString::fromUtf8(getSelectionName((*i).getObject())), objMenu);
00126 j++;
00127 }
00128 insertItem(i18n("Marked objects"), markMenu);
00129 }
00130 }
00131 }
|
|
||||||||||||||||||||
|
Definition at line 307 of file selectionpopup.cpp. References appCore, Selection::body(), Selection::deepsky(), Universe::find(), Body::getAlternateSurfaceNames(), PlanetarySystem::getBody(), Star::getCatalogNumber(), Body::getName(), SolarSystem::getPlanets(), Body::getSatellites(), CelestiaCore::getSimulation(), Universe::getSolarSystemCatalog(), PlanetarySystem::getSystemSize(), Simulation::getUniverse(), Universe::isMarked(), MENUMAXSIZE, and Selection::star(). Referenced by init(). 00308 {
00309 popup->insertItem(i18n("&Select"), baseId + 1);
00310 popup->insertItem(i18n("&Center"), baseId + 2);
00311 popup->insertItem(i18n("&Goto"), baseId + 3);
00312 popup->insertItem(i18n("&Follow"), baseId + 4);
00313 popup->insertItem(i18n("S&ynch Orbit"), baseId + 5);
00314 popup->insertItem(i18n("&Info"), baseId + 6);
00315 popup->insertItem(i18n("Unmark &All"), baseId + 8);
00316 if (appCore->getSimulation()->getUniverse()->isMarked(sel, 1))
00317 {
00318 popup->insertItem(i18n("&Unmark"), baseId + 7);
00319 }
00320 else
00321 {
00322 KPopupMenu *markMenu = new KPopupMenu(this);
00323 markMenu->insertItem(i18n("Diamond"), baseId + 10);
00324 markMenu->insertItem(i18n("Triangle"), baseId + 11);
00325 markMenu->insertItem(i18n("Square"), baseId + 12);
00326 markMenu->insertItem(i18n("Plus"), baseId + 13);
00327 markMenu->insertItem(i18n("X"), baseId + 14);
00328 popup->insertItem(i18n("&Mark"), markMenu);
00329 }
00330
00331 if (showSubObjects && sel.body() != NULL)
00332 {
00333 std::vector<std::string>* altSurfaces = sel.body()->getAlternateSurfaceNames();
00334 if (altSurfaces != NULL)
00335 {
00336 if (altSurfaces->size() != NULL)
00337 {
00338 KPopupMenu *surfaces = new KPopupMenu(this);
00339 surfaces->insertItem(i18n("Normal"), baseId + 20);
00340 int j=0;
00341 for (std::vector<std::string>::const_iterator i = altSurfaces->begin();
00342 i < altSurfaces->end() && j < MENUMAXSIZE - 1; i++, j++)
00343 {
00344 surfaces->insertItem(QString((*i).c_str()), baseId + 21 + j);
00345 }
00346 popup->insertItem(i18n("&Alternate Surfaces"), surfaces);
00347 }
00348 delete altSurfaces;
00349 }
00350
00351 const PlanetarySystem* satellites = sel.body()->getSatellites();
00352 if (satellites != NULL && satellites->getSystemSize() != 0)
00353 {
00354 popup->insertSeparator();
00355 KPopupMenu *planetaryMenu = new KPopupMenu(this);
00356 for (int i = 0; i < satellites->getSystemSize() && i < MENUMAXSIZE; i++)
00357 {
00358 Body* body = satellites->getBody(i);
00359 Selection satSel(body);
00360 KPopupMenu *satMenu = new KPopupMenu(this);
00361 insert(satMenu, satSel, baseId * MENUMAXSIZE + (i + 1) * MENUMAXSIZE);
00362 planetaryMenu->insertItem(QString::fromUtf8(body->getName(true).c_str()), satMenu);
00363 }
00364 popup->insertItem(i18n("Satellites"), planetaryMenu);
00365 }
00366 }
00367 else if (showSubObjects && sel.star() != NULL)
00368 {
00369 popup->setItemEnabled(baseId + 5, false);
00370 Simulation *sim = appCore->getSimulation();
00371 SolarSystemCatalog* solarSystemCatalog = sim->getUniverse()->getSolarSystemCatalog();
00372 SolarSystemCatalog::iterator iter = solarSystemCatalog->find(sel.star()->getCatalogNumber());
00373 if (iter != solarSystemCatalog->end())
00374 {
00375 popup->insertSeparator();
00376 SolarSystem* solarSys = iter->second;
00377 KPopupMenu* planetsMenu = new KPopupMenu(this);
00378 for (int i = 0; i < solarSys->getPlanets()->getSystemSize() && i < MENUMAXSIZE; i++)
00379 {
00380 Body* body = solarSys->getPlanets()->getBody(i);
00381 Selection satSel(body);
00382 KPopupMenu *satMenu = new KPopupMenu(this);
00383 insert(satMenu, satSel, baseId * MENUMAXSIZE + (i + 1) * MENUMAXSIZE);
00384 planetsMenu->insertItem(QString::fromUtf8(body->getName(true).c_str()), satMenu);
00385 }
00386 popup->insertItem(i18n("Planets"), planetsMenu);
00387 }
00388 }
00389 else if (sel.deepsky() != NULL)
00390 {
00391 popup->setItemEnabled(baseId + 5, false);
00392 }
00393 }
|
|
|
Definition at line 133 of file selectionpopup.cpp. References appCore, Selection::body(), CelestiaCore::charEntered(), Selection::deepsky(), Simulation::getActiveObserver(), Body::getAlternateSurfaceNames(), Star::getCatalogNumber(), Universe::getDSOCatalog(), DSODatabase::getDSOName(), Body::getInfoURL(), Universe::getMarkers(), Body::getName(), getSelectionFromId(), CelestiaCore::getSimulation(), Simulation::getUniverse(), Universe::markObject(), MENUMAXSIZE, sel, Observer::setDisplayedSurface(), Simulation::setSelection(), Selection::star(), Universe::unmarkAll(), and Universe::unmarkObject(). Referenced by CelestialBrowser::slotRightClickOnStar(). 00134 {
00135 Simulation *sim = appCore->getSimulation();
00136
00137 int actionId = id;
00138 actionId = id - (id / MENUMAXSIZE) * MENUMAXSIZE;
00139
00140 int subId = id;
00141 int level = 1;
00142 while (id > MENUMAXSIZE) {
00143 id /= MENUMAXSIZE;
00144 level *= MENUMAXSIZE;
00145 }
00146 subId -= id * level;
00147
00148 if (id == 1)
00149 {
00150 int selId = subId / MENUMAXSIZE;
00151 sel = getSelectionFromId(sel, selId);
00152 }
00153 else if (id == 2) // marked objects sub-menu
00154 {
00155 int subsubId = subId;
00156 int level = 1;
00157 while (subId > MENUMAXSIZE) {
00158 subId /= MENUMAXSIZE;
00159 level *= MENUMAXSIZE;
00160 }
00161 subsubId -= subId * level;
00162 MarkerList* markers = sim->getUniverse()->getMarkers();
00163 sel = (*markers)[subId-1].getObject();
00164 int selId = subsubId / MENUMAXSIZE;
00165 sel = getSelectionFromId(sel, selId);
00166 }
00167
00168 if (actionId == 1) {
00169 sim->setSelection(sel);
00170 return;
00171 }
00172 if (actionId == 2) {
00173 sim->setSelection(sel);
00174 appCore->charEntered('c');
00175 return;
00176 }
00177 if (actionId == 3) {
00178 sim->setSelection(sel);
00179 appCore->charEntered('g');
00180 return;
00181 }
00182 if (actionId == 4) {
00183 sim->setSelection(sel);
00184 appCore->charEntered('f');
00185 return;
00186 }
00187 if (actionId == 5) {
00188 sim->setSelection(sel);
00189 appCore->charEntered('y');
00190 return;
00191 }
00192 if (actionId == 6) {
00193 QString url;
00194 if (sel.body() != NULL)
00195 {
00196 url = QString(sel.body()->getInfoURL().c_str());
00197 if (url == "")
00198 {
00199 QString name = QString(sel.body()->getName().c_str()).lower();
00200 url = QString("http://www.nineplanets.org/") + name + ".html";
00201 }
00202 }
00203 else if (sel.star() != NULL)
00204 {
00205 if (sel.star()->getCatalogNumber() != 0)
00206 url = QString("http://simbad.u-strasbg.fr/sim-id.pl?protocol=html&Ident=HIP %1")
00207 .arg(sel.star()->getCatalogNumber() & ~0xf0000000);
00208 else
00209 url = QString("http://www.nineplanets.org/sun.html");
00210 }
00211 else if (sel.deepsky() != NULL)
00212 {
00213 url = QString("http://simbad.u-strasbg.fr/sim-id.pl?protocol=html&Ident=%1")
00214 .arg(sim->getUniverse()->getDSOCatalog()->getDSOName(sel.deepsky()).c_str());
00215 }
00216 KRun::runURL(url, "text/html");
00217 return;
00218 }
00219 if (actionId == 7)
00220 {
00221 if (sim->getUniverse() != NULL)
00222 sim->getUniverse()->unmarkObject(sel, 1);
00223 return;
00224 }
00225 if (actionId == 8)
00226 {
00227 sim->getUniverse()->unmarkAll();
00228 return;
00229 }
00230 if (actionId >= 10 && actionId <= 14)
00231 {
00232 if (sim->getUniverse() != NULL)
00233 {
00234 sim->getUniverse()->markObject(sel,
00235 10.0f,
00236 Color(0.0f, 1.0f, 0.0f, 0.9f),
00237 (Marker::Symbol)(actionId - 10),
00238 1);
00239 }
00240 return;
00241 }
00242 if (actionId == 20) {
00243 sim->getActiveObserver()->setDisplayedSurface("");
00244 return;
00245 }
00246 if (actionId > 20) {
00247 std::vector<std::string>* altSurfaces = sel.body()->getAlternateSurfaceNames();
00248 if (altSurfaces != NULL && altSurfaces->size() > actionId - 21)
00249 {
00250 sim->getActiveObserver()->setDisplayedSurface((*altSurfaces)[actionId - 21]);
00251 }
00252 }
00253 }
|
|
|
Definition at line 39 of file selectionpopup.h. Referenced by getSelectionFromId(), getSelectionName(), init(), insert(), and process(). |
|
|
Definition at line 43 of file selectionpopup.h. Referenced by getSelectionName(), init(), and process(). |
1.4.1