Oculars.cpp   Oculars.cpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "Oculars.hpp" #include "Oculars.hpp"
#include "OcularsGuiPanel.hpp" #include "OcularsGuiPanel.hpp"
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "SkyGui.hpp"
#include "StelActionMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelGui.hpp"
#include "StelGuiItems.hpp"
#include "StelLocaleMgr.hpp"
#include "StelMainView.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelPainter.hpp"
#include "StelShortcutMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelGui.hpp" #include "StelTextureMgr.hpp"
#include "StelGuiItems.hpp"
#include "StelMainWindow.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "SkyGui.hpp"
#include "renderer/GenericVertexTypes.hpp"
#include "renderer/StelGeometryBuilder.hpp"
#include "renderer/StelRenderer.hpp"
#include <QAction> #include <QAction>
#include <QDebug>
#include <QDir>
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug>
#include <QMenu> #include <QMenu>
#include <QMouseEvent> #include <QMouseEvent>
#include <QtNetwork> #include <QtNetwork>
#include <QPixmap> #include <QPixmap>
#include <QSignalMapper> #include <QSignalMapper>
#include <QDir>
#include <cmath> #include <cmath>
#ifdef Q_OS_MAC
extern void qt_set_sequence_auto_mnemonic(bool b); extern void qt_set_sequence_auto_mnemonic(bool b);
#endif
static QSettings *settings; //!< The settings as read in from the ini file. static QSettings *settings; //!< The settings as read in from the ini file.
/* ********************************************************************* */ /* ************************************************************************ ****************************************** */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark StelModuleMgr Methods #pragma mark StelModuleMgr Methods
#endif #endif
/* ********************************************************************* */ /* ************************************************************************ ****************************************** */
//! This method is the one called automatically by the StelModuleMgr just //! This method is the one called automatically by the StelModuleMgr just
//! after loading the dynamic library //! after loading the dynamic library
StelModule* OcularsStelPluginInterface::getStelModule() const StelModule* OcularsStelPluginInterface::getStelModule() const
{ {
return new Oculars(); return new Oculars();
} }
StelPluginInfo OcularsStelPluginInterface::getPluginInfo() const StelPluginInfo OcularsStelPluginInterface::getPluginInfo() const
{ {
// Allow to load the resources when used as a static plugin // Allow to load the resources when used as a static plugin
Q_INIT_RESOURCE(Oculars); Q_INIT_RESOURCE(Oculars);
StelPluginInfo info; StelPluginInfo info;
info.id = "Oculars"; info.id = "Oculars";
info.displayedName = N_("Oculars"); info.displayedName = N_("Oculars");
info.authors = "Timothy Reaves, Bogdan Marinov, Pawel Stolowski"; info.authors = "Timothy Reaves";
info.contact = "treaves@silverfieldstech.com"; info.contact = "treaves@silverfieldstech.com";
info.description = N_("Shows the sky as if looking through a telesco pe eyepiece. (Only magnification and field of view are simulated.) It can a lso show a sensor frame and a Telrad sight."); info.description = N_("Shows the sky as if looking through a telesco pe eyepiece. (Only magnification and field of view are simulated.) It can a lso show a sensor frame and a Telrad sight.");
info.version = OCULARS_PLUGIN_VERSION;
return info; return info;
} }
Q_EXPORT_PLUGIN2(Oculars, OcularsStelPluginInterface) /* ************************************************************************
****************************************** */
/* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Instance Methods #pragma mark Instance Methods
#endif #endif
/* ********************************************************************* */ /* ************************************************************************ ****************************************** */
Oculars::Oculars(): Oculars::Oculars():
selectedCCDIndex(-1),
selectedOcularIndex(-1),
selectedTelescopeIndex(-1),
selectedLensIndex(-1),
flagShowCCD(false),
flagShowOculars(false),
flagShowCrosshairs(false),
flagShowTelrad(false),
usageMessageLabelID(-1),
flagAzimuthalGrid(false),
flagGalacticGrid(false),
flagEquatorGrid(false),
flagEquatorJ2000Grid(false),
flagEquatorLine(false),
flagEclipticLine(false),
flagEclipticJ2000Grid(false),
flagMeridianLine(false),
flagHorizonLine(false),
flagGalacticPlaneLine(false),
flagAdaptation(false),
flagLimitStars(false),
magLimitStars(0.0),
flagLimitDSOs(false),
magLimitDSOs(0.0),
ccdRotationAngle(0.0),
maxEyepieceAngle(0.0),
requireSelection(true),
flagLimitMagnitude(false),
useMaxEyepieceAngle(true),
guiPanelEnabled(false),
flagDecimalDegrees(false),
ccdRotationSignalMapper(0),
ccdsSignalMapper(0),
ocularsSignalMapper(0),
telescopesSignalMapper(0),
lenseSignalMapper(0),
pxmapGlow(NULL), pxmapGlow(NULL),
pxmapOnIcon(NULL), pxmapOnIcon(NULL),
pxmapOffIcon(NULL), pxmapOffIcon(NULL),
toolbarButton(NULL), toolbarButton(NULL),
ocularDialog(NULL),
ready(false),
actionShowOcular(0), actionShowOcular(0),
actionShowCrosshairs(0), actionShowCrosshairs(0),
actionShowSensor(0), actionShowSensor(0),
actionShowTelrad(0), actionShowTelrad(0),
guiPanel(0) actionConfiguration(0),
actionMenu(0),
actionTelescopeIncrement(0),
actionTelescopeDecrement(0),
actionOcularIncrement(0),
actionOcularDecrement(0),
guiPanel(0),
actualFOV(0),
initialFOV(0),
flagInitFOVUsage(false),
reticleRotation(0)
{ {
flagShowCCD = false;
flagShowOculars = false;
flagShowCrosshairs = false;
flagShowTelrad = false;
ready = false;
requireSelection = true;
useMaxEyepieceAngle = true;
font.setPixelSize(14); font.setPixelSize(14);
maxEyepieceAngle = 0.0;
ccds = QList<CCD *>(); ccds = QList<CCD *>();
oculars = QList<Ocular *>(); oculars = QList<Ocular *>();
telescopes = QList<Telescope *>(); telescopes = QList<Telescope *>();
lense = QList<Lens *> (); lense = QList<Lens *> ();
ccdRotationSignalMapper = new QSignalMapper(this); ccdRotationSignalMapper = new QSignalMapper(this);
ccdsSignalMapper = new QSignalMapper(this); ccdsSignalMapper = new QSignalMapper(this);
ocularsSignalMapper = new QSignalMapper(this); ocularsSignalMapper = new QSignalMapper(this);
telescopesSignalMapper = new QSignalMapper(this); telescopesSignalMapper = new QSignalMapper(this);
lenseSignalMapper = new QSignalMapper(this); lenseSignalMapper = new QSignalMapper(this);
selectedCCDIndex = -1;
selectedOcularIndex = -1;
selectedTelescopeIndex = -1;
selectedLensIndex = -1;
usageMessageLabelID = -1;
setObjectName("Oculars"); setObjectName("Oculars");
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
qt_set_sequence_auto_mnemonic(true); qt_set_sequence_auto_mnemonic(true);
#endif #endif
} }
Oculars::~Oculars() Oculars::~Oculars()
{ {
delete ocularDialog; delete ocularDialog;
skipping to change at line 173 skipping to change at line 201
oculars.clear(); oculars.clear();
qDeleteAll(lense); qDeleteAll(lense);
lense.clear(); lense.clear();
} }
QSettings* Oculars::appSettings() QSettings* Oculars::appSettings()
{ {
return settings; return settings;
} }
/* ********************************************************************* */ /* ************************************************************************ ****************************************** */
#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) {
QString prefix = "ccd/" + QVariant(index).toString() + "/"; ccd->writeToSettings(settings, index);
settings->setValue(prefix + "name", ccd->name());
settings->setValue(prefix + "resolutionX", ccd->resolutionX(
));
settings->setValue(prefix + "resolutionY", ccd->resolutionY(
));
settings->setValue(prefix + "chip_width", ccd->chipWidth());
settings->setValue(prefix + "chip_height", ccd->chipHeight()
);
settings->setValue(prefix + "pixel_width", ccd->pixelWidth()
);
settings->setValue(prefix + "pixel_height", ccd->pixelWidth(
));
index++; index++;
} }
index = 0; index = 0;
foreach(Ocular* ocular, oculars) { foreach(Ocular * ocular, oculars) {
QString prefix = "ocular/" + QVariant(index).toString() + "/ ocular->writeToSettings(settings, index);
";
settings->setValue(prefix + "name", ocular->name());
settings->setValue(prefix + "afov", ocular->appearentFOV());
settings->setValue(prefix + "efl", ocular->effectiveFocalLen
gth());
settings->setValue(prefix + "fieldStop", ocular->fieldStop()
);
settings->setValue(prefix + "binoculars", ocular->isBinocula
rs());
index++; index++;
} }
index = 0; index = 0;
foreach(Telescope* telescope, telescopes){ foreach(Telescope* telescope, telescopes){
QString prefix = "telescope/" + QVariant(index).toString() + telescope->writeToSettings(settings, index);
"/";
settings->setValue(prefix + "name", telescope->name());
settings->setValue(prefix + "focalLength", telescope->focalL
ength());
settings->setValue(prefix + "diameter", telescope->diameter(
));
settings->setValue(prefix + "hFlip", telescope->isHFlipped()
);
settings->setValue(prefix + "vFlip", telescope->isVFlipped()
);
index++; index++;
} }
index = 0; index = 0;
foreach(Lens* lens, lense) { foreach(Lens* lens, lense) {
QString prefix = "lens/" + QVariant(index).toString() + "/"; lens->writeToSettings(settings, index);
settings->setValue(prefix + "name", lens->name());
settings->setValue(prefix + "multipler", lens->multipler());
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(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const
QString&)),
this, SLOT(setStelStyle(const QStrin
g&)));
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, StelRenderer* renderer) void Oculars::draw(StelCore* core)
{ {
if (flagShowTelrad) { if (flagShowTelrad) {
paintTelrad(renderer); 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 CCDIndex << " is greater than the sensor count of " << selected CCDIndex << " is greater than the sensor count of "
<< ccds.cou nt() << ". Module disabled!"; << ccds.cou 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 "
skipping to change at line 270 skipping to change at line 286
} }
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 TelescopeIndex << " is greater than the telescope count of " << selected TelescopeIndex << " is greater than the telescope count of "
<< telescop es.count() << ". Module disabled!"; << telescop es.count() << ". Module disabled!";
ready = false; ready = false;
} }
if (ready) { if (ready) {
if (selectedOcularIndex > -1) { if (selectedOcularIndex > -1) {
paintOcularMask(renderer); paintOcularMask(core);
if (flagShowCrosshairs) { if (flagShowCrosshairs) {
paintCrosshairs(renderer); 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
renderer->setBlendMode(BlendMode_Alpha); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_A
LPHA);
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, renderer); paintText(core);
} }
} }
} else if (flagShowCCD) { } else if (flagShowCCD) {
paintCCDBounds(renderer); 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
renderer->setBlendMode(BlendMode_Alpha); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
} }
else else
{ {
// Paint the information in the upper-right hand cor ner // Paint the information in the upper-right hand cor ner
paintText(core, renderer); paintText(core);
} }
} }
} }
//! Determine which "layer" the plugin's drawing will happen on. //! Determine which "layer" the plugin's drawing will happen on.
double Oculars::getCallOrder(StelModuleActionName actionName) const double Oculars::getCallOrder(StelModuleActionName actionName) const
{ {
// TODO; this really doesn't seem to have any effect. I've tried ev erything from -100 to +100, // TODO; this really doesn't seem to have any effect. I've tried ev erything from -100 to +100,
// and a calculated value. It all seems to work the sa me regardless. // and a calculated value. It all seems to work the sa me regardless.
double order = 1000.0; double order = 1000.0;
skipping to change at line 364 skipping to change at line 384
{ {
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 if (!event->modifiers().testFlag(Qt::Control
Modifier)) { Modifier))
{
movementManager->turnUp(true); movementManager->turnUp(true);
} }
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Down: case Qt::Key_Down:
if (!event->modifiers().testFlag(Qt::Control if (!event->modifiers().testFlag(Qt::Control
Modifier)) { Modifier))
{
movementManager->turnDown(true); movementManager->turnDown(true);
} }
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_PageUp: case Qt::Key_PageUp:
movementManager->zoomIn(true); movementManager->zoomIn(true);
consumeEvent = true; consumeEvent = true;
break; break;
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:
double multiplier = 1.0;
if (event->modifiers().testFlag(Qt::ControlM
odifier))
{
multiplier = 0.1;
}
if (event->modifiers().testFlag(Qt::AltModif
ier))
{
multiplier = 5.0;
}
if (event->modifiers().testFlag(Qt::ShiftMod
ifier))
{
reticleRotation += (1.0 * multiplier
);
} else {
reticleRotation -= (1.0 * multiplier
);
}
qDebug() << reticleRotation;
consumeEvent = true;
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 432 skipping to change at line 476
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.";
skipping to change at line 538 skipping to change at line 584
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", fa lse).toBool(); guiPanelEnabled = settings->value("enable_control_panel", fa lse).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());
} 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();
skipping to change at line 560 skipping to change at line 607
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 ring&)), connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt ring&)),
this, SLOT(setStelStyle(const QStrin g&))); this, SLOT(setStelStyle(const QStrin g&)));
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslateGui())); this, SLOT(retranslateGui()));
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) { foreach (Ocular* ocular, oculars) {
if (ocular->appearentFOV() > maxEyepieceAngle) { if (ocular->appearentFOV() > maxEyepieceAngle) {
maxEyepieceAngle = ocular->appearentFOV(); maxEyepieceAngle = ocular->appearentFOV();
} }
} }
} }
// insure it is not zero // insure it is not zero
skipping to change at line 613 skipping to change at line 661
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] : NUL L; 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 * 3.0, 0.0); movementManager->zoomTo(actualFOVx * 3.0, 0.0);
skipping to change at line 681 skipping to change at line 729
Q_ASSERT(gui); Q_ASSERT(gui);
guiPanel = new OcularsGuiPanel(this, gui->getSkyGui()); guiPanel = new OcularsGuiPanel(this, gui->getSkyGui());
if (flagShowOculars) if (flagShowOculars)
guiPanel->showOcularGui(); guiPanel->showOcularGui();
else if (flagShowCCD) else if (flagShowCCD)
guiPanel->showCcdGui(); guiPanel->showCcdGui();
} }
} }
/* ********************************************************************* */ void Oculars::updateOcularReticle(void)
{
reticleRotation = 0.0;
StelTextureMgr& manager = StelApp::getInstance().getTextureManager()
;
//Load OpenGL textures
StelTexture::StelTextureParams params;
params.generateMipmaps = true;
reticleTexture = manager.createTexture(oculars[selectedOcularIndex]-
>reticlePath(), params);
}
/* ************************************************************************
****************************************** */
#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); actionShowOcular->setChecked(false);
} }
else else
{ {
if (selectedOcularIndex >= oculars.count()) if (selectedOcularIndex >= oculars.count())
skipping to change at line 791 skipping to change at line 849
// 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(). getStelObjectMgr().getWasSelected() ) { if (!flagShowOculars && requireSelection && !StelApp::getInstance(). 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; const char *tcolor = "#99FF99";
if (StelApp::getInstance().getVisionModeNight())
tcolor = "#C40303";
else
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 // we didn't accept the new status - make sure the toolbar b utton reflects this
disconnect(actionShowOcular, SIGNAL(toggled(bool)), disconnect(actionShowOcular, SIGNAL(toggled(bool)),
this, SLOT(enableOc ular(bool))); this, SLOT(enableOc ular(bool)));
actionShowOcular->setChecked(false); actionShowOcular->setChecked(false);
connect(actionShowOcular, SIGNAL(toggled(bool)), connect(actionShowOcular, SIGNAL(toggled(bool)),
this, SLOT(enableOcular(bool ))); this, SLOT(enableOcular(bool )));
} else { } else {
skipping to change at line 872 skipping to change at line 926
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(&StelMainWindow::getInstance()); QMenu* popup = new QMenu(&StelMainView::getInstance());
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()));
skipping to change at line 933 skipping to change at line 987
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)), connect(action, SIGNAL(toggled(bool)), actionShowCrosshairs,
actionShowCrosshairs, SLOT(s SLOT(setChecked(bool)));
etChecked(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)), connect(action, SIGNAL(triggered(bool)), ocularDialog, SLOT(
ocularDialog, SLOT(setVisibl setVisible(bool)));
e(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)), connect(action, SIGNAL(toggled(bool)), actionShowSen
actionShowSensor, SL sor, SLOT(setChecked(bool)));
OT(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)), connect(action, SIGNAL(toggled(bool)), actionShowTel
actionShowTelrad, SL rad, SLOT(setChecked(bool)));
OT(setChecked(bool)));
} }
popup->addSeparator(); popup->addSeparator();
if (flagShowCCD && selectedCCDIndex > -1 && selectedTelescop eIndex > -1) if (flagShowCCD && selectedCCDIndex > -1 && selectedTelescop 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)
{ {
skipping to change at line 992 skipping to change at line 1042
{ {
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") rotateAction = submenu->addAction(QString("&1: -90")
+ QChar(0x00B0), + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-90")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-90"));
rotateAction = submenu->addAction(QString("&2: -45") rotateAction = submenu->addAction(QString("&2: -45")
+ QChar(0x00B0), + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-45")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-45"));
rotateAction = submenu->addAction(QString("&3: -15") rotateAction = submenu->addAction(QString("&3: -15")
+ QChar(0x00B0), + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-15")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-15"));
rotateAction = submenu->addAction(QString("&4: -5") rotateAction = submenu->addAction(QString("&4: -5")
+ QChar(0x00B0), + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-5")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-5"));
rotateAction = submenu->addAction(QString("&5: -1") QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
+ QChar(0x00B0), rotateAction = submenu->addAction(QString("&5: -1")
+ QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-1")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("-1"));
rotateAction = submenu->addAction(QString("&6: +1") QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
+ QChar(0x00B0), rotateAction = submenu->addAction(QString("&6: +1")
+ QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("1")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("1"));
rotateAction = submenu->addAction(QString("&7: +5") QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
+ QChar(0x00B0), rotateAction = submenu->addAction(QString("&7: +5")
+ QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("5")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("5"));
rotateAction = submenu->addAction(QString("&8: +15") QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
+ QChar(0x00B0), rotateAction = submenu->addAction(QString("&8: +15")
+ QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("15")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("15"));
rotateAction = submenu->addAction(QString("&9: +45") rotateAction = submenu->addAction(QString("&9: +45")
+ QChar(0x00B0), + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("45")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("45"));
rotateAction = submenu->addAction(QString("&0: +90") rotateAction = submenu->addAction(QString("&0: +90")
+ QChar(0x00B0), + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
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 () > 1) if (flagShowCCD && selectedCCDIndex > -1 && telescopes.count () > 1)
{ {
QMenu* submenu = addTelescopeSubmenu(popup); QMenu* submenu = addTelescopeSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
skipping to change at line 1099 skipping to change at line 1139
void Oculars::disableLens() void Oculars::disableLens()
{ {
selectedLensIndex = -1; selectedLensIndex = -1;
emit(selectedLensChanged()); emit(selectedLensChanged());
} }
void Oculars::rotateCCD(QString amount) void Oculars::rotateCCD(QString amount)
{ {
ccdRotationAngle += amount.toInt(); ccdRotationAngle += amount.toInt();
if (ccdRotationAngle >= 360) if (ccdRotationAngle >= 360) {
ccdRotationAngle -= 360; ccdRotationAngle -= 360;
if (ccdRotationAngle <= -360) } else if (ccdRotationAngle <= -360) {
ccdRotationAngle += 360; ccdRotationAngle += 360;
}
} }
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());
} }
} }
skipping to change at line 1156 skipping to change at line 1197
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 qWarning() << "Oculars plugin: Unable to display a s
ensor boundary:" ensor boundary: No sensors or telescopes are defined.";
<< "No sens
ors or telescopes are defined.";
flagShowCCD = false; flagShowCCD = false;
selectedCCDIndex = -1; selectedCCDIndex = -1;
show = false; show = false;
if (actionShowSensor->isChecked()) if (actionShowSensor->isChecked()) {
actionShowSensor->setChecked(false); actionShowSensor->setChecked(false);
}
} }
if (show) if (show) {
{
//Mutually exclusive with the ocular mode //Mutually exclusive with the ocular mode
hideUsageMessageIfDisplayed(); hideUsageMessageIfDisplayed();
if (flagShowOculars) if (flagShowOculars) {
{ if (actionShowOcular->isChecked()) {
if (actionShowOcular->isChecked())
actionShowOcular->setChecked(false); actionShowOcular->setChecked(false);
}
} }
if (flagShowTelrad) if (flagShowTelrad) {
{ if (actionShowTelrad->isChecked()) {
if (actionShowTelrad->isChecked())
actionShowTelrad->setChecked(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) if (guiPanel) {
guiPanel->showCcdGui(); guiPanel->showCcdGui();
} }
else } else {
{
flagShowCCD = false; flagShowCCD = false;
//Zoom out //Zoom out
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
movementManager->zoomTo(movementManager->getInitFov()); movementManager->zoomTo(movementManager->getInitFov());
movementManager->setFlagTracking(false); movementManager->setFlagTracking(false);
core->setFlipHorz(false);
core->setFlipVert(false);
if (guiPanel) if (guiPanel) {
guiPanel->foldGui(); guiPanel->foldGui();
}
} }
} }
void Oculars::toggleCCD() void Oculars::toggleCCD()
{ {
if (flagShowCCD) if (flagShowCCD) {
toggleCCD(false); toggleCCD(false);
else } else {
toggleCCD(true); toggleCCD(true);
}
} }
void Oculars::toggleCrosshairs(bool show) void Oculars::toggleCrosshairs(bool show)
{ {
if (show && flagShowOculars) if (show && flagShowOculars)
{ {
flagShowCrosshairs = true; flagShowCrosshairs = true;
} }
else else
{ {
skipping to change at line 1252 skipping to change at line 1296
} }
void Oculars::toggleTelrad() void Oculars::toggleTelrad()
{ {
if (flagShowTelrad) if (flagShowTelrad)
toggleTelrad(false); toggleTelrad(false);
else else
toggleTelrad(true); 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);
StelShortcutMgr* shMgr = StelApp::getInstance().getStelShortcutManag QString ocularsGroup = N_("Oculars");
er(); actionShowOcular = addAction("actionShow_Ocular", ocularsGroup, N_("
Ocular view"), "enableOcular(bool)", "Ctrl+O");
//This action needs to be connected to the enableOcular() slot after
//the necessary button is created to prevent the button from being c
hecked
//the first time this action is checked. See:
//http://doc.qt.nokia.com/4.7/signalsandslots.html#signals
actionShowOcular = shMgr->getGuiAction("actionShow_Ocular");
actionShowOcular->setChecked(flagShowOculars); 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, *pxmapOnIcon,
*pxmapOffIcon, *pxmapOffIcon,
*pxmapGlow, *pxmapGlow,
actionShowOcular); "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();
} }
connect(actionShowOcular, SIGNAL(toggled(bool)),
this, SLOT(enableOcular(bool)));
actionMenu = shMgr->getGuiAction("actionShow_Ocular_Menu");
connect(actionMenu, SIGNAL(toggled(bool)),
this, SLOT(displayPopupMenu()));
actionShowCrosshairs = shMgr->getGuiAction("actionShow_Ocular_Crossh
airs");
connect(actionShowCrosshairs, SIGNAL(toggled(bool)),
this, SLOT(toggleCrosshairs(bool)));
actionShowSensor = shMgr->getGuiAction("actionShow_Sensor");
connect(actionShowSensor, SIGNAL(toggled(bool)),
this, SLOT(toggleCCD(bool)));
actionShowTelrad = shMgr->getGuiAction("actionShow_Telrad");
connect(actionShowTelrad, SIGNAL(toggled(bool)),
this, SLOT(toggleTelrad(bool)));
actionConfiguration = shMgr->getGuiAction("actionOpen_Oculars_Config
uration");
connect(actionConfiguration, SIGNAL(toggled(bool)),
ocularDialog, SLOT(setVisible(bool))
);
connect(ocularDialog, SIGNAL(visibleChanged(bool)),
actionConfiguration, SLOT(setChecked
(bool)));
actionMenu = addAction("actionShow_Ocular_Menu", ocularsGroup, N_("O
culars popup menu"), "displayPopupMenu()", "Alt+O");
actionShowCrosshairs = addAction("actionShow_Ocular_Crosshairs", ocu
larsGroup, N_("Show crosshairs"), "toggleCrosshairs(bool)", "Alt+C");
actionShowSensor = addAction("actionShow_Sensor", ocularsGroup, N_("
Image sensor frame"), "toggleCCD(bool)");
actionShowTelrad = addAction("actionShow_Telrad", ocularsGroup, N_("
Telrad sight"), "toggleTelrad(bool)", "Ctrl+B");
actionConfiguration = addAction("actionOpen_Oculars_Configuration",
ocularsGroup, N_("Oculars plugin configuration"), ocularDialog, "visible");
// Select next telescope via keyboard // Select next telescope via keyboard
actionTelescopeIncrement = shMgr->getGuiAction("actionShow_Telescope addAction("actionShow_Telescope_Increment", ocularsGroup, N_("Select
_Increment"); next telescope"), "incrementTelescopeIndex()", "");
connect(actionTelescopeIncrement, SIGNAL(toggled(bool)), this, SLOT(
incrementTelescopeIndex()));
// Select previous telescope via keyboard // Select previous telescope via keyboard
actionTelescopeDecrement = shMgr->getGuiAction("actionShow_Telescope addAction("actionShow_Telescope_Decrement", ocularsGroup, N_("Select
_Decrement"); previous telescope"), "decrementTelescopeIndex()", "");
connect(actionTelescopeDecrement, SIGNAL(toggled(bool)), this, SLOT(
decrementTelescopeIndex()));
// Select next eyepiece via keyboard // Select next eyepiece via keyboard
actionOcularIncrement = shMgr->getGuiAction("actionShow_Ocular_Incre addAction("actionShow_Ocular_Increment", ocularsGroup, N_("Select ne
ment"); xt eyepiece"), "incrementOcularIndex()", "");
connect(actionOcularIncrement, SIGNAL(toggled(bool)), this, SLOT(inc
rementOcularIndex()));
// Select previous eyepiece via keyboard // Select previous eyepiece via keyboard
actionOcularDecrement = shMgr->getGuiAction("actionShow_Ocular_Decre addAction("actionShow_Ocular_Decrement", ocularsGroup, N_("Select pr
ment"); evious eyepiece"), "decrementOcularIndex()", "");
connect(actionOcularDecrement, SIGNAL(toggled(bool)), this, SLOT(dec
rementOcularIndex()));
connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentCha nged())); connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentCha nged()));
connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(setScreenFOVF orCCD())); connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(setScreenFOVF orCCD()));
connect(this, SIGNAL(selectedOcularChanged()), this, SLOT(instrument Changed())); connect(this, SIGNAL(selectedOcularChanged()), this, SLOT(instrument Changed()));
connect(this, SIGNAL(selectedTelescopeChanged()), this, SLOT(instrum entChanged())); connect(this, SIGNAL(selectedTelescopeChanged()), this, SLOT(instrum entChanged()));
connect(this, SIGNAL(selectedTelescopeChanged()), this, SLOT(setScre enFOVForCCD())); connect(this, SIGNAL(selectedTelescopeChanged()), this, SLOT(setScre enFOVForCCD()));
connect(this, SIGNAL(selectedLensChanged()), this, SLOT(instrumentCh anged())); connect(this, SIGNAL(selectedLensChanged()), this, SLOT(instrumentCh anged()));
connect(ocularDialog, SIGNAL(requireSelectionChanged(bool)), this, S LOT(setRequireSelection(bool))); connect(ocularDialog, SIGNAL(requireSelectionChanged(bool)), this, S LOT(setRequireSelection(bool)));
connect(ocularDialog, SIGNAL(scaleImageCircleChanged(bool)), this, S LOT(setScaleImageCircle(bool))); connect(ocularDialog, SIGNAL(scaleImageCircleChanged(bool)), this, S LOT(setScaleImageCircle(bool)));
connect(ccdRotationSignalMapper, SIGNAL(mapped(QString)), this, SLOT (rotateCCD(QString))); connect(ccdRotationSignalMapper, SIGNAL(mapped(QString)), this, SLOT (rotateCCD(QString)));
skipping to change at line 1356 skipping to change at line 1368
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(StelRenderer* renderer) 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;
renderer->setBlendMode(BlendMode_None); const StelProjectorP projector = core->getProjection(StelCore::Frame
EquinoxEqu);
StelVertexBuffer<VertexP2>* vertices =
renderer->createVertexBuffer<VertexP2>(PrimitiveType_LineStr
ip);
double screenFOV = params.fov; double screenFOV = params.fov;
const Vec2f offset = Vec2f(params.viewportCenter[0], params.viewport Center[1]);
// draw sensor rectangle // draw sensor rectangle
if(selectedCCDIndex != -1) { if(selectedCCDIndex != -1) {
CCD *ccd = ccds[selectedCCDIndex]; CCD *ccd = ccds[selectedCCDIndex];
if (ccd) { if (ccd) {
renderer->setGlobalColor(0.77f, 0.14f, 0.16f, 0.5f); StelPainter painter(projector);
painter.setColor(0.77f, 0.14f, 0.16f, 1.0f);
Telescope *telescope = telescopes[selectedTelescopeI ndex]; Telescope *telescope = telescopes[selectedTelescopeI ndex];
// flip are needed?
core->setFlipHorz(telescope->isHFlipped());
core->setFlipVert(telescope->isVFlipped());
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;
// 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;
} }
const float halfWidth = 0.5f * (params.viewportXywh float width = params.viewportXywh[aspectIndex] * ccd
[aspectIndex] * ccdYRatio); YRatio * params.devicePixelsPerPixel;
const float halfHeight = 0.5f * (params.viewportXywh float height = params.viewportXywh[aspectIndex] * cc
[aspectIndex] * ccdXRatio); dXRatio * params.devicePixelsPerPixel;
if (halfWidth > 0.0 && halfHeight > 0.0) if (width > 0.0 && height > 0.0) {
{ QPoint a, b;
const float s = sin(-ccdRotationAngle * M_PI QTransform transform = QTransform().translat
/ 180.0f); e(params.viewportCenter[0], params.viewportCenter[1]).rotate(-ccdRotationAn
const float c = cos(-ccdRotationAngle * M_PI gle);
/ 180.0f); // bottom line
const float cosHalfWidth = c * halfWidth; a = transform.map(QPoint(-width/2.0, -height
const float sinHalfWidth = s * halfWidth; /2.0));
const float cosHalfHeight = c * halfHeight; b = transform.map(QPoint(width/2.0, -height/
const float sinHalfHeight = s * halfHeight; 2.0));
const Vec2f v1 = Vec2f(-cosHalfWidth - sinHa painter.drawLine2d(a.x(), a.y(), b.x(), b.y(
lfHeight, -sinHalfWidth + cosHalfHeight); ));
const Vec2f v2 = Vec2f(cosHalfWidth - sinHa // top line
lfHeight, sinHalfWidth + cosHalfHeight); a = transform.map(QPoint(-width/2.0, height/
const Vec2f v3 = Vec2f(cosHalfWidth + sinHa 2.0));
lfHeight, sinHalfWidth - cosHalfHeight); b = transform.map(QPoint(width/2.0, height/2
const Vec2f v4 = Vec2f(-cosHalfWidth + sinHa .0));
lfHeight, -sinHalfWidth - cosHalfHeight); painter.drawLine2d(a.x(), a.y(), b.x(), b.y(
vertices->addVertex(VertexP2(offset + v1)); ));
vertices->addVertex(VertexP2(offset + v2)); // left line
vertices->addVertex(VertexP2(offset + v3)); a = transform.map(QPoint(-width/2.0, -height
vertices->addVertex(VertexP2(offset + v4)); /2.0));
vertices->addVertex(VertexP2(offset + v1)); b = transform.map(QPoint(-width/2.0, height/
vertices->lock(); 2.0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y(
renderer->drawVertexBuffer(vertices); ));
// right line
a = 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(
));
} }
} }
} }
delete vertices;
} }
void Oculars::paintCrosshairs(StelRenderer* renderer) void Oculars::paintCrosshairs()
{ {
const StelProjectorP projector = StelApp::getInstance().getCore()->g etProjection(StelCore::FrameEquinoxEqu);
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
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()+projector->getViewportH projector->getViewportPosY()+proj
eight()/2); ector->getViewportHeight()/2);
double length = 0.5 * params.viewportFovDiameter; GLdouble 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 V() > 0.0) { if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO V() > 0.0) {
length = oculars[selectedOcularIndex]->appearentFOV() * leng th / maxEyepieceAngle; length = oculars[selectedOcularIndex]->appearentFOV() * leng th / maxEyepieceAngle;
} }
length *= params.devicePixelsPerPixel;
// Draw the lines // Draw the lines
renderer->setGlobalColor(0.77f, 0.14f, 0.16f); StelPainter painter(projector);
StelVertexBuffer<VertexP2>* vertices = painter.setColor(0.77, 0.14, 0.16, 1);
renderer->createVertexBuffer<VertexP2>(PrimitiveType_Lines); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0]
const VertexP2 center(centerScreen[0], centerScreen[1]); , centerScreen[1] + length);
vertices->addVertex(center); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0]
vertices->addVertex(VertexP2(centerScreen[0], centerScreen[1] + leng , centerScreen[1] - length);
th)); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0]
vertices->addVertex(center); + length, centerScreen[1]);
vertices->addVertex(VertexP2(centerScreen[0], centerScreen[1] - leng painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0]
th)); - length, centerScreen[1]);
vertices->addVertex(center);
vertices->addVertex(VertexP2(centerScreen[0] + length, centerScreen[
1]));
vertices->addVertex(center);
vertices->addVertex(VertexP2(centerScreen[0] - length, centerScreen[
1]));
vertices->lock();
renderer->drawVertexBuffer(vertices);
delete vertices;
} }
void Oculars::paintTelrad(StelRenderer* renderer) 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);
// prevent unused warnings -MNG // StelPainter drawing
// StelCore *core = StelApp::getInstance().getCore(); StelPainter painter(projector);
// StelProjector::StelProjectorParams params = core->getCurr painter.setColor(0.77, 0.14, 0.16, 1.0);
entStelProjectorParams(); Vec2i centerScreen(projector->getViewportPosX() + projector-
>getViewportWidth() / 2,
renderer->setGlobalColor(0.77f, 0.14f, 0.16f); projector->
Vec2i centerScreen(projector->getViewportPosX()+projector->g getViewportPosY() + projector->getViewportHeight() / 2);
etViewportWidth()/2, float pixelsPerRad = projector->getPixelPerRadAtCenter();
projector->getViewportPosY()+projector->g painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p
etViewportHeight()/2); ixelsPerRad * (M_PI/180) * (0.5));
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p
// Generate and draw the circles. ixelsPerRad * (M_PI/180) * (2.0));
StelVertexBuffer<VertexP2>* circle = painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p
renderer->createVertexBuffer<VertexP2>(PrimitiveType ixelsPerRad * (M_PI/180) * (4.0));
_LineStrip);
const float baseRadius = 0.5f * projector->getPixelPerRadAtC
enter() * (M_PI / 180.0f);
StelGeometryBuilder().buildCircle(circle, centerScreen[0], c
enterScreen[1], baseRadius * 0.5f);
renderer->drawVertexBuffer(circle);
circle->unlock();
circle->clear();
StelGeometryBuilder().buildCircle(circle, centerScreen[0], c
enterScreen[1], baseRadius * 2.0f);
renderer->drawVertexBuffer(circle);
circle->unlock();
circle->clear();
StelGeometryBuilder().buildCircle(circle, centerScreen[0], c
enterScreen[1], baseRadius * 4.0f);
renderer->drawVertexBuffer(circle);
delete circle;
} }
} }
void Oculars::paintOcularMask(StelRenderer* renderer) void Oculars::paintOcularMask(const StelCore *core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz)
;
StelPainter painter(prj);
StelProjector::StelProjectorParams params = core->getCurrentStelProj
ectorParams();
// Draw the ocular outline, as GLUT is not working
painter.setColor(0.0, 0.5, 0.25, 1.0);
double inner = 0.5 * params.viewportFovDiameter * params.devicePixel
sPerPixel;
// See if we need to scale the mask
if (useMaxEyepieceAngle
&& oculars[selectedOcularIndex]->appearentFOV() > 0.0
&& !oculars[selectedOcularIndex]->isBinoculars()) {
inner = oculars[selectedOcularIndex]->appearentFOV() * inner
/ maxEyepieceAngle;
}
painter.drawCircle(params.viewportCenter[0] * params.devicePixelsPer
Pixel,
params.viewportCent
er[1]* params.devicePixelsPerPixel,
inner);
// Paint the reticale, if needed
if (!reticleTexture.isNull()){
glEnable(GL_BLEND);
painter.enableTexture2d(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
painter.setColor(0.77, 0.14, 0.16, 1.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal
transparency mode
reticleTexture->bind();
int textureHeight;
int textureWidth;
reticleTexture->getDimensions(textureWidth, textureHeight);
painter.drawSprite2dMode(params.viewportXywh[2] / 2 * params
.devicePixelsPerPixel,
params.viewportXywh[3] / 2 * params.devicePixelsPerPixel,
inner,
reticleRotation);
}
// FIXME: Enable usage QML shaders
// XXX: for some reason I cannot get to make the glu functions work
when
// compiling with Qt5!
// XXX: GLU can't work with OpenGL ES --AW
/*
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
renderer->setBlendMode(BlendMode_None); glDisable(GL_BLEND);
renderer->setGlobalColor(0.0f, 0.0f, 0.0f); glColor3f(0.f,0.f,0.f);
glPushMatrix();
glTranslated(params.viewportCenter[0], params.viewportCenter[1], 0.0
);
GLUquadricObj *quadric = gluNewQuadric();
GLdouble inner = 0.5 * params.viewportFovDiameter;
float inner = 0.5f * params.viewportFovDiameter;
// See if we need to scale the mask // See if we need to scale the mask
if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO V() > 0.0 && !oculars[selectedOcularIndex]->isBinoculars()) { if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO V() > 0.0 && !oculars[selectedOcularIndex]->isBinoculars()) {
inner = oculars[selectedOcularIndex]->appearentFOV() * inner / maxEyepieceAngle; inner = oculars[selectedOcularIndex]->appearentFOV() * inner / maxEyepieceAngle;
} }
const float outer = params.viewportXywh[2] + params.viewportXywh[3];
const Vec2f offset(params.viewportCenter[0], params.viewportCenter[1
]);
StelGeometryRing* disc = GLdouble outer = params.viewportXywh[2] + params.viewportXywh[3];
StelGeometryBuilder().buildRing2D(RingParams(inner, outer).r // Draw the mask
esolution(128, 1), offset); gluDisk(quadric, inner, outer, 256, 1);
disc->draw(renderer);
// the gray circle // the gray circle
renderer->setGlobalColor(0.15f, 0.15f, 0.15f); glColor3f(0.15f,0.15f,0.15f);
disc->setInnerOuterRadius(inner - 1.0f, inner); gluDisk(quadric, inner - 1.0, inner, 256, 1);
disc->draw(renderer); gluDeleteQuadric(quadric);
delete disc; glPopMatrix();
*/
} }
void Oculars::paintText(const StelCore* core, StelRenderer* renderer) void Oculars::paintText(const StelCore* core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ; const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ;
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 = oculars[selectedOcularIndex]; Ocular *ocular = oculars[selectedOcularIndex];
Telescope *telescope = telescopes[selectedTelescopeIndex]; Telescope *telescope = telescopes[selectedTelescopeIndex];
Lens *lens = selectedLensIndex >=0 ? lense[selectedLensIndex] : NUL L; Lens *lens = selectedLensIndex >=0 ? lense[selectedLensIndex] : NUL L;
// set up drawing // set up the color and the GL state
if (StelApp::getInstance().getVisionModeNight()) painter.setColor(0.8, 0.48, 0.0, 1);
renderer->setGlobalColor(0.8f, 0.0f, 0.0f); glDisable(GL_TEXTURE_2D);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
renderer->setGlobalColor(0.8f, 0.48f, 0.0f); glEnable(GL_BLEND);
renderer->setBlendMode(BlendMode_Alpha);
// Get the X & Y positions, and the line height // Get the X & Y positions, and the line height
renderer->setFont(font); painter.setFont(font);
QString widthString = "MMMMMMMMMMMMMMMMMMM"; QString widthString = "MMMMMMMMMMMMMMMMMMM";
const float insetFromRHS = QFontMetrics(font).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];
xPosition -= insetFromRHS; xPosition -= insetFromRHS;
int yPosition = projectorParams.viewportXywh[3]; int yPosition = projectorParams.viewportXywh[3];
yPosition -= 40; yPosition -= 40;
const int lineHeight = QFontMetrics(font).height(); const int lineHeight = painter.getFontMetrics().height();
// The Ocular // The Ocular
if (flagShowOculars) { if (flagShowOculars) {
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(selectedOcularIndex); .arg(selectedOcularIndex);
} }
else else
{ {
ocularNumberLabel = QString(q_("Ocular #%1: %2")) ocularNumberLabel = QString(q_("Ocular #%1: %2"))
.arg(selectedOcularIndex) .arg(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);
} }
renderer->drawText(TextParams(xPosition, yPosition, ocularNu mberLabel)); 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);
renderer->drawText(TextParams(xPosition, yPosition, eFocalLengthLabel)); 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);
renderer->drawText(TextParams(xPosition, yPosition, painter.drawText(xPosition, yPosition, ocularFOVLabe
ocularFOVLabel)); 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())
{ {
lensNumberLabel = QString(q_("Lens # %1")).arg(selectedLensIndex); lensNumberLabel = QString(q_("Lens # %1")).arg(selectedLensIndex);
} }
else else
{ {
lensNumberLabel = QString (q_("Lens #%1: %2")).arg(selectedLensIndex).arg(lensName); lensNumberLabel = QString (q_("Lens #%1: %2")).arg(selectedLensIndex).arg(lensName);
} }
} }
else else
{ {
lensNumberLabel = QString (q_("Lens: none")) ; lensNumberLabel = QString (q_("Lens: none")) ;
} }
renderer->drawText(TextParams(xPosition, yPosition, lensNumberLabel)); painter.drawText(xPosition, yPosition, lensNumberLab el);
yPosition-=lineHeight; yPosition-=lineHeight;
// The telescope // The telescope
QString telescopeNumberLabel; QString telescopeNumberLabel;
QString telescopeName = telescope->name(); QString telescopeName = telescope->name();
if (telescopeName.isEmpty()) if (telescopeName.isEmpty())
{ {
telescopeNumberLabel = QString(q_("Telescope #%1")) telescopeNumberLabel = QString(q_("Telescope #%1"))
.arg(selectedTelescopeIndex) ; .arg(selectedTelescopeIndex) ;
} }
else else
{ {
telescopeNumberLabel = QString(q_("Telescope #%1: %2")) telescopeNumberLabel = QString(q_("Telescope #%1: %2"))
.arg(selectedTelescopeIndex) .arg(selectedTelescopeIndex)
.arg(telescopeName); .arg(telescopeName);
} }
renderer->drawText(TextParams(xPosition, yPosition, telescopeNumberLabel)); painter.drawText(xPosition, yPosition, telescopeNumb erLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
// General info // General info
double magnification = ((int)(ocular->magnification( telescope, lens) * 10.0)) / 10.0; double magnification = ((int)(ocular->magnification( telescope, lens) * 10.0)) / 10.0;
QString magString = QString::number(magnification); QString magString = QString::number(magnification);
magString.append(QChar(0x00D7));//Multiplication sig n magString.append(QChar(0x00D7));//Multiplication sig n
QString magnificationLabel = QString(q_("Magnificati on: %1")) QString magnificationLabel = QString(q_("Magnificati on: %1"))
.arg(magString); .arg(magString);
renderer->drawText(TextParams(xPosition, yPosition, magnificationLabel)); painter.drawText(xPosition, yPosition, magnification Label);
yPosition-=lineHeight; yPosition-=lineHeight;
double fov = ((int)(ocular->actualFOV(telescope, len s) * 10000.00)) / 10000.0; double fov = ((int)(ocular->actualFOV(telescope, len s) * 10000.00)) / 10000.0;
QString fovString = QString::number(fov); QString fovString = QString::number(fov);
fovString.append(QChar(0x00B0));//Degree sign fovString.append(QChar(0x00B0));//Degree sign
QString fovLabel = QString(q_("FOV: %1")).arg(fovStr ing); QString fovLabel = QString(q_("FOV: %1")).arg(fovStr ing);
renderer->drawText(TextParams(xPosition, yPosition, fovLabel)); painter.drawText(xPosition, yPosition, fovLabel);
} }
} }
// The CCD // The CCD
if (flagShowCCD) { if (flagShowCCD) {
QString ccdSensorLabel, ccdInfoLabel; QString ccdSensorLabel, ccdInfoLabel;
double fovX = ((int)(ccd->getActualFOVx(telescope, lens) * 1 000.0)) / 1000.0; double fovX = ((int)(ccd->getActualFOVx(telescope, lens) * 1 000.0)) / 1000.0;
double fovY = ((int)(ccd->getActualFOVy(telescope, lens) * 1 000.0)) / 1000.0; double fovY = ((int)(ccd->getActualFOVy(telescope, lens) * 1 000.0)) / 1000.0;
ccdInfoLabel = QString(q_("Dimensions: %1")).arg(getDimensio nsString(fovX, fovY)); ccdInfoLabel = QString(q_("Dimensions: %1")).arg(getDimensio nsString(fovX, fovY));
skipping to change at line 1646 skipping to change at line 1676
if (name.isEmpty()) if (name.isEmpty())
{ {
ccdSensorLabel = QString(q_("Sensor #%1")).arg(selec tedCCDIndex); ccdSensorLabel = QString(q_("Sensor #%1")).arg(selec tedCCDIndex);
} }
else else
{ {
ccdSensorLabel = QString(q_("Sensor #%1: %2")) ccdSensorLabel = QString(q_("Sensor #%1: %2"))
.arg(selectedCCDIndex) .arg(selectedCCDIndex)
.arg(name); .arg(name);
} }
renderer->drawText(TextParams(xPosition, yPosition, ccdSenso rLabel)); painter.drawText(xPosition, yPosition, ccdSensorLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
renderer->drawText(TextParams(xPosition, yPosition, ccdInfoL abel)); painter.drawText(xPosition, yPosition, ccdInfoLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
// The telescope // The telescope
QString telescopeNumberLabel; QString telescopeNumberLabel;
QString telescopeName = telescope->name(); QString telescopeName = telescope->name();
if (telescopeName.isEmpty()) if (telescopeName.isEmpty())
{ {
telescopeNumberLabel = QString(q_("Telescope #%1")) telescopeNumberLabel = QString(q_("Telescope #%1"))
.arg(selectedTelescopeIndex); .arg(selectedTelescopeIndex);
} }
else else
{ {
telescopeNumberLabel = QString(q_("Telescope #%1: %2 ")) telescopeNumberLabel = QString(q_("Telescope #%1: %2 "))
.arg(selectedTelescopeIndex) .arg(selectedTelescopeIndex)
.arg(telescopeName); .arg(telescopeName);
} }
renderer->drawText(TextParams(xPosition, yPosition, telescop eNumberLabel)); painter.drawText(xPosition, yPosition, telescopeNumberLabel) ;
} }
} }
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())
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.
skipping to change at line 1755 skipping to change at line 1787
skyManager->setCustomNebulaMagnitudeLimit(magLimitDSOs); skyManager->setCustomNebulaMagnitudeLimit(magLimitDSOs);
movementManager->setFlagTracking(false); movementManager->setFlagTracking(false);
movementManager->setFlagEnableZoomKeys(true); movementManager->setFlagEnableZoomKeys(true);
movementManager->setFlagEnableMouseNavigation(true); movementManager->setFlagEnableMouseNavigation(true);
// Set the screen display // Set the screen display
// core->setMaskType(StelProjector::MaskNone); // core->setMaskType(StelProjector::MaskNone);
core->setFlipHorz(false); core->setFlipHorz(false);
core->setFlipVert(false); core->setFlipVert(false);
movementManager->zoomTo(movementManager->getInitFov()); if (getFlagInitFovUsage())
movementManager->zoomTo(movementManager->getInitFov());
else
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();
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( );
flagEclipticJ2000Grid = gridManager->getFlagEcliptic J2000Grid(); flagEclipticJ2000Grid = gridManager->getFlagEcliptic J2000Grid();
flagMeridianLine = gridManager->getFlagMeridianLine( ); flagMeridianLine = gridManager->getFlagMeridianLine( );
flagHorizonLine = gridManager->getFlagHorizonLine(); flagHorizonLine = gridManager->getFlagHorizonLine();
flagGalacticPlaneLine = gridManager->getFlagGalactic PlaneLine(); flagGalacticPlaneLine = gridManager->getFlagGalactic PlaneLine();
StelSkyDrawer *skyManager = StelApp::getInstance().g etCore()->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();
flagLimitDSOs = skyManager->getFlagNebulaMagnitudeLi mit(); flagLimitDSOs = skyManager->getFlagNebulaMagnitudeLi mit();
magLimitStars = skyManager->getCustomStarMagnitudeLi mit(); magLimitStars = skyManager->getCustomStarMagnitudeLi mit();
magLimitDSOs = skyManager->getCustomNebulaMagnitudeL imit(); magLimitDSOs = skyManager->getCustomNebulaMagnitudeL imit();
StelMovementMgr *movementManager = core->getMovement
Mgr();
initialFOV = movementManager->getCurrentFov();
} }
// set new state // set new state
zoomOcular(); zoomOcular();
} else { } else {
//reset to original state //reset to original state
unzoomOcular(); unzoomOcular();
} }
} }
skipping to change at line 1829 skipping to change at line 1869
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), 0.0, 1);
} }
// Set the screen display // Set the screen display
// core->setMaskType(StelProjector::MaskDisk); 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());
} }
// 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
// TODO: need improvements?
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);
} }
double 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-> isBinoculars()) { if (useMaxEyepieceAngle && ocular->appearentFOV() > 0.0 && !ocular-> 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)
skipping to change at line 1975 skipping to change at line 2013
flagLimitMagnitude = b; flagLimitMagnitude = b;
settings->setValue("limit_stellar_magnitude", b); settings->setValue("limit_stellar_magnitude", b);
settings->sync(); settings->sync();
} }
bool Oculars::getFlagLimitMagnitude() const bool Oculars::getFlagLimitMagnitude() const
{ {
return flagLimitMagnitude; return flagLimitMagnitude;
} }
void Oculars::setFlagInitFovUsage(const bool b)
{
flagInitFOVUsage = b;
settings->setValue("use_initial_fov", b);
settings->sync();
}
bool Oculars::getFlagInitFovUsage() const
{
return flagInitFOVUsage;
}
QString Oculars::getDimensionsString(double fovX, double fovY) const QString Oculars::getDimensionsString(double fovX, double fovY) const
{ {
QString stringFovX, stringFovY; QString stringFovX, stringFovY;
if (getFlagDecimalDegrees()) if (getFlagDecimalDegrees())
{ {
if (fovX >= 1.0) if (fovX >= 1.0)
{ {
int degrees = (int)fovX; int degrees = (int)fovX;
int minutes = (int)((fovX - degrees) * 60); int minutes = (int)((fovX - degrees) * 60);
stringFovX = QString::number(degrees) + QChar(0x00B0 ) + QString::number(minutes) + QChar(0x2032); stringFovX = QString::number(degrees) + QChar(0x00B0 ) + QString::number(minutes) + QChar(0x2032);
 End of changes. 153 change blocks. 
401 lines changed or deleted 446 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/