Oculars.cpp   Oculars.cpp 
skipping to change at line 32 skipping to change at line 32
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelPainter.hpp" #include "StelShortcutMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelMainWindow.hpp" #include "StelMainWindow.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "SkyGui.hpp" #include "SkyGui.hpp"
#include "renderer/GenericVertexTypes.hpp"
#include "renderer/StelGeometryBuilder.hpp"
#include "renderer/StelRenderer.hpp"
#include <QAction> #include <QAction>
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
#include <QMenu> #include <QMenu>
#include <QMouseEvent> #include <QMouseEvent>
#include <QtNetwork> #include <QtNetwork>
#include <QPixmap> #include <QPixmap>
#include <QSignalMapper> #include <QSignalMapper>
#include <cmath> #include <cmath>
#if defined(__APPLE__) && defined(__MACH__) #ifdef Q_OS_MAC
#include <OpenGL/glu.h> /* Header File For The GLU Library */
#else
#include <GL/glu.h> /* Header File For The GLU Library */
#endif
#ifdef Q_WS_MAC
extern void qt_set_sequence_auto_mnemonic(bool b); extern void qt_set_sequence_auto_mnemonic(bool b);
#endif #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
skipping to change at line 137 skipping to change at line 134
telescopesSignalMapper = new QSignalMapper(this); telescopesSignalMapper = new QSignalMapper(this);
selectedCCDIndex = -1; selectedCCDIndex = -1;
selectedOcularIndex = -1; selectedOcularIndex = -1;
selectedTelescopeIndex = -1; selectedTelescopeIndex = -1;
usageMessageLabelID = -1; usageMessageLabelID = -1;
setObjectName("Oculars"); setObjectName("Oculars");
#ifdef Q_WS_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;
ocularDialog = NULL; ocularDialog = NULL;
if (guiPanel) if (guiPanel)
delete guiPanel; delete guiPanel;
skipping to change at line 229 skipping to change at line 226
settings->setValue(prefix + "vFlip", telescope->isVFlipped() ); settings->setValue(prefix + "vFlip", telescope->isVFlipped() );
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->sync(); settings->sync();
} }
//! 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, StelRenderer* renderer)
{ {
if (flagShowTelrad) { if (flagShowTelrad) {
paintTelrad(); paintTelrad(renderer);
} 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 "
<< selectedCCDIndex << " i << selected
s greater than the sensor count of " CCDIndex << " is greater than the sensor count of "
<< ccds.count() << ". 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 "
<< selectedOcularIndex << << selected
" is greater than the ocular count of " OcularIndex << " is greater than the ocular count of "
<< oculars.count() << ". Module disabled!"; << oculars.
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 "
<< selectedTelescopeIndex << selected
<< " is greater than the telescope count of " TelescopeIndex << " is greater than the telescope count of "
<< telescopes.count() << ". Module disabled!"; << telescop
es.count() << ". Module disabled!";
ready = false; ready = false;
} }
if (ready) { if (ready) {
if (selectedOcularIndex > -1) { if (selectedOcularIndex > -1) {
paintOcularMask(); paintOcularMask(renderer);
if (flagShowCrosshairs) { if (flagShowCrosshairs) {
paintCrosshairs(); paintCrosshairs(renderer);
} }
} }
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); renderer->setBlendMode(BlendMode_Alpha);
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); paintText(core, renderer);
} }
} }
} else if (flagShowCCD) { } else if (flagShowCCD) {
paintCCDBounds(); paintCCDBounds(renderer);
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); renderer->setBlendMode(BlendMode_Alpha);
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); paintText(core, renderer);
} }
} }
} }
//! 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 529 skipping to change at line 522
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 ring&)), connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt ring&)),
this, SLOT(setStelStyle(const QString&))); this, SLOT(setStelStyle(const QStrin g&)));
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslateGui())); this, SLOT(retranslateGui()));
} }
void Oculars::setStelStyle(const QString&) void Oculars::setStelStyle(const QString&)
{ {
if(ocularDialog) { if(ocularDialog) {
ocularDialog->updateStyle(); ocularDialog->updateStyle();
} }
} }
/* ********************************************************************* */ /* ********************************************************************* */
skipping to change at line 763 skipping to change at line 756
// 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;
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(), "#99FF99"); 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(enableOcular(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 {
if (selectedOcularIndex != -1) { 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();
} }
skipping to change at line 887 skipping to change at line 885
{ {
QMenu* submenu = addTelescopeSubmenu(popup); QMenu* submenu = addTelescopeSubmenu(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, SLOT(setChecked(bool))); actionShowCrosshairs, SLOT(s 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(setVisible(bool))); ocularDialog, SLOT(setVisibl 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)),
actionShowSensor, SLOT(setChecked(bool))); actionShowSensor, SL 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)),
actionShowTelrad, SLOT(setChecked(bool))); actionShowTelrad, SL 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 946 skipping to change at line 944
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), rotateAction = submenu->addAction(QString("&1: -90") + 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") + QChar(0x00B0), rotateAction = submenu->addAction(QString("&2: -45") + 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") + QChar(0x00B0), rotateAction = submenu->addAction(QString("&3: -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("&4: -5") + QChar(0x00B0), rotateAction = submenu->addAction(QString("&4: -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("&5: -1") + 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), 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), 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), 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") + QChar(0x00B0), rotateAction = submenu->addAction(QString("&9: +45") + 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") + QChar(0x00B0), rotateAction = submenu->addAction(QString("&0: +90") + 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 1089 skipping to change at line 1087
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:" qWarning() << "Oculars plugin: Unable to display a s 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
skipping to change at line 1187 skipping to change at line 1185
} }
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Private Methods #pragma mark Private Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
void Oculars::initializeActivationActions() void Oculars::initializeActivationActions()
{ {
// TRANSLATORS: Title of a group of key bindings in the Help window
QString group = N_("Plugin Key Bindings");
//Bogdan: Temporary, for consistency and to avoid confusing the tran
slators
//TODO: Fix this when the key bindings feature is implemented
//QString group = N_("Oculars Plugin");
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
er();
//This action needs to be connected to the enableOcular() slot after //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 necessary button is created to prevent the button from being c hecked
//the first time this action is checked. See: //the first time this action is checked. See:
//http://doc.qt.nokia.com/4.7/signalsandslots.html#signals //http://doc.qt.nokia.com/4.7/signalsandslots.html#signals
QString shortcutStr = settings->value("bindings/toggle_oculars", "Ct actionShowOcular = shMgr->getGuiAction("actionShow_Ocular");
rl+O").toString();
actionShowOcular = gui->addGuiActions("actionShow_Ocular",
N_("Ocular view"),
shortcutStr,
group,
true);
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); actionShowOcul
ar);
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)), connect(actionShowOcular, SIGNAL(toggled(bool)),
this, SLOT(enableOcular(bool))); this, SLOT(enableOcular(bool)));
shortcutStr = settings->value("bindings/popup_navigator", "Alt+O").t actionMenu = shMgr->getGuiAction("actionShow_Ocular_Menu");
oString();
actionMenu = gui->addGuiActions("actionShow_Ocular_Menu",
N_("Oculars popup menu"),
shortcutStr,
group,
true);
connect(actionMenu, SIGNAL(toggled(bool)), connect(actionMenu, SIGNAL(toggled(bool)),
this, SLOT(displayPopupMenu())); this, SLOT(displayPopupMenu()));
actionShowCrosshairs = gui->addGuiActions("actionShow_Ocular_Crossha actionShowCrosshairs = shMgr->getGuiAction("actionShow_Ocular_Crossh
irs", airs");
N_("Crosshairs"),
QString(),
group,
true);
connect(actionShowCrosshairs, SIGNAL(toggled(bool)), connect(actionShowCrosshairs, SIGNAL(toggled(bool)),
this, SLOT(toggleCrosshairs(bool))); this, SLOT(toggleCrosshairs(bool)));
actionShowSensor = gui->addGuiActions("actionShow_Sensor", actionShowSensor = shMgr->getGuiAction("actionShow_Sensor");
N_("Image sensor frame"),
QString(),
group,
true);
connect(actionShowSensor, SIGNAL(toggled(bool)), connect(actionShowSensor, SIGNAL(toggled(bool)),
this, SLOT(toggleCCD(bool))); this, SLOT(toggleCCD(bool)));
actionShowTelrad = gui->addGuiActions("actionShow_Telrad", actionShowTelrad = shMgr->getGuiAction("actionShow_Telrad");
N_("Telrad sight"),
QString(),
group,
true);
connect(actionShowTelrad, SIGNAL(toggled(bool)), connect(actionShowTelrad, SIGNAL(toggled(bool)),
this, SLOT(toggleTelrad(bool))); this, SLOT(toggleTelrad(bool)));
actionConfiguration = gui->addGuiActions("actionOpen_Oculars_Configu actionConfiguration = shMgr->getGuiAction("actionOpen_Oculars_Config
ration", uration");
N_("Oculars plugin configur
ation"),
QString(),
group,
true);
connect(actionConfiguration, SIGNAL(toggled(bool)), connect(actionConfiguration, SIGNAL(toggled(bool)),
ocularDialog, SLOT(setVisible(bool))); ocularDialog, SLOT(setVisible(bool)) );
connect(ocularDialog, SIGNAL(visibleChanged(bool)), connect(ocularDialog, SIGNAL(visibleChanged(bool)),
actionConfiguration, SLOT(setChecked(bool))); actionConfiguration, SLOT(setChecked (bool)));
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(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 1294 skipping to change at line 1263
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(StelRenderer* renderer)
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
glDisable(GL_BLEND); renderer->setBlendMode(BlendMode_None);
glColor3f(0.f,0.f,0.f);
glPushMatrix(); StelVertexBuffer<VertexP2>* vertices =
glTranslated(params.viewportCenter[0], params.viewportCenter[1], 0.0 renderer->createVertexBuffer<VertexP2>(PrimitiveType_LineStr
); ip);
glRotated(ccdRotationAngle, 0.0, 0.0, 1.0);
GLdouble 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) {
glColor4f(0.77, 0.14, 0.16, 0.5); renderer->setGlobalColor(0.77f, 0.14f, 0.16f, 0.5f);
Telescope *telescope = telescopes[selectedTelescopeI ndex]; Telescope *telescope = telescopes[selectedTelescopeI ndex];
double ccdXRatio = ccd->getActualFOVx(telescope) / s const double ccdXRatio = ccd->getActualFOVx(telescop
creenFOV; e) / screenFOV;
double ccdYRatio = ccd->getActualFOVy(telescope) / s const double ccdYRatio = ccd->getActualFOVy(telescop
creenFOV; e) / 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;
} }
float width = params.viewportXywh[aspectIndex] * ccd const float halfWidth = 0.5f * (params.viewportXywh
YRatio; [aspectIndex] * ccdYRatio);
float height = params.viewportXywh[aspectIndex] * cc const float halfHeight = 0.5f * (params.viewportXywh
dXRatio; [aspectIndex] * ccdXRatio);
if (halfWidth > 0.0 && halfHeight > 0.0)
{
const float s = sin(-ccdRotationAngle * M_PI
/ 180.0f);
const float c = cos(-ccdRotationAngle * M_PI
/ 180.0f);
const float cosHalfWidth = c * halfWidth;
const float sinHalfWidth = s * halfWidth;
const float cosHalfHeight = c * halfHeight;
const float sinHalfHeight = s * halfHeight;
const Vec2f v1 = Vec2f(-cosHalfWidth - sinHa
lfHeight, -sinHalfWidth + cosHalfHeight);
const Vec2f v2 = Vec2f(cosHalfWidth - sinHa
lfHeight, sinHalfWidth + cosHalfHeight);
const Vec2f v3 = Vec2f(cosHalfWidth + sinHa
lfHeight, sinHalfWidth - cosHalfHeight);
const Vec2f v4 = Vec2f(-cosHalfWidth + sinHa
lfHeight, -sinHalfWidth - cosHalfHeight);
vertices->addVertex(VertexP2(offset + v1));
vertices->addVertex(VertexP2(offset + v2));
vertices->addVertex(VertexP2(offset + v3));
vertices->addVertex(VertexP2(offset + v4));
vertices->addVertex(VertexP2(offset + v1));
vertices->lock();
if (width > 0.0 && height > 0.0) { renderer->drawVertexBuffer(vertices);
glBegin(GL_LINE_LOOP);
glVertex2f(-width / 2.0, height / 2.0);
glVertex2f(width / 2.0, height / 2.0);
glVertex2f(width / 2.0, -height / 2.0);
glVertex2f(-width / 2.0, -height / 2.0);
glEnd();
} }
} }
} }
delete vertices;
glPopMatrix();
} }
void Oculars::paintCrosshairs() void Oculars::paintCrosshairs(StelRenderer* renderer)
{ {
const StelProjectorP projector = StelApp::getInstance().getCore()->g etProjection(StelCore::FrameEquinoxEqu); const StelProjectorP projector = StelApp::getInstance().getCore()->g etProjection(StelCore::FrameEquinoxEqu);
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
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 projector->getViewportPosY()+projector->getViewportH
ector->getViewportHeight()/2); eight()/2);
GLdouble length = 0.5 * params.viewportFovDiameter; double 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;
} }
// Draw the lines // Draw the lines
StelPainter painter(projector); renderer->setGlobalColor(0.77f, 0.14f, 0.16f);
painter.setColor(0.77, 0.14, 0.16, 1); StelVertexBuffer<VertexP2>* vertices =
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] renderer->createVertexBuffer<VertexP2>(PrimitiveType_Lines);
, centerScreen[1] + length); const VertexP2 center(centerScreen[0], centerScreen[1]);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] vertices->addVertex(center);
, centerScreen[1] - length); vertices->addVertex(VertexP2(centerScreen[0], centerScreen[1] + leng
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] th));
+ length, centerScreen[1]); vertices->addVertex(center);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] vertices->addVertex(VertexP2(centerScreen[0], centerScreen[1] - leng
- length, centerScreen[1]); th));
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() void Oculars::paintTelrad(StelRenderer* renderer)
{ {
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 // prevent unused warnings -MNG
// StelCore *core = StelApp::getInstance().getCore(); // StelCore *core = StelApp::getInstance().getCore();
// StelProjector::StelProjectorParams params = core->getCurr entStelProjectorParams(); // StelProjector::StelProjectorParams params = core->getCurr entStelProjectorParams();
// StelPainter drawing renderer->setGlobalColor(0.77f, 0.14f, 0.16f);
StelPainter painter(projector);
painter.setColor(0.77, 0.14, 0.16, 1.0);
Vec2i centerScreen(projector->getViewportPosX()+projector->g etViewportWidth()/2, Vec2i centerScreen(projector->getViewportPosX()+projector->g etViewportWidth()/2,
projector->getViewportPos projector->getViewportPosY()+projector->g
Y()+projector->getViewportHeight()/2); etViewportHeight()/2);
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p
rojector->getPixelPerRadAtCenter() * (M_PI/180) * (0.5)); // Generate and draw the circles.
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p StelVertexBuffer<VertexP2>* circle =
rojector->getPixelPerRadAtCenter() * (M_PI/180) * (2.0)); renderer->createVertexBuffer<VertexP2>(PrimitiveType
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p _LineStrip);
rojector->getPixelPerRadAtCenter() * (M_PI/180) * (4.0)); 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() void Oculars::paintOcularMask(StelRenderer* renderer)
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
glDisable(GL_BLEND); renderer->setBlendMode(BlendMode_None);
glColor3f(0.f,0.f,0.f); renderer->setGlobalColor(0.0f, 0.0f, 0.0f);
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
]);
GLdouble outer = params.viewportXywh[2] + params.viewportXywh[3]; StelGeometryRing* disc =
// Draw the mask StelGeometryBuilder().buildRing2D(RingParams(inner, outer).r
gluDisk(quadric, inner, outer, 256, 1); esolution(128, 1), offset);
disc->draw(renderer);
// the gray circle // the gray circle
glColor3f(0.15f,0.15f,0.15f); renderer->setGlobalColor(0.15f, 0.15f, 0.15f);
gluDisk(quadric, inner - 1.0, inner, 256, 1); disc->setInnerOuterRadius(inner - 1.0f, inner);
gluDeleteQuadric(quadric); disc->draw(renderer);
glPopMatrix(); delete disc;
} }
void Oculars::paintText(const StelCore* core) void Oculars::paintText(const StelCore* core, StelRenderer* renderer)
{ {
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];
// set up the color and the GL state // set up drawing
painter.setColor(0.8, 0.48, 0.0, 1); if (StelApp::getInstance().getVisionModeNight())
glDisable(GL_TEXTURE_2D); renderer->setGlobalColor(0.8f, 0.0f, 0.0f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else
glEnable(GL_BLEND); renderer->setGlobalColor(0.8f, 0.48f, 0.0f);
renderer->setBlendMode(BlendMode_Alpha);
// Get the X & Y positions, and the line height // Get the X & Y positions, and the line height
painter.setFont(font); renderer->setFont(font);
QString widthString = "MMMMMMMMMMMMMMMMMMM"; QString widthString = "MMMMMMMMMMMMMMMMMMM";
float insetFromRHS = painter.getFontMetrics().width(widthString); const float insetFromRHS = QFontMetrics(font).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 = painter.getFontMetrics().height(); const int lineHeight = QFontMetrics(font).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);
} }
painter.drawText(xPosition, yPosition, ocularNumberLabel); renderer->drawText(TextParams(xPosition, yPosition, ocularNu mberLabel));
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); renderer->drawText(TextParams(xPosition, yPosition, eFocalLengthLabel));
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 renderer->drawText(TextParams(xPosition, yPosition,
l); ocularFOVLabel));
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(selectedTelescop eIndex); .arg(selectedTelescopeIndex) ;
} }
else else
{ {
telescopeNumberLabel = QString(q_("Telescope #%1: %2")) telescopeNumberLabel = QString(q_("Telescope #%1: %2"))
.arg(selectedTelescop .arg(selectedTelescopeIndex)
eIndex) .arg(telescopeName);
.arg(telescopeName);
} }
painter.drawText(xPosition, yPosition, telescopeNumb erLabel); renderer->drawText(TextParams(xPosition, yPosition, telescopeNumberLabel));
yPosition-=lineHeight; yPosition-=lineHeight;
// General info // General info
double magnification = ((int)(ocular->magnification( telescope) * 10.0)) / 10.0; double magnification = ((int)(ocular->magnification( telescope) * 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);
painter.drawText(xPosition, yPosition, magnification Label); renderer->drawText(TextParams(xPosition, yPosition, magnificationLabel));
yPosition-=lineHeight; yPosition-=lineHeight;
double fov = ((int)(ocular->actualFOV(telescope) * 1 0000.00)) / 10000.0; double fov = ((int)(ocular->actualFOV(telescope) * 1 0000.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);
painter.drawText(xPosition, yPosition, fovLabel); renderer->drawText(TextParams(xPosition, yPosition, fovLabel));
} }
} }
// The CCD // The CCD
if (flagShowCCD) { if (flagShowCCD) {
QString ccdSensorLabel, ccdInfoLabel; QString ccdSensorLabel, ccdInfoLabel;
double fovX = ((int)(ccd->getActualFOVx(telescope) * 1000.0) ) / 1000.0; double fovX = ((int)(ccd->getActualFOVx(telescope) * 1000.0) ) / 1000.0;
double fovY = ((int)(ccd->getActualFOVy(telescope) * 1000.0) ) / 1000.0; double fovY = ((int)(ccd->getActualFOVy(telescope) * 1000.0) ) / 1000.0;
ccdInfoLabel = QString(q_("Dimensions: %1")).arg(getDimensio nsString(fovX, fovY)); ccdInfoLabel = QString(q_("Dimensions: %1")).arg(getDimensio nsString(fovX, fovY));
QString name = ccd->name(); QString name = ccd->name();
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);
} }
painter.drawText(xPosition, yPosition, ccdSensorLabel); renderer->drawText(TextParams(xPosition, yPosition, ccdSenso rLabel));
yPosition-=lineHeight; yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, ccdInfoLabel); renderer->drawText(TextParams(xPosition, yPosition, ccdInfoL abel));
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);
} }
painter.drawText(xPosition, yPosition, telescopeNumberLabel) ; renderer->drawText(TextParams(xPosition, yPosition, telescop eNumberLabel));
} }
} }
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 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 " << ocularIniPath; qDebug() << "Oculars::validateIniFile copied default _ocular.ini to " << 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: " << ocularIniPath << ". Checking version..."; qDebug() << "Oculars::validateIniFile ocular.ini exists at: " << 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 old to use; require d version is " << MIN_OCULARS_INI_VERSION << ". Copying over new one."; << " too ol d to use; required version is " << MIN_OCULARS_INI_VERSION << ". Copying ov er 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 " + ocularIniPath; qWarning() << "Oculars::validateIniFile cann ot move ocular.ini resource to ocular.ini.old at path " + ocularIniPath;
} else { } else {
qWarning() << "Oculars::validateIniFile ocul ar.ini resource renamed to ocular.ini.old at path " + ocularIniPath; qWarning() << "Oculars::validateIniFile ocul ar.ini resource renamed to ocular.ini.old at path " + ocularIniPath;
skipping to change at line 1669 skipping to change at line 1672
//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().getModuleMgr().getMod ule("GridLinesMgr"); (GridLinesMgr *)StelApp::getInstance().getModuleMgr( ).getModule("GridLinesMgr");
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);
gridManager->setFlagMeridianLine(false); gridManager->setFlagMeridianLine(false);
gridManager->setFlagHorizonLine(false); gridManager->setFlagHorizonLine(false);
 End of changes. 98 change blocks. 
214 lines changed or deleted 226 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/