Oculars.cpp   Oculars.cpp 
skipping to change at line 123 skipping to change at line 123
flagLongitudeLine(false), flagLongitudeLine(false),
flagHorizonLine(false), flagHorizonLine(false),
flagGalacticEquatorLine(false), flagGalacticEquatorLine(false),
flagAdaptation(false), flagAdaptation(false),
flagLimitStars(false), flagLimitStars(false),
magLimitStars(0.0), magLimitStars(0.0),
flagLimitDSOs(false), flagLimitDSOs(false),
magLimitDSOs(0.0), magLimitDSOs(0.0),
flagLimitPlanets(false), flagLimitPlanets(false),
magLimitPlanets(0.0), magLimitPlanets(0.0),
relativeStarScale(1.0),
absoluteStarScale(1.0),
flagMoonScale(false), flagMoonScale(false),
maxEyepieceAngle(0.0), maxEyepieceAngle(0.0),
requireSelection(true), requireSelection(true),
flagLimitMagnitude(false), flagLimitMagnitude(false),
useMaxEyepieceAngle(true), useMaxEyepieceAngle(true),
guiPanelEnabled(false), guiPanelEnabled(false),
flagDecimalDegrees(false), flagDecimalDegrees(false),
flagSemiTransporency(false), flagSemiTransporency(false),
flipVert(false),
flipHorz(false),
ccdRotationSignalMapper(0), ccdRotationSignalMapper(0),
ccdsSignalMapper(0), ccdsSignalMapper(0),
ocularsSignalMapper(0), ocularsSignalMapper(0),
telescopesSignalMapper(0), telescopesSignalMapper(0),
lenseSignalMapper(0), lenseSignalMapper(0),
pxmapGlow(NULL), pxmapGlow(NULL),
pxmapOnIcon(NULL), pxmapOnIcon(NULL),
pxmapOffIcon(NULL), pxmapOffIcon(NULL),
toolbarButton(NULL), toolbarButton(NULL),
ocularDialog(NULL), ocularDialog(NULL),
skipping to change at line 186 skipping to change at line 190
qt_set_sequence_auto_mnemonic(true); qt_set_sequence_auto_mnemonic(true);
#endif #endif
} }
Oculars::~Oculars() Oculars::~Oculars()
{ {
delete ocularDialog; delete ocularDialog;
ocularDialog = NULL; ocularDialog = NULL;
if (guiPanel) if (guiPanel)
delete guiPanel; delete guiPanel;
if (pxmapGlow) if (pxmapGlow)
delete pxmapGlow; delete pxmapGlow;
if (pxmapOnIcon) if (pxmapOnIcon)
delete pxmapOnIcon; delete pxmapOnIcon;
if (pxmapOffIcon) if (pxmapOffIcon)
delete pxmapOffIcon; delete pxmapOffIcon;
qDeleteAll(ccds); qDeleteAll(ccds);
ccds.clear(); ccds.clear();
qDeleteAll(telescopes); qDeleteAll(telescopes);
skipping to change at line 217 skipping to change at line 220
} }
/* ************************************************************************ ****************************************** */ /* ************************************************************************ ****************************************** */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark StelModule Methods #pragma mark StelModule Methods
#endif #endif
/* ************************************************************************ ****************************************** */ /* ************************************************************************ ****************************************** */
bool Oculars::configureGui(bool show) bool Oculars::configureGui(bool show)
{ {
if (show) { if (show)
{
ocularDialog->setVisible(true); ocularDialog->setVisible(true);
} }
return ready; return ready;
} }
void Oculars::deinit() void Oculars::deinit()
{ {
// update the ini file. // update the ini file.
settings->remove("ccd"); settings->remove("ccd");
settings->remove("ocular"); settings->remove("ocular");
settings->remove("telescope"); settings->remove("telescope");
settings->remove("lens"); settings->remove("lens");
int index = 0; int index = 0;
foreach(CCD* ccd, ccds) { foreach(CCD* ccd, ccds)
{
ccd->writeToSettings(settings, index); ccd->writeToSettings(settings, index);
index++; index++;
} }
index = 0; index = 0;
foreach(Ocular * ocular, oculars) { foreach(Ocular * ocular, oculars)
{
ocular->writeToSettings(settings, index); ocular->writeToSettings(settings, index);
index++; index++;
} }
index = 0; index = 0;
foreach(Telescope* telescope, telescopes){ foreach(Telescope* telescope, telescopes)
{
telescope->writeToSettings(settings, index); telescope->writeToSettings(settings, index);
index++; index++;
} }
index = 0; index = 0;
foreach(Lens* lens, lense) { foreach(Lens* lens, lense)
{
lens->writeToSettings(settings, index); lens->writeToSettings(settings, index);
index++; index++;
} }
settings->setValue("ocular_count", oculars.count()); settings->setValue("ocular_count", oculars.count());
settings->setValue("telescope_count", telescopes.count()); settings->setValue("telescope_count", telescopes.count());
settings->setValue("ccd_count", ccds.count()); settings->setValue("ccd_count", ccds.count());
settings->setValue("lens_count", lense.count()); settings->setValue("lens_count", lense.count());
settings->sync(); settings->sync();
disconnect(this, SIGNAL(selectedOcularChanged()), this, SLOT(updateO cularReticle())); disconnect(this, SIGNAL(selectedOcularChanged()), this, SLOT(updateO cularReticle()));
disconnect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const disconnect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const
QString&)), QString&)), this, SLOT(setStelStyle(const QString&)));
this, SLOT(setStelStyle(const QStrin disconnect(&StelApp::getInstance(), SIGNAL(languageChanged()), this,
g&))); SLOT(retranslateGui()));
disconnect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslateGui()));
} }
//! Draw any parts on the screen which are for our module //! Draw any parts on the screen which are for our module
void Oculars::draw(StelCore* core) void Oculars::draw(StelCore* core)
{ {
if (flagShowTelrad) { if (flagShowTelrad)
{
paintTelrad(); paintTelrad();
} else if (flagShowOculars){ }
else if (flagShowOculars)
{
// Ensure there is a selected ocular & telescope // Ensure there is a selected ocular & telescope
if (selectedCCDIndex > ccds.count()) { if (selectedCCDIndex > ccds.count())
{
qWarning() << "Oculars: the selected sensor index of " qWarning() << "Oculars: the selected sensor index of "
<< selected << selectedCCDIndex << " is greater than
CCDIndex << " is greater than the sensor count of " the sensor count of "
<< ccds.cou << ccds.count() << ". Module disabled!";
nt() << ". Module disabled!";
ready = false; ready = false;
} }
if (selectedOcularIndex > oculars.count()) { if (selectedOcularIndex > oculars.count())
{
qWarning() << "Oculars: the selected ocular index of " qWarning() << "Oculars: the selected ocular index of "
<< selected << selectedOcularIndex << " is greater th
OcularIndex << " is greater than the ocular count of " an the ocular count of "
<< oculars. << oculars.count() << ". Module disabled!
count() << ". Module disabled!"; ";
ready = false; ready = false;
} }
else if (selectedTelescopeIndex > telescopes.count()) { else if (selectedTelescopeIndex > telescopes.count())
{
qWarning() << "Oculars: the selected telescope index of " qWarning() << "Oculars: the selected telescope index of "
<< selected << selectedTelescopeIndex << " is greater
TelescopeIndex << " is greater than the telescope count of " than the telescope count of "
<< telescop << telescopes.count() << ". Module disabl
es.count() << ". Module disabled!"; ed!";
ready = false; ready = false;
} }
if (ready) { if (ready)
if (selectedOcularIndex > -1) { {
if (selectedOcularIndex > -1)
{
paintOcularMask(core); paintOcularMask(core);
if (flagShowCrosshairs) { if (flagShowCrosshairs)
{
paintCrosshairs(); paintCrosshairs();
} }
} }
if (guiPanelEnabled) if (guiPanelEnabled)
{ {
// Reset the state to allow the panel to be painted normally // Reset the state to allow the panel to be painted normally
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_A LPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_A LPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
} }
else else
{ {
// Paint the information in the upper-right hand corner // Paint the information in the upper-right hand corner
paintText(core); paintText(core);
} }
} }
} else if (flagShowCCD) { }
else if (flagShowCCD)
{
paintCCDBounds(); paintCCDBounds();
if (guiPanelEnabled) if (guiPanelEnabled)
{ {
// Reset the state to allow the panel to be painted normally // Reset the state to allow the panel to be painted normally
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
} }
else else
{ {
skipping to change at line 350 skipping to change at line 366
{ {
order = GETSTELMODULE(LabelMgr)->getCallOrder(actionName) + 100.0; order = GETSTELMODULE(LabelMgr)->getCallOrder(actionName) + 100.0;
} }
return order; return order;
} }
const StelStyle Oculars::getModuleStyleSheet(const StelStyle& style) const StelStyle Oculars::getModuleStyleSheet(const StelStyle& style)
{ {
StelStyle pluginStyle(style); StelStyle pluginStyle(style);
if (StelApp::getInstance().getVisionModeNight()) { if (StelApp::getInstance().getVisionModeNight())
{
pluginStyle.qtStyleSheet.append(nightStyleSheet); pluginStyle.qtStyleSheet.append(nightStyleSheet);
} else{ }
else
{
pluginStyle.qtStyleSheet.append(normalStyleSheet); pluginStyle.qtStyleSheet.append(normalStyleSheet);
} }
return pluginStyle; return pluginStyle;
} }
void Oculars::handleMouseClicks(class QMouseEvent* event) void Oculars::handleMouseClicks(class QMouseEvent* event)
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
if (StelApp::getInstance().getStelObjectMgr().getWasSelected()){ if (StelApp::getInstance().getStelObjectMgr().getWasSelected())
if (flagShowOculars) { {
if (flagShowOculars)
{
// center the selected object in the ocular, and tra ck. // center the selected object in the ocular, and tra ck.
movementManager->setFlagTracking(true); movementManager->setFlagTracking(true);
} else { }
else
{
// remove the usage label if it is being displayed. // remove the usage label if it is being displayed.
hideUsageMessageIfDisplayed(); hideUsageMessageIfDisplayed();
} }
} else if(flagShowOculars) { }
else if(flagShowOculars)
{
//TODO: this is broke in Stellarium. //TODO: this is broke in Stellarium.
// The ocular is displayed, but no object is selected. So d on't track the stars. We may have locked // The ocular is displayed, but no object is selected. So d on't track the stars. We may have locked
// the position of the screen if the movement keys were used . so call this to be on the safe side. // the position of the screen if the movement keys were used . so call this to be on the safe side.
movementManager->setFlagLockEquPos(false); movementManager->setFlagLockEquPos(false);
// Do we need to set this? // Do we need to set this?
// movementManager->setFlagTracking(false); // movementManager->setFlagTracking(false);
} }
event->setAccepted(false); event->setAccepted(false);
} }
void Oculars::handleKeys(QKeyEvent* event) void Oculars::handleKeys(QKeyEvent* event)
{ {
if (!flagShowOculars && !flagShowCCD) { if (!flagShowOculars && !flagShowCCD)
{
return; return;
} }
// We onle care about the arrow keys. This flag tracks that. // We onle care about the arrow keys. This flag tracks that.
bool consumeEvent = false; bool consumeEvent = false;
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress)
{
// Direction and zoom replacements // Direction and zoom replacements
switch (event->key()) { switch (event->key())
{
case Qt::Key_Left: case Qt::Key_Left:
movementManager->turnLeft(true); movementManager->turnLeft(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Right: case Qt::Key_Right:
movementManager->turnRight(true); movementManager->turnRight(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Up: case Qt::Key_Up:
if (!event->modifiers().testFlag(Qt::Control Modifier)) if (!event->modifiers().testFlag(Qt::Control Modifier))
skipping to change at line 431 skipping to change at line 459
case Qt::Key_PageDown: case Qt::Key_PageDown:
movementManager->zoomOut(true); movementManager->zoomOut(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Shift: case Qt::Key_Shift:
movementManager->moveSlow(true); movementManager->moveSlow(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_M: case Qt::Key_M:
double multiplier = 1.0; double multiplier = 1.0;
if (event->modifiers().testFlag(Qt::ControlM if (event->modifiers().testFlag(Qt::ControlM
odifier)) { odifier))
{
multiplier = 0.1; multiplier = 0.1;
} }
if (event->modifiers().testFlag(Qt::AltModif if (event->modifiers().testFlag(Qt::AltModif
ier)) { ier))
{
multiplier = 5.0; multiplier = 5.0;
} }
if (event->modifiers().testFlag(Qt::ShiftMod if (event->modifiers().testFlag(Qt::ShiftMod
ifier)) { ifier))
{
reticleRotation += (1.0 * multiplier ); reticleRotation += (1.0 * multiplier );
} else { }
else
{
reticleRotation -= (1.0 * multiplier ); reticleRotation -= (1.0 * multiplier );
} }
qDebug() << reticleRotation; qDebug() << reticleRotation;
consumeEvent = true; consumeEvent = true;
break; break;
} }
} else { }
else
{
// When a deplacement key is released stop mooving // When a deplacement key is released stop mooving
switch (event->key()) { switch (event->key())
{
case Qt::Key_Left: case Qt::Key_Left:
movementManager->turnLeft(false); movementManager->turnLeft(false);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Right: case Qt::Key_Right:
movementManager->turnRight(false); movementManager->turnRight(false);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Up: case Qt::Key_Up:
movementManager->turnUp(false); movementManager->turnUp(false);
skipping to change at line 478 skipping to change at line 514
break; break;
case Qt::Key_PageDown: case Qt::Key_PageDown:
movementManager->zoomOut(false); movementManager->zoomOut(false);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Shift: case Qt::Key_Shift:
movementManager->moveSlow(false); movementManager->moveSlow(false);
consumeEvent = true; consumeEvent = true;
break; break;
} }
if (consumeEvent) { if (consumeEvent)
{
// We don't want to re-center the object; just hold the current position. // We don't want to re-center the object; just hold the current position.
movementManager->setFlagLockEquPos(true); movementManager->setFlagLockEquPos(true);
} }
} }
if (consumeEvent) { if (consumeEvent)
{
event->accept(); event->accept();
} else { }
else
{
event->setAccepted(false); event->setAccepted(false);
} }
} }
void Oculars::init() void Oculars::init()
{ {
qDebug() << "Ocular plugin - press Command-O to toggle eyepiece view mode. Press ALT-o for configuration."; qDebug() << "Ocular plugin - press Command-O to toggle eyepiece view mode. Press ALT-o for configuration.";
// Load settings from ocular.ini // Load settings from ocular.ini
try { try {
validateAndLoadIniFile(); validateAndLoadIniFile();
// assume all is well // assume all is well
ready = true; ready = true;
requireSelection = settings->value("require_selection_to_zoo m", 1.0).toBool(); requireSelection = settings->value("require_selection_to_zoo m", 1.0).toBool();
useMaxEyepieceAngle = settings->value("use_max_exit_circle", 0.0).toBool(); useMaxEyepieceAngle = settings->value("use_max_exit_circle", 0.0).toBool();
int ocularCount = settings->value("ocular_count", 0).toInt() ; int ocularCount = settings->value("ocular_count", 0).toInt() ;
int actualOcularCount = ocularCount; int actualOcularCount = ocularCount;
for (int index = 0; index < ocularCount; index++) { for (int index = 0; index < ocularCount; index++)
{
Ocular *newOcular = Ocular::ocularFromSettings(setti ngs, index); Ocular *newOcular = Ocular::ocularFromSettings(setti ngs, index);
if (newOcular != NULL) { if (newOcular != NULL)
{
oculars.append(newOcular); oculars.append(newOcular);
} else { }
else
{
actualOcularCount--; actualOcularCount--;
} }
} }
if (actualOcularCount < 1) { if (actualOcularCount < 1)
if (actualOcularCount < ocularCount) { {
if (actualOcularCount < ocularCount)
{
qWarning() << "The Oculars ini file appears to be corrupt; delete it."; qWarning() << "The Oculars ini file appears to be corrupt; delete it.";
} else { }
else
{
qWarning() << "There are no oculars defined for the Oculars plugin; plugin will be disabled."; qWarning() << "There are no oculars defined for the Oculars plugin; plugin will be disabled.";
} }
ready = false; ready = false;
} else { }
else
{
selectedOcularIndex = 0; selectedOcularIndex = 0;
} }
int ccdCount = settings->value("ccd_count", 0).toInt(); int ccdCount = settings->value("ccd_count", 0).toInt();
int actualCcdCount = ccdCount; int actualCcdCount = ccdCount;
for (int index = 0; index < ccdCount; index++) { for (int index = 0; index < ccdCount; index++)
{
CCD *newCCD = CCD::ccdFromSettings(settings, index); CCD *newCCD = CCD::ccdFromSettings(settings, index);
if (newCCD != NULL) { if (newCCD != NULL)
{
ccds.append(newCCD); ccds.append(newCCD);
} else { }
else
{
actualCcdCount--; actualCcdCount--;
} }
} }
if (actualCcdCount < ccdCount) { if (actualCcdCount < ccdCount)
{
qWarning() << "The Oculars ini file appears to be co rrupt; delete it."; qWarning() << "The Oculars ini file appears to be co rrupt; delete it.";
ready = false; ready = false;
} }
int telescopeCount = settings->value("telescope_count", 0).t oInt(); int telescopeCount = settings->value("telescope_count", 0).t oInt();
int actualTelescopeCount = telescopeCount; int actualTelescopeCount = telescopeCount;
for (int index = 0; index < telescopeCount; index++) { for (int index = 0; index < telescopeCount; index++)
{
Telescope *newTelescope = Telescope::telescopeFromSe ttings(settings, index); Telescope *newTelescope = Telescope::telescopeFromSe ttings(settings, index);
if (newTelescope != NULL) { if (newTelescope != NULL)
{
telescopes.append(newTelescope); telescopes.append(newTelescope);
}else { }
else
{
actualTelescopeCount--; actualTelescopeCount--;
} }
} }
if (actualTelescopeCount < 1) { if (actualTelescopeCount < 1)
if (actualTelescopeCount < telescopeCount) { {
if (actualTelescopeCount < telescopeCount)
{
qWarning() << "The Oculars ini file appears to be corrupt; delete it."; qWarning() << "The Oculars ini file appears to be corrupt; delete it.";
} else { }
else
{
qWarning() << "There are no telescopes defin ed for the Oculars plugin; plugin will be disabled."; qWarning() << "There are no telescopes defin ed for the Oculars plugin; plugin will be disabled.";
} }
ready = false; ready = false;
} else { }
else
{
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
} }
int lensCount = settings->value("lens_count", 0).toInt(); int lensCount = settings->value("lens_count", 0).toInt();
int actualLensCount = lensCount; int actualLensCount = lensCount;
for (int index = 0; index<lensCount; index++) { for (int index = 0; index<lensCount; index++)
{
Lens *newLens = Lens::lensFromSettings(settings, ind ex); Lens *newLens = Lens::lensFromSettings(settings, ind ex);
if (newLens != NULL) { if (newLens != NULL)
{
lense.append(newLens); lense.append(newLens);
} }
else { else
{
actualLensCount--; actualLensCount--;
} }
} }
if (lensCount > 0 && actualLensCount < lensCount) if (lensCount > 0 && actualLensCount < lensCount)
{ {
qWarning() << "The Oculars ini file appears to be co rrupt; delete it."; qWarning() << "The Oculars ini file appears to be co rrupt; delete it.";
} }
ocularDialog = new OcularDialog(this, &ccds, &oculars, &tele scopes, &lense); ocularDialog = new OcularDialog(this, &ccds, &oculars, &tele scopes, &lense);
initializeActivationActions(); initializeActivationActions();
determineMaxEyepieceAngle(); determineMaxEyepieceAngle();
guiPanelEnabled = settings->value("enable_control_panel", tr ue).toBool(); guiPanelEnabled = settings->value("enable_control_panel", tr ue).toBool();
enableGuiPanel(guiPanelEnabled); enableGuiPanel(guiPanelEnabled);
setFlagDecimalDegrees(settings->value("use_decimal_degrees", false).toBool()); setFlagDecimalDegrees(settings->value("use_decimal_degrees", false).toBool());
setFlagLimitMagnitude(settings->value("limit_stellar_magnitu de", true).toBool()); setFlagLimitMagnitude(settings->value("limit_stellar_magnitu de", true).toBool());
setFlagInitFovUsage(settings->value("use_initial_fov", false ).toBool()); setFlagInitFovUsage(settings->value("use_initial_fov", false ).toBool());
setFlagUseFlipForCCD(settings->value("use_ccd_flip", false). toBool()); setFlagUseFlipForCCD(settings->value("use_ccd_flip", false). toBool());
setFlagUseSemiTransparency(settings->value("use_semi_transpa rency", false).toBool()); setFlagUseSemiTransparency(settings->value("use_semi_transpa rency", false).toBool());
} catch (std::runtime_error& e) { }
catch (std::runtime_error& e)
{
qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what(); qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what();
ready = false; ready = false;
} }
//Load the module's custom style sheets //Load the module's custom style sheets
QFile styleSheetFile; QFile styleSheetFile;
styleSheetFile.setFileName(":/ocular/normalStyle.css"); styleSheetFile.setFileName(":/ocular/normalStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) { if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
normalStyleSheet = styleSheetFile.readAll(); normalStyleSheet = styleSheetFile.readAll();
} }
styleSheetFile.close(); styleSheetFile.close();
styleSheetFile.setFileName(":/ocular/nightStyle.css"); styleSheetFile.setFileName(":/ocular/nightStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) { if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
nightStyleSheet = styleSheetFile.readAll(); nightStyleSheet = styleSheetFile.readAll();
} }
styleSheetFile.close(); styleSheetFile.close();
connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt
ring&)), ring&)), this, SLOT(setStelStyle(const QString&)));
this, SLOT(setStelStyle(const QStrin connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL
g&))); OT(retranslateGui()));
connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslateGui()));
connect(this, SIGNAL(selectedOcularChanged()), this, SLOT(updateOcul arReticle())); connect(this, SIGNAL(selectedOcularChanged()), this, SLOT(updateOcul arReticle()));
} }
void Oculars::setStelStyle(const QString&) void Oculars::setStelStyle(const QString&)
{ {
if(ocularDialog) { if(ocularDialog)
{
ocularDialog->updateStyle(); ocularDialog->updateStyle();
} }
} }
/* ************************************************************************ ****************************************** */ /* ************************************************************************ ****************************************** */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Private slots Methods #pragma mark Private slots Methods
#endif #endif
/* ************************************************************************ ****************************************** */ /* ************************************************************************ ****************************************** */
void Oculars::determineMaxEyepieceAngle() void Oculars::determineMaxEyepieceAngle()
{ {
if (ready) { if (ready)
foreach (Ocular* ocular, oculars) { {
if (ocular->appearentFOV() > maxEyepieceAngle) { foreach (Ocular* ocular, oculars)
{
if (ocular->appearentFOV() > maxEyepieceAngle)
{
maxEyepieceAngle = ocular->appearentFOV(); maxEyepieceAngle = ocular->appearentFOV();
} }
} }
} }
// insure it is not zero // insure it is not zero
if (maxEyepieceAngle == 0.0) { if (maxEyepieceAngle == 0.0)
{
maxEyepieceAngle = 1.0; maxEyepieceAngle = 1.0;
} }
} }
void Oculars::instrumentChanged() void Oculars::instrumentChanged()
{ {
// We only zoom if in ocular mode. // We only zoom if in ocular mode.
if (flagShowOculars) { if (flagShowOculars)
{
zoom(true); zoom(true);
} }
} }
void Oculars::setRequireSelection(bool state) void Oculars::setRequireSelection(bool state)
{ {
requireSelection = state; requireSelection = state;
} }
void Oculars::setScaleImageCircle(bool state) void Oculars::setScaleImageCircle(bool state)
{ {
if (state) { if (state)
{
determineMaxEyepieceAngle(); determineMaxEyepieceAngle();
} }
useMaxEyepieceAngle = state; useMaxEyepieceAngle = state;
} }
void Oculars::setScreenFOVForCCD() void Oculars::setScreenFOVForCCD()
{ {
Lens * lens = selectedLensIndex >=0 ? lense[selectedLensIndex] : NU LL; Lens * lens = selectedLensIndex >=0 ? lense[selectedLensIndex] : NU LL;
if (selectedCCDIndex > -1 && selectedTelescopeIndex > -1) { if (selectedCCDIndex > -1 && selectedTelescopeIndex > -1)
{
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
double actualFOVx = ccds[selectedCCDIndex]->getActualFOVx(te lescopes[selectedTelescopeIndex], lens); double actualFOVx = ccds[selectedCCDIndex]->getActualFOVx(te lescopes[selectedTelescopeIndex], lens);
double actualFOVy = ccds[selectedCCDIndex]->getActualFOVy(te lescopes[selectedTelescopeIndex], lens); double actualFOVy = ccds[selectedCCDIndex]->getActualFOVy(te lescopes[selectedTelescopeIndex], lens);
if (actualFOVx < actualFOVy) { if (actualFOVx < actualFOVy)
{
actualFOVx = actualFOVy; actualFOVx = actualFOVy;
} }
movementManager->setFlagTracking(true); movementManager->setFlagTracking(true);
movementManager->zoomTo(actualFOVx * 1.75, 0.0); movementManager->zoomTo(actualFOVx * 1.75, 0.0);
} }
} }
void Oculars::enableGuiPanel(bool enable) void Oculars::enableGuiPanel(bool enable)
{ {
if (enable) if (enable)
skipping to change at line 752 skipping to change at line 830
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Slots Methods #pragma mark Slots Methods
#endif #endif
/* ************************************************************************ ****************************************** */ /* ************************************************************************ ****************************************** */
void Oculars::updateLists() void Oculars::updateLists()
{ {
if (oculars.isEmpty()) if (oculars.isEmpty())
{ {
selectedOcularIndex = -1; selectedOcularIndex = -1;
actionShowOcular->setChecked(false); enableOcular(false);
} }
else else
{ {
if (selectedOcularIndex >= oculars.count()) if (selectedOcularIndex >= oculars.count())
selectedOcularIndex = oculars.count() - 1; selectedOcularIndex = oculars.count() - 1;
if (flagShowOculars) if (flagShowOculars)
emit selectedOcularChanged(); emit selectedOcularChanged();
} }
if (telescopes.isEmpty()) if (telescopes.isEmpty())
{ {
selectedTelescopeIndex = -1; selectedTelescopeIndex = -1;
actionShowOcular->setChecked(false); enableOcular(false);
actionShowSensor->setChecked(false); toggleCCD(false);
} }
else else
{ {
if (selectedTelescopeIndex >= telescopes.count()) if (selectedTelescopeIndex >= telescopes.count())
selectedTelescopeIndex = telescopes.count() - 1; selectedTelescopeIndex = telescopes.count() - 1;
if (flagShowOculars || flagShowCCD) if (flagShowOculars || flagShowCCD)
emit selectedTelescopeChanged(); emit selectedTelescopeChanged();
} }
if (ccds.isEmpty()) if (ccds.isEmpty())
{ {
selectedCCDIndex = -1; selectedCCDIndex = -1;
actionShowSensor->setChecked(false); toggleCCD(false);
} }
else else
{ {
if (selectedCCDIndex >= ccds.count()) if (selectedCCDIndex >= ccds.count())
selectedCCDIndex = ccds.count() - 1; selectedCCDIndex = ccds.count() - 1;
if (flagShowCCD) if (flagShowCCD)
emit selectedCCDChanged(); emit selectedCCDChanged();
} }
} }
skipping to change at line 814 skipping to change at line 892
else return 0.0; else return 0.0;
} }
void Oculars::enableOcular(bool enableOcularMode) void Oculars::enableOcular(bool enableOcularMode)
{ {
if (enableOcularMode) if (enableOcularMode)
{ {
// Close the sensor view if it's displayed // Close the sensor view if it's displayed
if (flagShowCCD) if (flagShowCCD)
{ {
if (actionShowSensor->isChecked()) toggleCCD(false);
actionShowSensor->setChecked(false);
flagShowCCD = false; flagShowCCD = false;
selectedCCDIndex = -1; selectedCCDIndex = -1;
} }
// Close the Telrad sight if it's displayed // Close the Telrad sight if it's displayed
if (flagShowTelrad) if (flagShowTelrad)
{ {
if (actionShowTelrad->isChecked()) toggleTelrad(false);
actionShowTelrad->setChecked(false);
} }
// Check to ensure that we have enough oculars & telescopes, as they may have been edited in the config dialog // Check to ensure that we have enough oculars & telescopes, as they may have been edited in the config dialog
if (oculars.count() == 0) { if (oculars.count() == 0)
{
selectedOcularIndex = -1; selectedOcularIndex = -1;
qWarning() << "No oculars found"; qWarning() << "No oculars found";
} else if (oculars.count() > 0 && selectedOcularIndex == -1) }
{ else if (oculars.count() > 0 && selectedOcularIndex == -1)
{
selectedOcularIndex = 0; selectedOcularIndex = 0;
} }
if (telescopes.count() == 0) { if (telescopes.count() == 0)
{
selectedTelescopeIndex = -1; selectedTelescopeIndex = -1;
qWarning() << "No telescopes found"; qWarning() << "No telescopes found";
} else if (telescopes.count() > 0 && selectedTelescopeIndex }
== -1) { else if (telescopes.count() > 0 && selectedTelescopeIndex ==
-1)
{
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
} }
} }
if (!ready || selectedOcularIndex == -1 || (selectedTelescopeIndex if (!ready || selectedOcularIndex == -1 || (selectedTelescopeIndex
== -1 && !isBinocularDefined())) { == -1 && !isBinocularDefined()))
{
qWarning() << "The Oculars module has been disabled."; qWarning() << "The Oculars module has been disabled.";
return; return;
} }
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
LabelMgr* labelManager = GETSTELMODULE(LabelMgr); LabelMgr* labelManager = GETSTELMODULE(LabelMgr);
// Toggle the ocular view on & off. To toggle on, we want to ensure there is a selected object. // Toggle the ocular view on & off. To toggle on, we want to ensure there is a selected object.
if (!flagShowOculars && requireSelection && !StelApp::getInstance(). if (!flagShowOculars && requireSelection && !StelApp::getInstance().
getStelObjectMgr().getWasSelected() ) { getStelObjectMgr().getWasSelected() )
if (usageMessageLabelID == -1) { {
if (usageMessageLabelID == -1)
{
QFontMetrics metrics(font); QFontMetrics metrics(font);
QString labelText = q_("Please select an object befo re switching to ocular view."); QString labelText = q_("Please select an object befo re switching to ocular view.");
StelProjector::StelProjectorParams projectorParams = core->getCurrentStelProjectorParams(); StelProjector::StelProjectorParams projectorParams = core->getCurrentStelProjectorParams();
int xPosition = projectorParams.viewportCenter[0]; int xPosition = projectorParams.viewportCenter[0];
xPosition = xPosition - 0.5 * (metrics.width(labelTe xt)); xPosition = xPosition - 0.5 * (metrics.width(labelTe xt));
int yPosition = projectorParams.viewportCenter[1]; int yPosition = projectorParams.viewportCenter[1];
yPosition = yPosition - 0.5 * (metrics.height()); yPosition = yPosition - 0.5 * (metrics.height());
const char *tcolor = "#99FF99"; const char *tcolor = "#99FF99";
usageMessageLabelID = labelManager->labelScreen(labe lText, xPosition, yPosition, usageMessageLabelID = labelManager->labelScreen(labe lText, xPosition, yPosition,
true , font.pixelSize(), tcolor); true , font.pixelSize(), tcolor);
} }
// we didn't accept the new status - make sure the toolbar b }
utton reflects this else
disconnect(actionShowOcular, SIGNAL(toggled(bool)), {
this, SLOT(enableOc if (selectedOcularIndex != -1)
ular(bool))); {
actionShowOcular->setChecked(false);
connect(actionShowOcular, SIGNAL(toggled(bool)),
this, SLOT(enableOcular(bool
)));
} else {
if (selectedOcularIndex != -1) {
// remove the usage label if it is being displayed. // remove the usage label if it is being displayed.
hideUsageMessageIfDisplayed(); hideUsageMessageIfDisplayed();
flagShowOculars = enableOcularMode; flagShowOculars = enableOcularMode;
zoom(false); zoom(false);
//BM: I hope this is the right place... //BM: I hope this is the right place...
if (guiPanel) if (guiPanel)
guiPanel->showOcularGui(); guiPanel->showOcularGui();
} }
} }
emit enableOcularChanged(flagShowOculars);
} }
void Oculars::decrementCCDIndex() void Oculars::decrementCCDIndex()
{ {
selectedCCDIndex--; selectedCCDIndex--;
if (selectedCCDIndex == -1) { if (selectedCCDIndex == -1)
{
selectedCCDIndex = ccds.count() - 1; selectedCCDIndex = ccds.count() - 1;
} }
emit(selectedCCDChanged()); emit(selectedCCDChanged());
} }
void Oculars::decrementOcularIndex() void Oculars::decrementOcularIndex()
{ {
selectedOcularIndex--; selectedOcularIndex--;
if (selectedOcularIndex == -1) { if (selectedOcularIndex == -1)
{
selectedOcularIndex = oculars.count() - 1; selectedOcularIndex = oculars.count() - 1;
} }
// validate the new selection // validate the new selection
if (selectedOcularIndex > -1 && !oculars[selectedOcularIndex]->isBin if (selectedOcularIndex > -1 && !oculars[selectedOcularIndex]->isBin
oculars()) { oculars())
if ( selectedTelescopeIndex == -1 && telescopes.count() == 0 {
) { if ( selectedTelescopeIndex == -1 && telescopes.count() == 0
)
{
// reject the change // reject the change
selectedOcularIndex++; selectedOcularIndex++;
} else if (selectedTelescopeIndex == -1) { }
else if (selectedTelescopeIndex == -1)
{
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} else { }
else
{
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} }
} else { }
else
{
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} }
} }
void Oculars::decrementTelescopeIndex() void Oculars::decrementTelescopeIndex()
{ {
selectedTelescopeIndex--; selectedTelescopeIndex--;
if (selectedTelescopeIndex == -1) { if (selectedTelescopeIndex == -1)
{
selectedTelescopeIndex = telescopes.count() - 1; selectedTelescopeIndex = telescopes.count() - 1;
} }
emit(selectedTelescopeChanged()); emit(selectedTelescopeChanged());
} }
void Oculars::decrementLensIndex() void Oculars::decrementLensIndex()
{ {
selectedLensIndex--; selectedLensIndex--;
if (selectedLensIndex == lense.count()) { if (selectedLensIndex == lense.count())
{
selectedLensIndex = -1; selectedLensIndex = -1;
} }
if (selectedLensIndex == -2) { if (selectedLensIndex == -2)
{
selectedLensIndex = lense.count() - 1; selectedLensIndex = lense.count() - 1;
} }
emit(selectedLensChanged()); emit(selectedLensChanged());
} }
void Oculars::displayPopupMenu() void Oculars::displayPopupMenu()
{ {
QMenu * popup = new QMenu(&StelMainView::getInstance()); QMenu * popup = new QMenu(&StelMainView::getInstance());
StelGui * gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui ()); StelGui * gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui ());
Q_ASSERT(gui); Q_ASSERT(gui);
qDebug() <<this->getModuleStyleSheet(gui->getStelStyle()).qtStyleShe et; qDebug() <<this->getModuleStyleSheet(gui->getStelStyle()).qtStyleShe et;
popup->setStyleSheet(this->getModuleStyleSheet(gui->getStelStyle()). qtStyleSheet); popup->setStyleSheet(this->getModuleStyleSheet(gui->getStelStyle()). qtStyleSheet);
if (flagShowOculars) { if (flagShowOculars)
{
// We are in Oculars mode // We are in Oculars mode
// We want to show all of the Oculars, and if the current oc ular is not a binocular, // We want to show all of the Oculars, and if the current oc ular is not a binocular,
// we will also show the telescopes. // we will also show the telescopes.
if (!oculars.isEmpty()) { if (!oculars.isEmpty())
{
popup->addAction(q_("&Previous ocular"), this, SLOT( decrementOcularIndex())); popup->addAction(q_("&Previous ocular"), this, SLOT( decrementOcularIndex()));
popup->addAction(q_("&Next ocular"), this, SLOT(incr ementOcularIndex())); popup->addAction(q_("&Next ocular"), this, SLOT(incr ementOcularIndex()));
QMenu* submenu = new QMenu(q_("Select &ocular"), pop up); QMenu* submenu = new QMenu(q_("Select &ocular"), pop up);
int availableOcularCount = 0; int availableOcularCount = 0;
for (int index = 0; index < oculars.count(); ++index for (int index = 0; index < oculars.count(); ++index
) { )
{
QString label; QString label;
if (availableOcularCount < 10) { if (availableOcularCount < 10)
{
label = QString("&%1: %2").arg(avail ableOcularCount).arg(oculars[index]->name()); label = QString("&%1: %2").arg(avail ableOcularCount).arg(oculars[index]->name());
} else { }
else
{
label = oculars[index]->name(); label = oculars[index]->name();
} }
//BM: Does this happen at all any more? //BM: Does this happen at all any more?
QAction* action = 0; QAction* action = 0;
if (selectedTelescopeIndex == -1) { if (selectedTelescopeIndex == -1)
if (oculars[index]->isBinoculars()) {
{ if (oculars[index]->isBinoculars())
{
action = submenu->addAction( label, ocularsSignalMapper, SLOT(map())); action = submenu->addAction( label, ocularsSignalMapper, SLOT(map()));
availableOcularCount++; availableOcularCount++;
ocularsSignalMapper->setMapp ing(action, QString("%1").arg(index)); ocularsSignalMapper->setMapp ing(action, QString("%1").arg(index));
} }
} else { }
else
{
action = submenu->addAction(label, o cularsSignalMapper, SLOT(map())); action = submenu->addAction(label, o cularsSignalMapper, SLOT(map()));
availableOcularCount++; availableOcularCount++;
ocularsSignalMapper->setMapping(acti on, QString("%1").arg(index)); ocularsSignalMapper->setMapping(acti on, QString("%1").arg(index));
} }
if (action && index == selectedOcularIndex) if (action && index == selectedOcularIndex)
{ {
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
} }
} }
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
// If there is more than one telescope, show the prev/next/l ist complex. // If there is more than one telescope, show the prev/next/l ist complex.
// If the selected ocular is a binoculars, show nothing. // If the selected ocular is a binoculars, show nothing.
if (telescopes.count() > 1 && (selectedOcularIndex > -1 && ! if (telescopes.count() > 1 && (selectedOcularIndex > -1 && !
oculars[selectedOcularIndex]->isBinoculars())) { oculars[selectedOcularIndex]->isBinoculars()))
{
QMenu* submenu = addTelescopeSubmenu(popup); QMenu* submenu = addTelescopeSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
submenu = addLensSubmenu(popup); submenu = addLensSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
QAction* action = popup->addAction(q_("Toggle &crosshair")); QAction* action = popup->addAction(q_("Toggle &crosshair"));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(flagShowCrosshairs); action->setChecked(flagShowCrosshairs);
connect(action, SIGNAL(toggled(bool)), actionShowCrosshairs, SLOT(setChecked(bool))); connect(action, SIGNAL(toggled(bool)), actionShowCrosshairs, SLOT(setChecked(bool)));
} else { }
else
{
// We are not in ocular mode // We are not in ocular mode
// We want to show the CCD's, and if a CCD is selected, the telescopes // We want to show the CCD's, and if a CCD is selected, the telescopes
//(as a CCD requires a telescope) and the general menu items . //(as a CCD requires a telescope) and the general menu items .
QAction* action = new QAction(q_("Configure &Oculars"), popu p); QAction* action = new QAction(q_("Configure &Oculars"), popu p);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(ocularDialog->visible()); action->setChecked(ocularDialog->visible());
connect(action, SIGNAL(triggered(bool)), ocularDialog, SLOT( setVisible(bool))); connect(action, SIGNAL(triggered(bool)), ocularDialog, SLOT( setVisible(bool)));
popup->addAction(action); popup->addAction(action);
popup->addSeparator(); popup->addSeparator();
if (!flagShowTelrad) { if (!flagShowTelrad)
{
QAction* action = popup->addAction(q_("Toggle &CCD") ); QAction* action = popup->addAction(q_("Toggle &CCD") );
action->setCheckable(true); action->setCheckable(true);
action->setChecked(flagShowCCD); action->setChecked(flagShowCCD);
connect(action, SIGNAL(toggled(bool)), actionShowSen sor, SLOT(setChecked(bool))); connect(action, SIGNAL(toggled(bool)), actionShowSen sor, SLOT(setChecked(bool)));
} }
if (!flagShowCCD) { if (!flagShowCCD)
{
QAction* action = popup->addAction(q_("Toggle &Telra d")); QAction* action = popup->addAction(q_("Toggle &Telra d"));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(flagShowTelrad); action->setChecked(flagShowTelrad);
connect(action, SIGNAL(toggled(bool)), actionShowTel rad, SLOT(setChecked(bool))); connect(action, SIGNAL(toggled(bool)), actionShowTel rad, SLOT(setChecked(bool)));
} }
popup->addSeparator(); popup->addSeparator();
if (flagShowCCD && selectedCCDIndex > -1 && selectedTelescop if (flagShowCCD && selectedCCDIndex > -1 && selectedTelescop
eIndex > -1) { eIndex > -1)
{
popup->addAction(q_("&Previous CCD"), this, SLOT(dec rementCCDIndex())); popup->addAction(q_("&Previous CCD"), this, SLOT(dec rementCCDIndex()));
popup->addAction(q_("&Next CCD"), this, SLOT(increme ntCCDIndex())); popup->addAction(q_("&Next CCD"), this, SLOT(increme ntCCDIndex()));
QMenu* submenu = new QMenu(q_("&Select CCD"), popup) ; QMenu* submenu = new QMenu(q_("&Select CCD"), popup) ;
for (int index = 0; index < ccds.count(); ++index) { for (int index = 0; index < ccds.count(); ++index)
{
QString label; QString label;
if (index < 10) { if (index < 10)
{
label = QString("&%1: %2").arg(index ).arg(ccds[index]->name()); label = QString("&%1: %2").arg(index ).arg(ccds[index]->name());
} else { }
else
{
label = ccds[index]->name(); label = ccds[index]->name();
} }
QAction* action = submenu->addAction(label, ccdsSignalMapper, SLOT(map())); QAction* action = submenu->addAction(label, ccdsSignalMapper, SLOT(map()));
if (index == selectedCCDIndex) { if (index == selectedCCDIndex)
{
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
} }
ccdsSignalMapper->setMapping(action, QString ("%1").arg(index)); ccdsSignalMapper->setMapping(action, QString ("%1").arg(index));
} }
popup->addMenu(submenu); popup->addMenu(submenu);
submenu = new QMenu(q_("&Rotate CCD"), popup); submenu = new QMenu(q_("&Rotate CCD"), popup);
QAction* rotateAction = NULL; QAction* rotateAction = NULL;
rotateAction = submenu->addAction(QString("&1: -90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map())); rotateAction = submenu->addAction(QString("&1: -90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
skipping to change at line 1068 skipping to change at line 1187
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("15")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("15"));
rotateAction = submenu->addAction(QString("&9: +45") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map())); rotateAction = submenu->addAction(QString("&9: +45") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("45")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("45"));
rotateAction = submenu->addAction(QString("&0: +90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map())); rotateAction = submenu->addAction(QString("&0: +90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("90")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("90"));
rotateAction = submenu->addAction(q_("&Reset rotatio n"), this, SLOT(ccdRotationReset())); rotateAction = submenu->addAction(q_("&Reset rotatio n"), this, SLOT(ccdRotationReset()));
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
if (flagShowCCD && selectedCCDIndex > -1 && telescopes.count if (flagShowCCD && selectedCCDIndex > -1 && telescopes.count
() > 1) { () > 1)
{
QMenu* submenu = addTelescopeSubmenu(popup); QMenu* submenu = addTelescopeSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
submenu = addLensSubmenu(popup); submenu = addLensSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
} }
popup->exec(QCursor::pos()); popup->exec(QCursor::pos());
delete popup; delete popup;
} }
void Oculars::incrementCCDIndex() void Oculars::incrementCCDIndex()
{ {
selectedCCDIndex++; selectedCCDIndex++;
if (selectedCCDIndex == ccds.count()) { if (selectedCCDIndex == ccds.count())
{
selectedCCDIndex = 0; selectedCCDIndex = 0;
} }
emit(selectedCCDChanged()); emit(selectedCCDChanged());
} }
void Oculars::incrementOcularIndex() void Oculars::incrementOcularIndex()
{ {
selectedOcularIndex++; selectedOcularIndex++;
if (selectedOcularIndex == oculars.count()) { if (selectedOcularIndex == oculars.count())
{
selectedOcularIndex = 0; selectedOcularIndex = 0;
} }
// validate the new selection // validate the new selection
if (selectedOcularIndex > -1 && !oculars[selectedOcularIndex]->isBin if (selectedOcularIndex > -1 && !oculars[selectedOcularIndex]->isBin
oculars()) { oculars())
if ( selectedTelescopeIndex == -1 && telescopes.count() == 0 {
) { if ( selectedTelescopeIndex == -1 && telescopes.count() == 0
)
{
// reject the change // reject the change
selectedOcularIndex++; selectedOcularIndex++;
} else if (selectedTelescopeIndex == -1) { }
else if (selectedTelescopeIndex == -1)
{
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} else { }
else
{
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} }
} else { }
else
{
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} }
} }
void Oculars::incrementTelescopeIndex() void Oculars::incrementTelescopeIndex()
{ {
selectedTelescopeIndex++; selectedTelescopeIndex++;
if (selectedTelescopeIndex == telescopes.count()) { if (selectedTelescopeIndex == telescopes.count())
{
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
} }
emit(selectedTelescopeChanged()); emit(selectedTelescopeChanged());
} }
void Oculars::incrementLensIndex() void Oculars::incrementLensIndex()
{ {
selectedLensIndex++; selectedLensIndex++;
if (selectedLensIndex == lense.count()) { if (selectedLensIndex == lense.count())
{
selectedLensIndex = -1; selectedLensIndex = -1;
} }
emit(selectedLensChanged()); emit(selectedLensChanged());
} }
void Oculars::disableLens() void Oculars::disableLens()
{ {
selectedLensIndex = -1; selectedLensIndex = -1;
emit(selectedLensChanged()); emit(selectedLensChanged());
} }
void Oculars::rotateCCD(QString amount) void Oculars::rotateCCD(QString amount)
{ {
CCD *ccd = ccds[selectedCCDIndex]; CCD *ccd = ccds[selectedCCDIndex];
if (!ccd) return; if (!ccd) return;
double angle = ccd->chipRotAngle(); double angle = ccd->chipRotAngle();
angle += amount.toInt(); angle += amount.toInt();
if (angle >= 360) { if (angle >= 360)
{
angle -= 360; angle -= 360;
} else if (angle <= -360) { }
else if (angle <= -360)
{
angle += 360; angle += 360;
} }
ccd->setChipRotAngle(angle); ccd->setChipRotAngle(angle);
emit(selectedCCDChanged()); emit(selectedCCDChanged());
} }
void Oculars::selectCCDAtIndex(QString indexString) void Oculars::selectCCDAtIndex(QString indexString)
{ {
int index = indexString.toInt(); int index = indexString.toInt();
if (index > -2 && index < ccds.count()) { if (index > -2 && index < ccds.count())
{
selectedCCDIndex = index; selectedCCDIndex = index;
emit(selectedCCDChanged()); emit(selectedCCDChanged());
} }
} }
void Oculars::selectOcularAtIndex(QString indexString) void Oculars::selectOcularAtIndex(QString indexString)
{ {
int index = indexString.toInt(); int index = indexString.toInt();
// validate the new selection // validate the new selection
if (oculars[index]->isBinoculars()) { if (oculars[index]->isBinoculars())
{
selectedOcularIndex = index; selectedOcularIndex = index;
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} else { }
if ( selectedTelescopeIndex == -1 && telescopes.count() == 0 else
) { {
if ( selectedTelescopeIndex == -1 && telescopes.count() == 0
)
{
// reject the change // reject the change
} else { }
if (selectedTelescopeIndex == -1) { else
{
if (selectedTelescopeIndex == -1)
{
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
} }
selectedOcularIndex = index; selectedOcularIndex = index;
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} }
} }
} }
void Oculars::selectTelescopeAtIndex(QString indexString) void Oculars::selectTelescopeAtIndex(QString indexString)
{ {
int index = indexString.toInt(); int index = indexString.toInt();
if (index > -2 && index < telescopes.count()) { if (index > -2 && index < telescopes.count())
{
selectedTelescopeIndex = index; selectedTelescopeIndex = index;
emit(selectedTelescopeChanged()); emit(selectedTelescopeChanged());
} }
} }
void Oculars::selectLensAtIndex(QString indexString) void Oculars::selectLensAtIndex(QString indexString)
{ {
int index = indexString.toInt(); int index = indexString.toInt();
if (index > -2 && index < lense.count()) { if (index > -2 && index < lense.count())
{
selectedLensIndex = index; selectedLensIndex = index;
emit(selectedLensChanged()); emit(selectedLensChanged());
} }
} }
void Oculars::toggleCCD(bool show) void Oculars::toggleCCD(bool show)
{ {
//If there are no sensors... //If there are no sensors...
if (ccds.isEmpty() || telescopes.isEmpty()) { if (ccds.isEmpty() || telescopes.isEmpty())
{
//TODO: BM: Make this an on-screen message and/or disable th e button //TODO: BM: Make this an on-screen message and/or disable th e button
//if there are no sensors. //if there are no sensors.
if (show) if (show)
qWarning() << "Oculars plugin: Unable to display a s ensor boundary: No sensors or telescopes are defined."; qWarning() << "Oculars plugin: Unable to display a s ensor boundary: No sensors or telescopes are defined.";
flagShowCCD = false; flagShowCCD = false;
selectedCCDIndex = -1; selectedCCDIndex = -1;
show = false; show = false;
if (actionShowSensor->isChecked()) {
actionShowSensor->setChecked(false);
}
} }
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
if (show) { StelSkyDrawer *skyManager = core->getSkyDrawer();
skyManager->setAbsoluteStarScale(absoluteStarScale);
if (show)
{
initialFOV = movementManager->getCurrentFov(); initialFOV = movementManager->getCurrentFov();
//Mutually exclusive with the ocular mode //Mutually exclusive with the ocular mode
hideUsageMessageIfDisplayed(); hideUsageMessageIfDisplayed();
if (flagShowOculars) { enableOcular(false);
if (actionShowOcular->isChecked()) {
actionShowOcular->setChecked(false);
}
}
if (flagShowTelrad) { if (flagShowTelrad) {
if (actionShowTelrad->isChecked()) { toggleTelrad(false);
actionShowTelrad->setChecked(false);
}
} }
if (selectedTelescopeIndex < 0) { if (selectedTelescopeIndex < 0)
{
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
} }
if (selectedCCDIndex < 0) { if (selectedCCDIndex < 0)
{
selectedCCDIndex = 0; selectedCCDIndex = 0;
} }
flagShowCCD = true; flagShowCCD = true;
setScreenFOVForCCD(); setScreenFOVForCCD();
if (guiPanel) { // Change relative scale for stars
// TODO: Finding experimental value for better rendering
skyManager->setRelativeStarScale(0.6);
if (guiPanel)
{
guiPanel->showCcdGui(); guiPanel->showCcdGui();
} }
} else { }
else
{
flagShowCCD = false; flagShowCCD = false;
skyManager->setRelativeStarScale(relativeStarScale);
movementManager->setFlagTracking(false); movementManager->setFlagTracking(false);
//Zoom out //Zoom out
if (getFlagInitFovUsage()) if (getFlagInitFovUsage())
movementManager->zoomTo(movementManager->getInitFov( )); movementManager->zoomTo(movementManager->getInitFov( ));
else else
movementManager->zoomTo(initialFOV); movementManager->zoomTo(initialFOV);
if (getFlagUseFlipForCCD()) if (getFlagUseFlipForCCD())
{ {
core->setFlipHorz(false); core->setFlipHorz(false);
core->setFlipVert(false); core->setFlipVert(false);
} }
if (guiPanel) { if (guiPanel)
{
guiPanel->foldGui(); guiPanel->foldGui();
} }
} }
emit enableCCDChanged(flagShowCCD);
} }
void Oculars::toggleCCD() void Oculars::toggleCCD()
{ {
if (flagShowCCD) { toggleCCD(!flagShowCCD);
toggleCCD(false);
} else {
toggleCCD(true);
}
} }
void Oculars::toggleCrosshairs(bool show) void Oculars::toggleCrosshairs(bool show)
{ {
if (show && flagShowOculars) if(show != flagShowCrosshairs)
{ {
flagShowCrosshairs = true; flagShowCrosshairs = show;
} emit enableCrosshairsChanged(show);
else
{
flagShowCrosshairs = false;
} }
} }
void Oculars::toggleTelrad(bool show) void Oculars::toggleTelrad(bool show)
{ {
if (show) if(show!=flagShowTelrad)
{ {
hideUsageMessageIfDisplayed(); if (show)
if (actionShowOcular->isChecked()) {
actionShowOcular->setChecked(false); hideUsageMessageIfDisplayed();
if (actionShowSensor->isChecked()) enableOcular(false);
actionShowSensor->setChecked(false); toggleCCD(false);
}
flagShowTelrad = show;
emit enableTelradChanged(flagShowTelrad);
} }
flagShowTelrad = show;
} }
void Oculars::toggleTelrad() void Oculars::toggleTelrad()
{ {
if (flagShowTelrad) toggleTelrad(!flagShowTelrad);
toggleTelrad(false);
else
toggleTelrad(true);
} }
/* ************************************************************************ ****************************************** */ /* ************************************************************************ ****************************************** */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Private Methods #pragma mark Private Methods
#endif #endif
/* ************************************************************************ ****************************************** */ /* ************************************************************************ ****************************************** */
void Oculars::initializeActivationActions() void Oculars::initializeActivationActions()
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); Q_ASSERT(gui);
QString ocularsGroup = N_("Oculars"); QString ocularsGroup = N_("Oculars");
actionShowOcular = addAction("actionShow_Ocular", ocularsGroup, N_(" actionShowOcular = addAction("actionShow_Ocular", ocularsGroup, N_("
Ocular view"), "enableOcular(bool)", "Ctrl+O"); Ocular view"), "enableOcular", "Ctrl+O");
actionShowOcular->setChecked(flagShowOculars);
// Make a toolbar button // Make a toolbar button
try { try
{
pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png"); pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png");
pxmapOnIcon = new QPixmap(":/ocular/bt_ocular_on.png"); pxmapOnIcon = new QPixmap(":/ocular/bt_ocular_on.png");
pxmapOffIcon = new QPixmap(":/ocular/bt_ocular_off.png"); pxmapOffIcon = new QPixmap(":/ocular/bt_ocular_off.png");
toolbarButton = new StelButton(NULL, toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff
*pxmapOnIcon, Icon, *pxmapGlow, "actionShow_Ocular");
*pxmapOffIcon,
*pxmapGlow,
"actionShow_Ocular");
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup");
} catch (std::runtime_error& e) { }
catch (std::runtime_error& e)
{
qWarning() << "WARNING: unable create toolbar button for Ocu lars plugin: " << e.what(); qWarning() << "WARNING: unable create toolbar button for Ocu lars plugin: " << e.what();
} }
actionMenu = addAction("actionShow_Ocular_Menu", ocularsGroup, N_("O culars popup menu"), "displayPopupMenu()", "Alt+O"); actionMenu = addAction("actionShow_Ocular_Menu", ocularsGroup, N_("O culars popup menu"), "displayPopupMenu()", "Alt+O");
actionShowCrosshairs = addAction("actionShow_Ocular_Crosshairs", ocu actionShowCrosshairs = addAction("actionShow_Ocular_Crosshairs", ocu
larsGroup, N_("Show crosshairs"), "toggleCrosshairs(bool)", "Alt+C"); larsGroup, N_("Show crosshairs"), "enableCrosshairs", "Alt+C");
actionShowSensor = addAction("actionShow_Sensor", ocularsGroup, N_(" actionShowSensor = addAction("actionShow_Sensor", ocularsGroup, N_("
Image sensor frame"), "toggleCCD(bool)"); Image sensor frame"), "enableCCD");
actionShowTelrad = addAction("actionShow_Telrad", ocularsGroup, N_(" actionShowTelrad = addAction("actionShow_Telrad", ocularsGroup, N_("
Telrad sight"), "toggleTelrad(bool)", "Ctrl+B"); Telrad sight"), "enableTelrad", "Ctrl+B");
actionConfiguration = addAction("actionOpen_Oculars_Configuration", ocularsGroup, N_("Oculars plugin configuration"), ocularDialog, "visible"); actionConfiguration = addAction("actionOpen_Oculars_Configuration", ocularsGroup, N_("Oculars plugin configuration"), ocularDialog, "visible");
// Select next telescope via keyboard // Select next telescope via keyboard
addAction("actionShow_Telescope_Increment", ocularsGroup, N_("Select next telescope"), "incrementTelescopeIndex()", ""); addAction("actionShow_Telescope_Increment", ocularsGroup, N_("Select next telescope"), "incrementTelescopeIndex()", "");
// Select previous telescope via keyboard // Select previous telescope via keyboard
addAction("actionShow_Telescope_Decrement", ocularsGroup, N_("Select previous telescope"), "decrementTelescopeIndex()", ""); addAction("actionShow_Telescope_Decrement", ocularsGroup, N_("Select previous telescope"), "decrementTelescopeIndex()", "");
// Select next eyepiece via keyboard // Select next eyepiece via keyboard
addAction("actionShow_Ocular_Increment", ocularsGroup, N_("Select ne xt eyepiece"), "incrementOcularIndex()", ""); addAction("actionShow_Ocular_Increment", ocularsGroup, N_("Select ne xt eyepiece"), "incrementOcularIndex()", "");
// Select previous eyepiece via keyboard // Select previous eyepiece via keyboard
addAction("actionShow_Ocular_Decrement", ocularsGroup, N_("Select pr evious eyepiece"), "decrementOcularIndex()", ""); addAction("actionShow_Ocular_Decrement", ocularsGroup, N_("Select pr evious eyepiece"), "decrementOcularIndex()", "");
connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentCha nged())); connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentCha nged()));
skipping to change at line 1372 skipping to change at line 1515
connect(ccdsSignalMapper, SIGNAL(mapped(QString)), this, SLOT(setScr eenFOVForCCD())); connect(ccdsSignalMapper, SIGNAL(mapped(QString)), this, SLOT(setScr eenFOVForCCD()));
connect(ocularsSignalMapper, SIGNAL(mapped(QString)), this, SLOT(sel ectOcularAtIndex(QString))); connect(ocularsSignalMapper, SIGNAL(mapped(QString)), this, SLOT(sel ectOcularAtIndex(QString)));
connect(telescopesSignalMapper, SIGNAL(mapped(QString)), this, SLOT( selectTelescopeAtIndex(QString))); connect(telescopesSignalMapper, SIGNAL(mapped(QString)), this, SLOT( selectTelescopeAtIndex(QString)));
connect(telescopesSignalMapper, SIGNAL(mapped(QString)), this, SLOT( setScreenFOVForCCD())); connect(telescopesSignalMapper, SIGNAL(mapped(QString)), this, SLOT( setScreenFOVForCCD()));
connect(lenseSignalMapper, SIGNAL(mapped(QString)), this, SLOT(selec tLensAtIndex(QString))); connect(lenseSignalMapper, SIGNAL(mapped(QString)), this, SLOT(selec tLensAtIndex(QString)));
} }
bool Oculars::isBinocularDefined() bool Oculars::isBinocularDefined()
{ {
bool binocularFound = false; bool binocularFound = false;
foreach (Ocular* ocular, oculars) { foreach (Ocular* ocular, oculars)
if (ocular->isBinoculars()) { {
if (ocular->isBinoculars())
{
binocularFound = true; binocularFound = true;
break; break;
} }
} }
return binocularFound; return binocularFound;
} }
void Oculars::paintCCDBounds() void Oculars::paintCCDBounds()
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
Lens *lens = selectedLensIndex >=0 ? lense[selectedLensIndex] : NUL L; Lens *lens = selectedLensIndex >=0 ? lense[selectedLensIndex] : NUL L;
const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu); const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu);
double screenFOV = params.fov; double screenFOV = params.fov;
// draw sensor rectangle // draw sensor rectangle
if(selectedCCDIndex != -1) { if(selectedCCDIndex != -1)
{
CCD *ccd = ccds[selectedCCDIndex]; CCD *ccd = ccds[selectedCCDIndex];
if (ccd) { if (ccd)
{
StelPainter painter(projector); StelPainter painter(projector);
painter.setColor(0.77f, 0.14f, 0.16f, 1.0f); painter.setColor(0.77f, 0.14f, 0.16f, 1.0f);
Telescope *telescope = telescopes[selectedTelescopeI ndex]; Telescope *telescope = telescopes[selectedTelescopeI ndex];
const double ccdXRatio = ccd->getActualFOVx(telescop e, lens) / screenFOV; const double ccdXRatio = ccd->getActualFOVx(telescop e, lens) / screenFOV;
const double ccdYRatio = ccd->getActualFOVy(telescop e, lens) / screenFOV; const double ccdYRatio = ccd->getActualFOVy(telescop e, lens) / screenFOV;
// flip are needed and allowed? // flip are needed and allowed?
float ratioLimit = 0.125f; float ratioLimit = 0.125f;
if (getFlagUseFlipForCCD() && (ccdXRatio>=ratioLimit || ccdYRatio>=ratioLimit)) if (getFlagUseFlipForCCD() && (ccdXRatio>=ratioLimit || ccdYRatio>=ratioLimit))
skipping to change at line 1417 skipping to change at line 1564
} }
else else
{ {
core->setFlipHorz(false); core->setFlipHorz(false);
core->setFlipVert(false); core->setFlipVert(false);
} }
// As the FOV is based on the narrow aspect of the s creen, we need to calculate // As the FOV is based on the narrow aspect of the s creen, we need to calculate
// height & width based soley off of that dimension. // height & width based soley off of that dimension.
int aspectIndex = 2; int aspectIndex = 2;
if (params.viewportXywh[2] > params.viewportXywh[3]) if (params.viewportXywh[2] > params.viewportXywh[3])
{ {
aspectIndex = 3; aspectIndex = 3;
} }
float width = params.viewportXywh[aspectIndex] * ccd YRatio * params.devicePixelsPerPixel; float width = params.viewportXywh[aspectIndex] * ccd YRatio * params.devicePixelsPerPixel;
float height = params.viewportXywh[aspectIndex] * cc dXRatio * params.devicePixelsPerPixel; float height = params.viewportXywh[aspectIndex] * cc dXRatio * params.devicePixelsPerPixel;
double polarAngle = 0; double polarAngle = 0;
// if the telescope is Equatorial derotate the field // if the telescope is Equatorial derotate the field
if (telescope->isEquatorial()) { if (telescope->isEquatorial())
{
Vec3d CPos; Vec3d CPos;
Vec2f cpos = projector->getViewportCenter(); Vec2f cpos = projector->getViewportCenter();
projector->unProject(cpos[0], cpos[1], CPos) ; projector->unProject(cpos[0], cpos[1], CPos) ;
Vec3d CPrel(CPos); Vec3d CPrel(CPos);
CPrel[2]*=0.2; CPrel[2]*=0.2;
Vec3d crel; Vec3d crel;
projector->project(CPrel, crel); projector->project(CPrel, crel);
polarAngle = atan2(cpos[1] - crel[1], cpos[0 ] - crel[0]) * (-180.0)/M_PI; // convert to degrees polarAngle = atan2(cpos[1] - crel[1], cpos[0 ] - crel[0]) * (-180.0)/M_PI; // convert to degrees
if (CPos[2] > 0) polarAngle += 90.0; if (CPos[2] > 0) polarAngle += 90.0;
else polarAngle -= 90.0; else polarAngle -= 90.0;
} }
if (width > 0.0 && height > 0.0) { if (width > 0.0 && height > 0.0)
{
QPoint a, b; QPoint a, b;
QTransform transform = QTransform().translat e(params.viewportCenter[0] * params.devicePixelsPerPixel, QTransform transform = QTransform().translat e(params.viewportCenter[0] * params.devicePixelsPerPixel,
params.viewportCenter[1] * p arams.devicePixelsPerPixel).rotate(-(ccd->chipRotAngle() + polarAngle)); params.viewportCenter[1] * p arams.devicePixelsPerPixel).rotate(-(ccd->chipRotAngle() + polarAngle));
// bottom line // bottom line
a = transform.map(QPoint(-width/2.0, -height /2.0)); a = transform.map(QPoint(-width/2.0, -height /2.0));
b = transform.map(QPoint(width/2.0, -height/ 2.0)); b = transform.map(QPoint(width/2.0, -height/ 2.0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
// top line // top line
a = transform.map(QPoint(-width/2.0, height/ 2.0)); a = transform.map(QPoint(-width/2.0, height/ 2.0));
b = transform.map(QPoint(width/2.0, height/2 .0)); b = transform.map(QPoint(width/2.0, height/2 .0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
// left line // left line
a = transform.map(QPoint(-width/2.0, -height /2.0)); a = transform.map(QPoint(-width/2.0, -height /2.0));
b = transform.map(QPoint(-width/2.0, height/ 2.0)); b = transform.map(QPoint(-width/2.0, height/ 2.0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
// right line // right line
a = transform.map(QPoint(width/2.0, height/2 .0)); a = transform.map(QPoint(width/2.0, height/2 .0));
b = transform.map(QPoint(width/2.0, -height/ 2.0)); b = transform.map(QPoint(width/2.0, -height/ 2.0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
if(ccd->hasOAG()) { if(ccd->hasOAG())
{
const double InnerOAGRatio = ccd->ge tInnerOAGRadius(telescope, lens) / screenFOV; const double InnerOAGRatio = ccd->ge tInnerOAGRadius(telescope, lens) / screenFOV;
const double OuterOAGRatio = ccd->ge tOuterOAGRadius(telescope, lens) / screenFOV; const double OuterOAGRatio = ccd->ge tOuterOAGRadius(telescope, lens) / screenFOV;
const double prismXRatio = ccd->getO AGActualFOVx(telescope, lens) / screenFOV; const double prismXRatio = ccd->getO AGActualFOVx(telescope, lens) / screenFOV;
float in_oag_r = params.viewportXywh [aspectIndex] * InnerOAGRatio * params.devicePixelsPerPixel; float in_oag_r = params.viewportXywh [aspectIndex] * InnerOAGRatio * params.devicePixelsPerPixel;
float out_oag_r = params.viewportXyw h[aspectIndex] * OuterOAGRatio * params.devicePixelsPerPixel; float out_oag_r = params.viewportXyw h[aspectIndex] * OuterOAGRatio * params.devicePixelsPerPixel;
float h_width = params.viewportXywh[ aspectIndex] * prismXRatio * params.devicePixelsPerPixel / 2.0; float h_width = params.viewportXywh[ aspectIndex] * prismXRatio * params.devicePixelsPerPixel / 2.0;
//painter.setColor(0.60f, 0.20f, 0.2 0f, .5f); //painter.setColor(0.60f, 0.20f, 0.2 0f, .5f);
painter.drawCircle(params.viewportCe nter[0] * params.devicePixelsPerPixel, painter.drawCircle(params.viewportCe nter[0] * params.devicePixelsPerPixel,
params.viewportCente r[1] * params.devicePixelsPerPixel, in_oag_r); params.viewportCente r[1] * params.devicePixelsPerPixel, in_oag_r);
skipping to change at line 1544 skipping to change at line 1695
} }
void Oculars::paintCrosshairs() void Oculars::paintCrosshairs()
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu); const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu);
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
// Center of screen // Center of screen
Vec2i centerScreen(projector->getViewportPosX()+projector->getViewpo rtWidth()/2, Vec2i centerScreen(projector->getViewportPosX()+projector->getViewpo rtWidth()/2,
projector->getViewportPosY()+proj ector->getViewportHeight()/2); projector->getViewportPosY()+projector->getViewpo rtHeight()/2);
float length = 0.5 * params.viewportFovDiameter; float length = 0.5 * params.viewportFovDiameter;
// See if we need to scale the length // See if we need to scale the length
if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO
V() > 0.0) { V() > 0.0)
{
length = oculars[selectedOcularIndex]->appearentFOV() * leng th / maxEyepieceAngle; length = oculars[selectedOcularIndex]->appearentFOV() * leng th / maxEyepieceAngle;
} }
length *= params.devicePixelsPerPixel; length *= params.devicePixelsPerPixel;
// Draw the lines // Draw the lines
StelPainter painter(projector); StelPainter painter(projector);
painter.setColor(0.77, 0.14, 0.16, 1); painter.setColor(0.77f, 0.14f, 0.16f, 1.f);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] + length); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] + length);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] - length); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] - length);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] + length, centerScreen[1]); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] + length, centerScreen[1]);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] - length, centerScreen[1]); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] - length, centerScreen[1]);
} }
void Oculars::paintTelrad() void Oculars::paintTelrad()
{ {
if (!flagShowOculars) { if (!flagShowOculars) {
const StelProjectorP projector = StelApp::getInstance().getC ore()->getProjection(StelCore::FrameEquinoxEqu); const StelProjectorP projector = StelApp::getInstance().getC ore()->getProjection(StelCore::FrameEquinoxEqu);
// StelPainter drawing // StelPainter drawing
StelPainter painter(projector); StelPainter painter(projector);
painter.setColor(0.77, 0.14, 0.16, 1.0); painter.setColor(0.77f, 0.14f, 0.16f, 1.f);
Vec2i centerScreen(projector->getViewportPosX() + projector- >getViewportWidth() / 2, Vec2i centerScreen(projector->getViewportPosX() + projector- >getViewportWidth() / 2,
projector-> getViewportPosY() + projector->getViewportHeight() / 2); projector->getViewportPosY() + projector- >getViewportHeight() / 2);
float pixelsPerRad = projector->getPixelPerRadAtCenter(); float pixelsPerRad = projector->getPixelPerRadAtCenter();
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p ixelsPerRad * (M_PI/180) * (0.5)); painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p ixelsPerRad * (M_PI/180) * (0.5));
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p ixelsPerRad * (M_PI/180) * (2.0)); painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p ixelsPerRad * (M_PI/180) * (2.0));
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p ixelsPerRad * (M_PI/180) * (4.0)); painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p ixelsPerRad * (M_PI/180) * (4.0));
} }
} }
void Oculars::paintOcularMask(const StelCore *core) void Oculars::paintOcularMask(const StelCore *core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ; const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ;
StelPainter painter(prj); StelPainter painter(prj);
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
double inner = 0.5 * params.viewportFovDiameter * params.devicePixel sPerPixel; double inner = 0.5 * params.viewportFovDiameter * params.devicePixel sPerPixel;
// See if we need to scale the mask // See if we need to scale the mask
if (useMaxEyepieceAngle if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO
&& oculars[selectedOcularIndex]->appearentFOV() > 0.0 V() > 0.0 && !oculars[selectedOcularIndex]->isBinoculars())
&& !oculars[selectedOcularIndex]->isBinoculars()) { {
inner = oculars[selectedOcularIndex]->appearentFOV() * inner / maxEyepieceAngle; inner = oculars[selectedOcularIndex]->appearentFOV() * inner / maxEyepieceAngle;
} }
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode
// Paint the reticale, if needed // Paint the reticale, if needed
if (!reticleTexture.isNull()) if (!reticleTexture.isNull())
{ {
painter.enableTexture2d(true); painter.enableTexture2d(true);
painter.setColor(0.77, 0.14, 0.16, 1.0); painter.setColor(0.77f, 0.14f, 0.16f, 1.f);
reticleTexture->bind(); reticleTexture->bind();
int textureHeight; int textureHeight;
int textureWidth; int textureWidth;
reticleTexture->getDimensions(textureWidth, textureHeight); reticleTexture->getDimensions(textureWidth, textureHeight);
painter.drawSprite2dMode(params.viewportXywh[2] / 2 * params .devicePixelsPerPixel, painter.drawSprite2dMode(params.viewportXywh[2] / 2 * params .devicePixelsPerPixel,
params.viewportXywh[3] / 2 * params params.viewportXywh[3] / 2 * params.devicePi
.devicePixelsPerPixel, xelsPerPixel,
inner, reticleRotation); inner, reticleRotation);
} }
if (oculars[selectedOcularIndex]->hasPermanentCrosshair()) { if (oculars[selectedOcularIndex]->hasPermanentCrosshair())
{
paintCrosshairs(); paintCrosshairs();
} }
float alpha = 1.f; float alpha = 1.f;
if (getFlagUseSemiTransparency()) if (getFlagUseSemiTransparency())
alpha = 0.85f; alpha = 0.85f;
painter.setColor(0.f,0.f,0.f,alpha); painter.setColor(0.f,0.f,0.f,alpha);
GLfloat outerRadius = params.viewportXywh[2] * params.devicePixelsPe rPixel + params.viewportXywh[3] * params.devicePixelsPerPixel; GLfloat outerRadius = params.viewportXywh[2] * params.devicePixelsPe rPixel + params.viewportXywh[3] * params.devicePixelsPerPixel;
skipping to change at line 1651 skipping to change at line 1803
sinCache[slices]=sinCache[0]; sinCache[slices]=sinCache[0];
cosCache[slices]=cosCache[0]; cosCache[slices]=cosCache[0];
/* Enable arrays */ /* Enable arrays */
painter.enableClientStates(true); painter.enableClientStates(true);
painter.setVertexPointer(3, GL_FLOAT, vertices); painter.setVertexPointer(3, GL_FLOAT, vertices);
radiusHigh=outerRadius-deltaRadius; radiusHigh=outerRadius-deltaRadius;
for (int i=0; i<=slices; i++) for (int i=0; i<=slices; i++)
{ {
vertices[i*2][0]= params.viewportCenter[0] + outerRadius*sin vertices[i*2][0]= params.viewportCenter[0] * params.devicePi
Cache[i]; xelsPerPixel + outerRadius*sinCache[i];
vertices[i*2][1]= params.viewportCenter[1] + outerRadius*cos vertices[i*2][1]= params.viewportCenter[1] * params.devicePi
Cache[i]; xelsPerPixel + outerRadius*cosCache[i];
vertices[i*2][2] = 0.0; vertices[i*2][2] = 0.0;
vertices[i*2+1][0]= params.viewportCenter[0] + radiusHigh*si vertices[i*2+1][0]= params.viewportCenter[0] * params.device
nCache[i]; PixelsPerPixel + radiusHigh*sinCache[i];
vertices[i*2+1][1]= params.viewportCenter[1] + radiusHigh*co vertices[i*2+1][1]= params.viewportCenter[1] * params.device
sCache[i]; PixelsPerPixel + radiusHigh*cosCache[i];
vertices[i*2+1][2] = 0.0; vertices[i*2+1][2] = 0.0;
} }
painter.drawFromArray(StelPainter::TriangleStrip, (slices+1)*2, 0, f alse); painter.drawFromArray(StelPainter::TriangleStrip, (slices+1)*2, 0, f alse);
painter.enableClientStates(false); painter.enableClientStates(false);
} }
void Oculars::paintText(const StelCore* core) void Oculars::paintText(const StelCore* core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ; const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ;
StelPainter painter(prj); StelPainter painter(prj);
// Get the current instruments // Get the current instruments
CCD *ccd = NULL; CCD *ccd = NULL;
if(selectedCCDIndex != -1) { if(selectedCCDIndex != -1)
{
ccd = ccds[selectedCCDIndex]; ccd = ccds[selectedCCDIndex];
} }
Ocular *ocular = NULL; Ocular *ocular = NULL;
if(selectedOcularIndex !=-1) { if(selectedOcularIndex !=-1)
{
ocular = oculars[selectedOcularIndex]; ocular = oculars[selectedOcularIndex];
} }
Telescope *telescope = NULL; Telescope *telescope = NULL;
if(selectedTelescopeIndex != -1) { if(selectedTelescopeIndex != -1)
{
telescope = telescopes[selectedTelescopeIndex]; telescope = telescopes[selectedTelescopeIndex];
} }
Lens *lens = NULL; Lens *lens = NULL;
if(selectedLensIndex != -1) { if(selectedLensIndex != -1)
{
lens = lense[selectedLensIndex]; lens = lense[selectedLensIndex];
} }
// set up the color and the GL state // set up the color and the GL state
painter.setColor(0.8, 0.48, 0.0, 1); painter.setColor(0.8f, 0.48f, 0.f, 1.f);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
// Get the X & Y positions, and the line height // Get the X & Y positions, and the line height
painter.setFont(font); painter.setFont(font);
QString widthString = "MMMMMMMMMMMMMMMMMMM"; QString widthString = "MMMMMMMMMMMMMMMMMMM";
float insetFromRHS = painter.getFontMetrics().width(widthString); float insetFromRHS = painter.getFontMetrics().width(widthString);
StelProjector::StelProjectorParams projectorParams = core->getCurren tStelProjectorParams(); StelProjector::StelProjectorParams projectorParams = core->getCurren tStelProjectorParams();
int xPosition = projectorParams.viewportXywh[2]; int xPosition = projectorParams.viewportXywh[2];
skipping to change at line 1709 skipping to change at line 1865
yPosition -= 40; yPosition -= 40;
const int lineHeight = painter.getFontMetrics().height(); const int lineHeight = painter.getFontMetrics().height();
// The Ocular // The Ocular
if (flagShowOculars && ocular!=NULL) if (flagShowOculars && ocular!=NULL)
{ {
QString ocularNumberLabel; QString ocularNumberLabel;
QString name = ocular->name(); QString name = ocular->name();
if (name.isEmpty()) if (name.isEmpty())
{ {
ocularNumberLabel = QString(q_("Ocular #%1")) ocularNumberLabel = QString(q_("Ocular #%1")).arg(se
.arg(selectedOcularIndex); lectedOcularIndex);
} }
else else
{ {
ocularNumberLabel = QString(q_("Ocular #%1: %2")) ocularNumberLabel = QString(q_("Ocular #%1: %2")).ar
.arg(selectedOcularIndex) g(selectedOcularIndex).arg(name);
.arg(name);
} }
// The name of the ocular could be really long. // The name of the ocular could be really long.
if (name.length() > widthString.length()) { if (name.length() > widthString.length())
{
xPosition -= (insetFromRHS / 2.0); xPosition -= (insetFromRHS / 2.0);
} }
painter.drawText(xPosition, yPosition, ocularNumberLabel); painter.drawText(xPosition, yPosition, ocularNumberLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
if (!ocular->isBinoculars()) { if (!ocular->isBinoculars())
{
QString eFocalLength = QVariant(ocular->effectiveFoc alLength()).toString(); QString eFocalLength = QVariant(ocular->effectiveFoc alLength()).toString();
// TRANSLATORS: FL = Focal length // TRANSLATORS: FL = Focal length
QString eFocalLengthLabel = QString(q_("Ocular FL: % 1 mm")).arg(eFocalLength); QString eFocalLengthLabel = QString(q_("Ocular FL: % 1 mm")).arg(eFocalLength);
painter.drawText(xPosition, yPosition, eFocalLengthL abel); painter.drawText(xPosition, yPosition, eFocalLengthL abel);
yPosition-=lineHeight; yPosition-=lineHeight;
QString ocularFov = QString::number(ocular->appearen tFOV()); QString ocularFov = QString::number(ocular->appearen tFOV());
ocularFov.append(QChar(0x00B0));//Degree sign ocularFov.append(QChar(0x00B0));//Degree sign
// TRANSLATORS: aFOV = apparent field of view // TRANSLATORS: aFOV = apparent field of view
QString ocularFOVLabel = QString(q_("Ocular aFOV: %1 QString ocularFOVLabel = QString(q_("Ocular aFOV: %1
")) ")).arg(ocularFov);
.arg(ocularFov);
painter.drawText(xPosition, yPosition, ocularFOVLabe l); painter.drawText(xPosition, yPosition, ocularFOVLabe l);
yPosition-=lineHeight; yPosition-=lineHeight;
QString lensNumberLabel; QString lensNumberLabel;
// Barlow and Shapley lens // Barlow and Shapley lens
if (lens != NULL) // it's null if lens is not select ed (lens index = -1) if (lens != NULL) // it's null if lens is not select ed (lens index = -1)
{ {
QString lensName = lens->name(); QString lensName = lens->name();
if (lensName.isEmpty()) if (lensName.isEmpty())
{ {
skipping to change at line 1765 skipping to change at line 1919
{ {
lensNumberLabel = QString (q_("Lens: none")) ; lensNumberLabel = QString (q_("Lens: none")) ;
} }
painter.drawText(xPosition, yPosition, lensNumberLab el); painter.drawText(xPosition, yPosition, lensNumberLab el);
yPosition-=lineHeight; yPosition-=lineHeight;
// The telescope // The telescope
QString telescopeString = ""; QString telescopeString = "";
QString magString = ""; QString magString = "";
QString fovString = ""; QString fovString = "";
QString exitPupil = "";
if (telescope!=NULL) if (telescope!=NULL)
{ {
QString telescopeName = telescope->name(); QString telescopeName = telescope->name();
if (telescopeName.isEmpty()) if (telescopeName.isEmpty())
telescopeString = QString("%1").arg( selectedTelescopeIndex); telescopeString = QString("%1").arg( selectedTelescopeIndex);
else else
telescopeString = QString("%1: %2"). arg(selectedTelescopeIndex).arg(telescopeName); telescopeString = QString("%1: %2"). arg(selectedTelescopeIndex).arg(telescopeName);
// General info // General info
if (lens!=NULL) if (lens!=NULL)
{ {
magString = QString::number(((int)(o cular->magnification(telescope, lens) * 10.0)) / 10.0); magString = QString::number(((int)(o cular->magnification(telescope, lens) * 10.0)) / 10.0);
magString.append(QChar(0x00D7));//Mu ltiplication sign magString.append(QChar(0x00D7));//Mu ltiplication sign
fovString = QString::number(((int)(o cular->actualFOV(telescope, lens) * 10000.00)) / 10000.0); fovString = QString::number(((int)(o cular->actualFOV(telescope, lens) * 10000.00)) / 10000.0);
fovString.append(QChar(0x00B0));//De gree sign fovString.append(QChar(0x00B0));//De gree sign
exitPupil = QString::number(telescop
e->diameter()/ocular->magnification(telescope, lens), 'f', 2);
} }
} }
painter.drawText(xPosition, yPosition, QString(q_("T elescope #%1")).arg(telescopeString)); painter.drawText(xPosition, yPosition, QString(q_("T elescope #%1")).arg(telescopeString));
yPosition-=lineHeight; yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, QString(q_("M agnification: %1")).arg(magString)); painter.drawText(xPosition, yPosition, QString(q_("M agnification: %1")).arg(magString));
yPosition-=lineHeight; yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, QString(q_("E
xit pupil: %1 mm")).arg(exitPupil));
yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, QString(q_("F OV: %1")).arg(fovString)); painter.drawText(xPosition, yPosition, QString(q_("F OV: %1")).arg(fovString));
} }
} }
// The CCD // The CCD
if (flagShowCCD && ccd!=NULL) { if (flagShowCCD && ccd!=NULL)
{
QString ccdSensorLabel, ccdInfoLabel; QString ccdSensorLabel, ccdInfoLabel;
QString name = ""; QString name = "";
QString telescopeName = ""; QString telescopeName = "";
double fovX = 0.0; double fovX = 0.0;
double fovY = 0.0; double fovY = 0.0;
if (telescope!=NULL && lens!=NULL) if (telescope!=NULL && lens!=NULL)
{ {
fovX = ((int)(ccd->getActualFOVx(telescope, lens) * 1000.0)) / 1000.0; fovX = ((int)(ccd->getActualFOVx(telescope, lens) * 1000.0)) / 1000.0;
fovY = ((int)(ccd->getActualFOVy(telescope, lens) * 1000.0)) / 1000.0; fovY = ((int)(ccd->getActualFOVy(telescope, lens) * 1000.0)) / 1000.0;
name = ccd->name(); name = ccd->name();
skipping to change at line 1855 skipping to change at line 2016
void Oculars::validateAndLoadIniFile() void Oculars::validateAndLoadIniFile()
{ {
// Insure the module directory exists // Insure the module directory exists
StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::getUserDir( )+"/modules/Oculars"); StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::getUserDir( )+"/modules/Oculars");
StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directo ry|StelFileMgr::Writable); StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directo ry|StelFileMgr::Writable);
QString ocularIniPath = StelFileMgr::findFile("modules/Oculars/", fl ags) + "ocular.ini"; QString ocularIniPath = StelFileMgr::findFile("modules/Oculars/", fl ags) + "ocular.ini";
if (ocularIniPath.isEmpty()) if (ocularIniPath.isEmpty())
return; return;
// If the ini file does not already exist, create it from the resour ce in the QT resource // If the ini file does not already exist, create it from the resour ce in the QT resource
if(!QFileInfo(ocularIniPath).exists()) { if(!QFileInfo(ocularIniPath).exists())
{
QFile src(":/ocular/default_ocular.ini"); QFile src(":/ocular/default_ocular.ini");
if (!src.copy(ocularIniPath)) { if (!src.copy(ocularIniPath))
{
qWarning() << "Oculars::validateIniFile cannot copy default_ocular.ini resource to [non-existing] " qWarning() << "Oculars::validateIniFile cannot copy default_ocular.ini resource to [non-existing] "
+ ocularIniPath;
+ ocularIniPath; }
} else { else
{
qDebug() << "Oculars::validateIniFile copied default _ocular.ini to " << QDir::toNativeSeparators(ocularIniPath); qDebug() << "Oculars::validateIniFile copied default _ocular.ini to " << QDir::toNativeSeparators(ocularIniPath);
// The resource is read only, and the new file inher its this, so set write-able. // The resource is read only, and the new file inher its this, so set write-able.
QFile dest(ocularIniPath); QFile dest(ocularIniPath);
dest.setPermissions(dest.permissions() | QFile::Writ eOwner); dest.setPermissions(dest.permissions() | QFile::Writ eOwner);
} }
} else { }
else
{
qDebug() << "Oculars::validateIniFile ocular.ini exists at: " << QDir::toNativeSeparators(ocularIniPath) << ". Checking version..."; qDebug() << "Oculars::validateIniFile ocular.ini exists at: " << QDir::toNativeSeparators(ocularIniPath) << ". Checking version...";
QSettings settings(ocularIniPath, QSettings::IniFormat); QSettings settings(ocularIniPath, QSettings::IniFormat);
double ocularsVersion = settings.value("oculars_version", "0 .0").toDouble(); double ocularsVersion = settings.value("oculars_version", "0 .0").toDouble();
qWarning() << "Oculars::validateIniFile found existing ini f ile version " << ocularsVersion; qWarning() << "Oculars::validateIniFile found existing ini f ile version " << ocularsVersion;
if (ocularsVersion < MIN_OCULARS_INI_VERSION) { if (ocularsVersion < MIN_OCULARS_INI_VERSION)
{
qWarning() << "Oculars::validateIniFile existing ini file version " << ocularsVersion qWarning() << "Oculars::validateIniFile existing ini file version " << ocularsVersion
<< " too ol d to use; required version is " << MIN_OCULARS_INI_VERSION << ". Copying ov er new one."; << " too old to use; required version is " << MIN_OCULARS_INI_VERSION << ". Copying over new one.";
// delete last "old" file, if it exists // delete last "old" file, if it exists
QFile deleteFile(ocularIniPath + ".old"); QFile deleteFile(ocularIniPath + ".old");
deleteFile.remove(); deleteFile.remove();
// Rename the old one, and copy over a new one // Rename the old one, and copy over a new one
QFile oldFile(ocularIniPath); QFile oldFile(ocularIniPath);
if (!oldFile.rename(ocularIniPath + ".old")) { if (!oldFile.rename(ocularIniPath + ".old"))
{
qWarning() << "Oculars::validateIniFile cann ot move ocular.ini resource to ocular.ini.old at path " + QDir::toNativeSe parators(ocularIniPath); qWarning() << "Oculars::validateIniFile cann ot move ocular.ini resource to ocular.ini.old at path " + QDir::toNativeSe parators(ocularIniPath);
} else { }
else
{
qWarning() << "Oculars::validateIniFile ocul ar.ini resource renamed to ocular.ini.old at path " + QDir::toNativeSepara tors(ocularIniPath); qWarning() << "Oculars::validateIniFile ocul ar.ini resource renamed to ocular.ini.old at path " + QDir::toNativeSepara tors(ocularIniPath);
QFile src(":/ocular/default_ocular.ini"); QFile src(":/ocular/default_ocular.ini");
if (!src.copy(ocularIniPath)) { if (!src.copy(ocularIniPath))
{
qWarning() << "Oculars::validateIniF ile cannot copy default_ocular.ini resource to [non-existing] " + QDir::toN ativeSeparators(ocularIniPath); qWarning() << "Oculars::validateIniF ile cannot copy default_ocular.ini resource to [non-existing] " + QDir::toN ativeSeparators(ocularIniPath);
} else { }
else
{
qDebug() << "Oculars::validateIniFil e copied default_ocular.ini to " << QDir::toNativeSeparators(ocularIniPath) ; qDebug() << "Oculars::validateIniFil e copied default_ocular.ini to " << QDir::toNativeSeparators(ocularIniPath) ;
// The resource is read only, and th e new file inherits this... make sure the new file // The resource is read only, and th e new file inherits this... make sure the new file
// is writable by the Stellarium pro cess so that updates can be done. // is writable by the Stellarium pro cess so that updates can be done.
QFile dest(ocularIniPath); QFile dest(ocularIniPath);
dest.setPermissions(dest.permissions () | QFile::WriteOwner); dest.setPermissions(dest.permissions () | QFile::WriteOwner);
} }
} }
} }
} }
settings = new QSettings(ocularIniPath, QSettings::IniFormat, this); settings = new QSettings(ocularIniPath, QSettings::IniFormat, this);
skipping to change at line 1926 skipping to change at line 2100
gridManager->setFlagLongitudeLine(flagLongitudeLine); gridManager->setFlagLongitudeLine(flagLongitudeLine);
gridManager->setFlagHorizonLine(flagHorizonLine); gridManager->setFlagHorizonLine(flagHorizonLine);
gridManager->setFlagGalacticEquatorLine(flagGalacticEquatorLine); gridManager->setFlagGalacticEquatorLine(flagGalacticEquatorLine);
skyManager->setFlagLuminanceAdaptation(flagAdaptation); skyManager->setFlagLuminanceAdaptation(flagAdaptation);
skyManager->setFlagStarMagnitudeLimit(flagLimitStars); skyManager->setFlagStarMagnitudeLimit(flagLimitStars);
skyManager->setFlagPlanetMagnitudeLimit(flagLimitPlanets); skyManager->setFlagPlanetMagnitudeLimit(flagLimitPlanets);
skyManager->setFlagNebulaMagnitudeLimit(flagLimitDSOs); skyManager->setFlagNebulaMagnitudeLimit(flagLimitDSOs);
skyManager->setCustomStarMagnitudeLimit(magLimitStars); skyManager->setCustomStarMagnitudeLimit(magLimitStars);
skyManager->setCustomPlanetMagnitudeLimit(magLimitPlanets); skyManager->setCustomPlanetMagnitudeLimit(magLimitPlanets);
skyManager->setCustomNebulaMagnitudeLimit(magLimitDSOs); skyManager->setCustomNebulaMagnitudeLimit(magLimitDSOs);
skyManager->setRelativeStarScale(relativeStarScale);
skyManager->setAbsoluteStarScale(absoluteStarScale);
movementManager->setFlagTracking(false); movementManager->setFlagTracking(false);
movementManager->setFlagEnableZoomKeys(true); movementManager->setFlagEnableZoomKeys(true);
movementManager->setFlagEnableMouseNavigation(true); movementManager->setFlagEnableMouseNavigation(true);
GETSTELMODULE(SolarSystem)->setFlagMoonScale(flagMoonScale); GETSTELMODULE(SolarSystem)->setFlagMoonScale(flagMoonScale);
// Set the screen display // Set the screen display
core->setFlipHorz(false); core->setFlipHorz(flipHorz);
core->setFlipVert(false); core->setFlipVert(flipVert);
if (getFlagInitFovUsage()) if (getFlagInitFovUsage())
movementManager->zoomTo(movementManager->getInitFov()); movementManager->zoomTo(movementManager->getInitFov());
else else
movementManager->zoomTo(initialFOV); movementManager->zoomTo(initialFOV);
} }
void Oculars::zoom(bool zoomedIn) void Oculars::zoom(bool zoomedIn)
{ {
if (flagShowOculars && selectedOcularIndex == -1) { if (flagShowOculars && selectedOcularIndex == -1)
{
// The user cycled out the selected ocular // The user cycled out the selected ocular
flagShowOculars = false; flagShowOculars = false;
} }
if (flagShowOculars) { if (flagShowOculars)
if (!zoomedIn) { {
if (!zoomedIn)
{
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
GridLinesMgr *gridManager = (GridLinesMgr *)StelApp: :getInstance().getModuleMgr().getModule("GridLinesMgr"); GridLinesMgr *gridManager = (GridLinesMgr *)StelApp: :getInstance().getModuleMgr().getModule("GridLinesMgr");
// Current state // Current state
flagAzimuthalGrid = gridManager->getFlagAzimuthalGri d(); flagAzimuthalGrid = gridManager->getFlagAzimuthalGri d();
flagGalacticGrid = gridManager->getFlagGalacticGrid( ); flagGalacticGrid = gridManager->getFlagGalacticGrid( );
flagEquatorGrid = gridManager->getFlagEquatorGrid(); flagEquatorGrid = gridManager->getFlagEquatorGrid();
flagEquatorJ2000Grid = gridManager->getFlagEquatorJ2 000Grid(); flagEquatorJ2000Grid = gridManager->getFlagEquatorJ2 000Grid();
flagEquatorLine = gridManager->getFlagEquatorLine(); flagEquatorLine = gridManager->getFlagEquatorLine();
flagEclipticLine = gridManager->getFlagEclipticLine( ); flagEclipticLine = gridManager->getFlagEclipticLine( );
skipping to change at line 1976 skipping to change at line 2155
StelSkyDrawer *skyManager = core->getSkyDrawer(); StelSkyDrawer *skyManager = core->getSkyDrawer();
// Current state // Current state
flagAdaptation = skyManager->getFlagLuminanceAdaptat ion(); flagAdaptation = skyManager->getFlagLuminanceAdaptat ion();
flagLimitStars = skyManager->getFlagStarMagnitudeLim it(); flagLimitStars = skyManager->getFlagStarMagnitudeLim it();
flagLimitPlanets = skyManager->getFlagPlanetMagnitud eLimit(); flagLimitPlanets = skyManager->getFlagPlanetMagnitud eLimit();
flagLimitDSOs = skyManager->getFlagNebulaMagnitudeLi mit(); flagLimitDSOs = skyManager->getFlagNebulaMagnitudeLi mit();
magLimitStars = skyManager->getCustomStarMagnitudeLi mit(); magLimitStars = skyManager->getCustomStarMagnitudeLi mit();
magLimitPlanets = skyManager->getCustomPlanetMagnitu deLimit(); magLimitPlanets = skyManager->getCustomPlanetMagnitu deLimit();
magLimitDSOs = skyManager->getCustomNebulaMagnitudeL imit(); magLimitDSOs = skyManager->getCustomNebulaMagnitudeL imit();
relativeStarScale = skyManager->getRelativeStarScale
();
absoluteStarScale = skyManager->getAbsoluteStarScale
();
flagMoonScale = GETSTELMODULE(SolarSystem)->getFlagM oonScale(); flagMoonScale = GETSTELMODULE(SolarSystem)->getFlagM oonScale();
flipHorz = core->getFlipHorz();
flipVert = core->getFlipVert();
StelMovementMgr *movementManager = core->getMovement Mgr(); StelMovementMgr *movementManager = core->getMovement Mgr();
initialFOV = movementManager->getCurrentFov(); initialFOV = movementManager->getCurrentFov();
} }
// set new state // set new state
zoomOcular(); zoomOcular();
} else { }
else
{
//reset to original state //reset to original state
unzoomOcular(); unzoomOcular();
} }
} }
void Oculars::zoomOcular() void Oculars::zoomOcular()
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
GridLinesMgr *gridManager = GridLinesMgr *gridManager = (GridLinesMgr *)StelApp::getInstance().g
(GridLinesMgr *)StelApp::getInstance().getModuleMgr( etModuleMgr().getModule("GridLinesMgr");
).getModule("GridLinesMgr");
StelSkyDrawer *skyManager = core->getSkyDrawer(); StelSkyDrawer *skyManager = core->getSkyDrawer();
gridManager->setFlagAzimuthalGrid(false); gridManager->setFlagAzimuthalGrid(false);
gridManager->setFlagGalacticGrid(false); gridManager->setFlagGalacticGrid(false);
gridManager->setFlagEquatorGrid(false); gridManager->setFlagEquatorGrid(false);
gridManager->setFlagEquatorJ2000Grid(false); gridManager->setFlagEquatorJ2000Grid(false);
gridManager->setFlagEquatorLine(false); gridManager->setFlagEquatorLine(false);
gridManager->setFlagEclipticLine(false); gridManager->setFlagEclipticLine(false);
gridManager->setFlagEclipticJ2000Grid(false); gridManager->setFlagEclipticJ2000Grid(false);
skipping to change at line 2020 skipping to change at line 2205
gridManager->setFlagGalacticEquatorLine(false); gridManager->setFlagGalacticEquatorLine(false);
skyManager->setFlagLuminanceAdaptation(false); skyManager->setFlagLuminanceAdaptation(false);
GETSTELMODULE(SolarSystem)->setFlagMoonScale(false); GETSTELMODULE(SolarSystem)->setFlagMoonScale(false);
movementManager->setFlagTracking(true); movementManager->setFlagTracking(true);
movementManager->setFlagEnableZoomKeys(false); movementManager->setFlagEnableZoomKeys(false);
movementManager->setFlagEnableMouseNavigation(false); movementManager->setFlagEnableMouseNavigation(false);
// We won't always have a selected object // We won't always have a selected object
if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) { if (StelApp::getInstance().getStelObjectMgr().getWasSelected())
{
StelObjectP selectedObject = StelApp::getInstance().getStelO bjectMgr().getSelectedObject()[0]; StelObjectP selectedObject = StelApp::getInstance().getStelO bjectMgr().getSelectedObject()[0];
movementManager->moveToJ2000(selectedObject->getEquinoxEquat orialPos(core), 0.0, 1); movementManager->moveToJ2000(selectedObject->getEquinoxEquat orialPos(core), movementManager->mountFrameToJ2000(Vec3d(0., 0., 1.)), 0.0, StelMovementMgr::ZoomIn);
} }
// Set the screen display // Set the screen display
Ocular * ocular = oculars[selectedOcularIndex]; Ocular * ocular = oculars[selectedOcularIndex];
Telescope * telescope = NULL; Telescope * telescope = NULL;
Lens * lens = NULL; Lens * lens = NULL;
// Only consider flip is we're not binoculars // Only consider flip is we're not binoculars
if (ocular->isBinoculars()) if (ocular->isBinoculars())
{ {
core->setFlipHorz(false); core->setFlipHorz(false);
core->setFlipVert(false); core->setFlipVert(false);
} }
else else
{ {
if (selectedLensIndex >= 0) { if (selectedLensIndex >= 0)
{
lens = lense[selectedLensIndex]; lens = lense[selectedLensIndex];
} }
telescope = telescopes[selectedTelescopeIndex]; telescope = telescopes[selectedTelescopeIndex];
core->setFlipHorz(telescope->isHFlipped()); core->setFlipHorz(telescope->isHFlipped());
core->setFlipVert(telescope->isVFlipped()); core->setFlipVert(telescope->isVFlipped());
} }
// Change relative and absolute scales for stars
// TODO: Finding experimental value for better rendering
skyManager->setRelativeStarScale(0.6);
skyManager->setAbsoluteStarScale(0.75);
// Limit stars and DSOs if it enable and it's telescope + eyepiece c ombination // Limit stars and DSOs if it enable and it's telescope + eyepiece c ombination
if (getFlagLimitMagnitude() && !ocular->isBinoculars()) if (getFlagLimitMagnitude() && !ocular->isBinoculars())
{ {
// Simplified calculation of the penetrating power of the te lescope // Simplified calculation of the penetrating power of the te lescope
double limitMag = 2.1 + 5*std::log10(telescope->diameter()); double limitMag = 2.1 + 5*std::log10(telescope->diameter());
skyManager->setFlagStarMagnitudeLimit(true); skyManager->setFlagStarMagnitudeLimit(true);
skyManager->setFlagNebulaMagnitudeLimit(true); skyManager->setFlagNebulaMagnitudeLimit(true);
skyManager->setCustomStarMagnitudeLimit(limitMag); skyManager->setCustomStarMagnitudeLimit(limitMag);
skyManager->setCustomNebulaMagnitudeLimit(limitMag); skyManager->setCustomNebulaMagnitudeLimit(limitMag);
} }
actualFOV = ocular->actualFOV(telescope, lens); actualFOV = ocular->actualFOV(telescope, lens);
// See if the mask was scaled; if so, correct the actualFOV. // See if the mask was scaled; if so, correct the actualFOV.
if (useMaxEyepieceAngle && ocular->appearentFOV() > 0.0 && !ocular-> if (useMaxEyepieceAngle && ocular->appearentFOV() > 0.0 && !ocular->
isBinoculars()) { isBinoculars())
{
actualFOV = maxEyepieceAngle * actualFOV / ocular->appearent FOV(); actualFOV = maxEyepieceAngle * actualFOV / ocular->appearent FOV();
} }
movementManager->zoomTo(actualFOV, 0.0); movementManager->zoomTo(actualFOV, 0.0);
} }
void Oculars::hideUsageMessageIfDisplayed() void Oculars::hideUsageMessageIfDisplayed()
{ {
if (usageMessageLabelID > -1) { if (usageMessageLabelID > -1)
{
LabelMgr *labelManager = GETSTELMODULE(LabelMgr); LabelMgr *labelManager = GETSTELMODULE(LabelMgr);
labelManager->setLabelShow(usageMessageLabelID, false); labelManager->setLabelShow(usageMessageLabelID, false);
labelManager->deleteLabel(usageMessageLabelID); labelManager->deleteLabel(usageMessageLabelID);
usageMessageLabelID = -1; usageMessageLabelID = -1;
} }
} }
Lens* Oculars::selectedLens() Lens* Oculars::selectedLens()
{ {
if (selectedLensIndex >= 0 && selectedLensIndex < lense.count()) { if (selectedLensIndex >= 0 && selectedLensIndex < lense.count())
{
return lense[selectedLensIndex]; return lense[selectedLensIndex];
} }
return NULL; return NULL;
} }
QMenu* Oculars::addLensSubmenu(QMenu* parent) QMenu* Oculars::addLensSubmenu(QMenu* parent)
{ {
Q_ASSERT(parent); Q_ASSERT(parent);
QMenu *submenu = new QMenu(q_("&Lens"), parent); QMenu *submenu = new QMenu(q_("&Lens"), parent);
 End of changes. 204 change blocks. 
315 lines changed or deleted 509 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/