Oculars.cpp   Oculars.cpp 
skipping to change at line 29 skipping to change at line 29
#include "Oculars.hpp" #include "Oculars.hpp"
#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 "StelPainter.hpp" #include "StelPainter.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 <QAction> #include <QAction>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
#include <QMouseEvent> #include <QMouseEvent>
#include <QtNetwork> #include <QtNetwork>
#include <QPixmap> #include <QPixmap>
#include <QSettings>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <cmath> #include <cmath>
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
#include <OpenGL/glu.h> /* Header File For The GLU Library */ #include <OpenGL/glu.h> /* Header File For The GLU Library */
#else #else
#include <GL/glu.h> /* Header File For The GLU Library */ #include <GL/glu.h> /* Header File For The GLU Library */
#endif #endif
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 = "Ocular"; info.displayedName = q_("Oculars");
info.authors = "Timothy Reaves"; info.authors = "Timothy Reaves";
info.contact = "treaves@silverfieldstech.com"; info.contact = "treaves@silverfieldstech.com";
info.description = "Shows the sky as if looking through a telescope eyepiece"; info.description = q_("Shows the sky as if looking through a telesco pe eyepiece");
return info; return info;
} }
Q_EXPORT_PLUGIN2(Oculars, OcularsStelPluginInterface) 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() : selectedOcularIndex(-1), flagShowOculars(false), usage Oculars::Oculars() : pxmapGlow(NULL), pxmapOnIcon(NULL), pxmapOffIcon(NULL)
MessageLabelID(-1), , toolbarButton(NULL)
pxmapGlow(NULL), pxmapOnIcon(NULL), pxmap
OffIcon(NULL), toolbarButton(NULL)
{ {
flagShowOculars = false; flagShowOculars = false;
flagShowCrosshairs = false; flagShowCrosshairs = false;
flagShowTelrad = false; flagShowTelrad = false;
ready = false;
useMaxEyepieceAngle = true;
visible = false;
font.setPixelSize(14); font.setPixelSize(14);
maxImageCircle = 0.0; maxEyepieceAngle = 0.0;
CCDs = QList<CCD *>();
ccds = QList<CCD *>();
oculars = QList<Ocular *>(); oculars = QList<Ocular *>();
ready = false;
selectedCCDIndex = 0;
selectedOcularIndex = 0;
selectedTelescopeIndex = 0;
setObjectName("Oculars");
telescopes = QList<Telescope *>(); telescopes = QList<Telescope *>();
useMaxImageCircle = true;
visible = false; selectedCCDIndex = -1;
ocularsTableModel = NULL; selectedOcularIndex = -1;
telescopesTableModel = NULL; selectedTelescopeIndex = -1;
ocularDialog = NULL;
noEntitiesLabelID = -1;
usageMessageLabelID = -1;
setObjectName("Oculars");
} }
Oculars::~Oculars() Oculars::~Oculars()
{ {
delete CCDsTableModel;
CCDsTableModel = NULL;
delete ocularsTableModel;
ocularsTableModel = NULL;
delete telescopesTableModel;
telescopesTableModel = NULL;
delete ocularDialog; delete ocularDialog;
ocularDialog = NULL; ocularDialog = NULL;
} }
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark StelModule Methods #pragma mark StelModule Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
skipping to change at line 144 skipping to change at line 140
if (show) if (show)
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
Q_ASSERT(gui); Q_ASSERT(gui);
gui->getGuiActions("actionShow_Ocular_Window")->setChecked(t rue); gui->getGuiActions("actionShow_Ocular_Window")->setChecked(t rue);
} }
return ready; return ready;
} }
void Oculars::deinit()
{
// update the ini file.
settings->remove("ccd");
settings->remove("ocular");
settings->remove("telescope");
int index = 0;
foreach(CCD* ccd, ccds) {
QString prefix = "ccd/" + QVariant(index).toString() + "/";
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 = 0;
foreach(Ocular* ocular, oculars) {
QString prefix = "ocular/" + QVariant(index).toString() + "/
";
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()
);
index++;
}
index = 0;
foreach(Telescope* telescope, telescopes){
QString prefix = "telescope/" + QVariant(index).toString() +
"/";
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++;
}
settings->setValue("ocular_count", oculars.count());
settings->setValue("telescope_count", telescopes.count());
settings->setValue("ccd_count", ccds.count());
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)
{ {
if (flagShowTelrad) { if (flagShowTelrad) {
drawTelrad(); drawTelrad();
} }
if (flagShowOculars){ if (flagShowOculars){
// Insure there is a selected ocular & telescope // Insure there is a selected ocular & telescope
if (selectedCCDIndex > CCDs.count()) { if (selectedCCDIndex > ccds.count()) {
qWarning() << "Oculars: the selected sensor index of " << selectedCCDIndex << " is greater than the sensor count of " qWarning() << "Oculars: the selected sensor index of " << selectedCCDIndex << " is greater than the sensor count of "
<< CCDs.count() << ". Module disabled!"; << ccds.count() << ". Module disabled!";
ready = false; ready = false;
} }
if (selectedOcularIndex > oculars.count()) { if (selectedOcularIndex > oculars.count()) {
qWarning() << "Oculars: the selected ocular index of " << selectedOcularIndex << " is greater than the ocular count of " qWarning() << "Oculars: the selected ocular index of " << selectedOcularIndex << " 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 " << selectedTelescopeIndex << " is greater than the telescope count of " qWarning() << "Oculars: the selected telescope index of " << selectedTelescopeIndex << " is greater than the telescope count of "
<< telescopes.count() << ". Module disabled!"; << telescopes.count() << ". Module disabled!";
skipping to change at line 199 skipping to change at line 238
order = StelApp::getInstance().getModuleMgr().getModule("Ste lMovementMgr")->getCallOrder(actionName) - 1.0; order = StelApp::getInstance().getModuleMgr().getModule("Ste lMovementMgr")->getCallOrder(actionName) - 1.0;
} }
else if (actionName==StelModule::ActionDraw) else if (actionName==StelModule::ActionDraw)
{ {
order = GETSTELMODULE(LabelMgr)->getCallOrder(actionName) + 100.0; order = GETSTELMODULE(LabelMgr)->getCallOrder(actionName) + 100.0;
} }
return order; return order;
} }
const StelStyle Oculars::getModuleStyleSheet(const StelStyle& style)
{
StelStyle pluginStyle(style);
if (style.confSectionName == "color") {
pluginStyle.qtStyleSheet.append(normalStyleSheet);
} else{
pluginStyle.qtStyleSheet.append(nightStyleSheet);
}
return pluginStyle;
}
void Oculars::handleMouseClicks(class QMouseEvent* event) void Oculars::handleMouseClicks(class QMouseEvent* event)
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
if (StelApp::getInstance().getStelObjectMgr().getWasSelected()){ if (StelApp::getInstance().getStelObjectMgr().getWasSelected()){
LabelMgr *labelManager = GETSTELMODULE(LabelMgr); LabelMgr *labelManager = GETSTELMODULE(LabelMgr);
if (flagShowOculars) if (flagShowOculars)
{ {
// center the selected object in the ocular, and tra ck. // center the selected object in the ocular, and tra ck.
skipping to change at line 232 skipping to change at line 282
else if(flagShowOculars) else if(flagShowOculars)
{ {
// The ocular is displayed, but no object is selected. So d on't track the stars. // The ocular is displayed, but no object is selected. So d on't track the stars.
movementManager->setFlagLockEquPos(false); movementManager->setFlagLockEquPos(false);
} }
event->setAccepted(false); event->setAccepted(false);
} }
void Oculars::init() void Oculars::init()
{ {
qDebug() << "Ocular plugin - press Command-o to toggle eyepiece view mode. Press ALT-o for configuration."; qDebug() << "Ocular plugin - press Command-O to toggle eyepiece view mode. Press ALT-o for configuration.";
// Load settings from ocular.ini // Load settings from ocular.ini
validateIniFile(); try {
if (initializeDB()) { validateAndLoadIniFile();
// assume all is well // assume all is well
ready = true; ready = true;
ocularDialog = new OcularDialog(CCDsTableModel, ocularsTable
Model, telescopesTableModel);
initializeActivationActions();
}
try {
StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr:
:Directory|StelFileMgr::Writable);
QString ocularIniPath = StelFileMgr::findFile("modules/Ocula
rs/", flags) + "ocular.ini";
QSettings settings(ocularIniPath, QSettings::IniFormat); useMaxEyepieceAngle = settings->value("use_max_exit_circle",
useMaxImageCircle = settings.value("use_max_exit_circle", 0. 0.0).toBool();
0).toBool(); int ocularCount = settings->value("ocular_count", 0).toInt()
;
int actualOcularCount = ocularCount;
for (int index = 0; index < ocularCount; index++) {
Ocular *newOcular = Ocular::ocularFromSettings(setti
ngs, index);
if (newOcular != NULL) {
oculars.append(newOcular);
} else {
actualOcularCount--;
}
}
if (actualOcularCount < 1) {
if (actualOcularCount < ocularCount) {
qWarning() << "The Oculars ini file appears
to be corrupt; delete it.";
} else {
qWarning() << "There are no oculars defined
for the Oculars plugin; plugin will be disabled.";
}
ready = false;
} else {
selectedOcularIndex = 0;
}
int ccdCount = settings->value("ccd_count", 0).toInt();
int actualCcdCount = ccdCount;
for (int index = 0; index < ccdCount; index++) {
CCD *newCCD = CCD::ccdFromSettings(settings, index);
if (newCCD != NULL) {
ccds.append(newCCD);
} else {
actualCcdCount--;
}
}
if (actualCcdCount < ccdCount) {
qWarning() << "The Oculars ini file appears to be co
rrupt; delete it.";
ready = false;
}
int telescopeCount = settings->value("telescope_count", 0).t
oInt();
int actualTelescopeCount = telescopeCount;
for (int index = 0; index < telescopeCount; index++) {
Telescope *newTelescope = Telescope::telescopeFromSe
ttings(settings, index);
if (newTelescope != NULL) {
telescopes.append(newTelescope);
}else {
actualTelescopeCount--;
}
}
if (actualTelescopeCount < 1) {
if (actualTelescopeCount < telescopeCount) {
qWarning() << "The Oculars ini file appears
to be corrupt; delete it.";
} else {
qWarning() << "There are no telescopes defin
ed for the Oculars plugin; plugin will be disabled.";
}
ready = false;
} else {
selectedTelescopeIndex = 0;
}
ocularDialog = new OcularDialog(&ccds, &oculars, &telescopes
);
initializeActivationActions();
determineMaxEyepieceAngle();
} 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;
} }
//Load the module's custom style sheets //Load the module's custom style sheets
QFile styleSheetFile; QFile styleSheetFile;
styleSheetFile.setFileName(":/ocular/normalStyle.css"); styleSheetFile.setFileName(":/ocular/normalStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{ {
normalStyleSheet = styleSheetFile.readAll(); normalStyleSheet = styleSheetFile.readAll();
} }
styleSheetFile.close(); styleSheetFile.close();
styleSheetFile.setFileName(":/ocular/nightStyle.css"); styleSheetFile.setFileName(":/ocular/nightStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{ {
nightStyleSheet = styleSheetFile.readAll(); nightStyleSheet = styleSheetFile.readAll();
} }
styleSheetFile.close(); styleSheetFile.close();
} }
void Oculars::deinit()
{
QSqlDatabase db = QSqlDatabase::database("oculars");
db.close();
QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection);
}
void Oculars::setStelStyle(const QString&) void Oculars::setStelStyle(const QString&)
{ {
ocularDialog->updateStyle(); if(ocularDialog) {
} ocularDialog->updateStyle();
const StelStyle Oculars::getModuleStyleSheet(const StelStyle& style)
{
StelStyle pluginStyle(style);
if (style.confSectionName == "color")
{
pluginStyle.qtStyleSheet.append(normalStyleSheet);
}
else
{
pluginStyle.qtStyleSheet.append(nightStyleSheet);
} }
return pluginStyle;
} }
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Private slots Methods #pragma mark Private slots Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
void Oculars::determineMaxImageCircle() void Oculars::determineMaxEyepieceAngle()
{ {
if (ready) { if (ready) {
QListIterator<Ocular *> ocularIterator(oculars); QListIterator<Ocular *> ocularIterator(oculars);
while (ocularIterator.hasNext()) { while (ocularIterator.hasNext()) {
Ocular *ocular = ocularIterator.next(); Ocular *ocular = ocularIterator.next();
QListIterator<Telescope *> telescopeIterator(telesco if (ocular->appearentFOV() > maxEyepieceAngle) {
pes); maxEyepieceAngle = ocular->appearentFOV();
while (telescopeIterator.hasNext()) {
Telescope *telescope = telescopeIterator.nex
t();
if (ocular->getExitCircle(telescope) > maxIm
ageCircle) {
maxImageCircle = ocular->getExitCirc
le(telescope);
}
} }
} }
} }
// insure it is not zero // insure it is not zero
if (maxImageCircle == 0.0) { if (maxEyepieceAngle == 0.0) {
maxImageCircle = 1.0; maxEyepieceAngle = 1.0;
} }
} }
void Oculars::instrumentChanged() void Oculars::instrumentChanged()
{ {
newInstrument = true; newInstrument = true;
zoom(true); zoom(true);
} }
void Oculars::loadCCDs()
{
CCDs.clear();
int rowCount = CCDsTableModel->rowCount();
for (int row = 0; row < rowCount; row++) {
CCDs.append(new CCD(CCDsTableModel->record(row)));
}
}
void Oculars::loadOculars()
{
oculars.clear();
int rowCount = ocularsTableModel->rowCount();
for (int row = 0; row < rowCount; row++) {
oculars.append(new Ocular(ocularsTableModel->record(row)));
}
}
void Oculars::loadTelescopes()
{
telescopes.clear();
int rowCount = telescopesTableModel->rowCount();
for (int row = 0; row < rowCount; row++) {
telescopes.append(new Telescope(telescopesTableModel->record
(row)));
}
}
void Oculars::setScaleImageCircle(bool state) void Oculars::setScaleImageCircle(bool state)
{ {
if (state) { if (state) {
determineMaxImageCircle(); determineMaxEyepieceAngle();
} }
useMaxImageCircle = state; useMaxEyepieceAngle = state;
} }
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Slots Methods #pragma mark Slots Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
void Oculars::enableOcular(bool b) void Oculars::enableOcular(bool enableOcularMode)
{ {
if (!ready) { if (enableOcularMode) {
qDebug() << "The Oculars module has been disabled."; // Check to insure that we have enough oculars & telescopes,
return; as they may have been edited in the config dialog
if (oculars.count() == 0) {
selectedOcularIndex = -1;
qDebug() << "No oculars found";
} else if (oculars.count() > 0 && selectedOcularIndex == -1)
{
selectedOcularIndex = 0;
}
if (telescopes.count() == 0) {
selectedTelescopeIndex = -1;
qDebug() << "No telescopes found";
} else if (telescopes.count() > 0 && selectedTelescopeIndex
== -1) {
selectedTelescopeIndex = 0;
}
} }
if (b) { if (!ready || selectedOcularIndex == -1 || selectedTelescopeIndex
// load data and determine if we're ready (if we have all re == -1) {
quired data) qDebug() << "The Oculars module has been disabled.";
loadDatabaseObjects();
}
if (!ready) {
// no, some data was missing. We already warned, done.
return; return;
} }
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
LabelMgr* labelManager = GETSTELMODULE(LabelMgr); LabelMgr* labelManager = GETSTELMODULE(LabelMgr);
// Toggle the plugin on & off. To toggle on, we want to ensure ther e is a selected object. // Toggle the plugin on & off. To toggle on, we want to ensure ther e is a selected object.
if (!flagShowOculars && !StelApp::getInstance().getStelObjectMgr().g etWasSelected()) { if (!flagShowOculars && !StelApp::getInstance().getStelObjectMgr().g etWasSelected()) {
if (usageMessageLabelID == -1) { if (usageMessageLabelID == -1) {
QFontMetrics metrics(font); QFontMetrics metrics(font);
QString labelText = "Please select an object before enabling Ocular."; QString labelText = "Please select an object before enabling Ocular.";
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());
usageMessageLabelID = labelManager->labelScreen(labe lText, xPosition, yPosition, true, font.pixelSize(), "#99FF99"); usageMessageLabelID = labelManager->labelScreen(labe lText, xPosition, yPosition, true, font.pixelSize(), "#99FF99");
} }
// 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
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
Q_ASSERT(gui); Q_ASSERT(gui);
disconnect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(t oggled(bool)), this, SLOT(enableOcular(bool)));
gui->getGuiActions("actionShow_Ocular")->setChecked(false); gui->getGuiActions("actionShow_Ocular")->setChecked(false);
connect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(togg led(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.
if (usageMessageLabelID > -1) { if (usageMessageLabelID > -1) {
labelManager->setLabelShow(usageMessageLabel ID, false); labelManager->setLabelShow(usageMessageLabel ID, false);
labelManager->deleteLabel(usageMessageLabelI D); labelManager->deleteLabel(usageMessageLabelI D);
usageMessageLabelID = -1; usageMessageLabelID = -1;
} }
flagShowOculars = b; flagShowOculars = enableOcularMode;
zoom(false); zoom(false);
} }
} }
if (flagShowOculars) { if (flagShowOculars) {
// Initialize those actions that should only be enabled when in ocular mode.
initializeActions(); initializeActions();
} }
} }
void Oculars::decrementCCDIndex() void Oculars::decrementCCDIndex()
{ {
selectedCCDIndex--; selectedCCDIndex--;
if (selectedCCDIndex == -1) { if (selectedCCDIndex == -2) {
selectedCCDIndex = CCDs.count() - 1; selectedCCDIndex = ccds.count() - 1;
} }
emit(selectedCCDChanged()); emit(selectedCCDChanged());
} }
void Oculars::decrementOcularIndex() void Oculars::decrementOcularIndex()
{ {
selectedOcularIndex--; selectedOcularIndex--;
if (selectedOcularIndex == -1) { if (selectedOcularIndex == -1) {
selectedOcularIndex = oculars.count() - 1; selectedOcularIndex = oculars.count() - 1;
} }
skipping to change at line 451 skipping to change at line 515
selectedTelescopeIndex--; selectedTelescopeIndex--;
if (selectedTelescopeIndex == -1) { if (selectedTelescopeIndex == -1) {
selectedTelescopeIndex = telescopes.count() - 1; selectedTelescopeIndex = telescopes.count() - 1;
} }
emit(selectedTelescopeChanged()); emit(selectedTelescopeChanged());
} }
void Oculars::incrementCCDIndex() void Oculars::incrementCCDIndex()
{ {
selectedCCDIndex++; selectedCCDIndex++;
if (selectedCCDIndex == CCDs.count()) { if (selectedCCDIndex == ccds.count()) {
selectedCCDIndex = 0; selectedCCDIndex = -1;
} }
emit(selectedCCDChanged()); emit(selectedCCDChanged());
} }
void Oculars::incrementOcularIndex() void Oculars::incrementOcularIndex()
{ {
selectedOcularIndex++; selectedOcularIndex++;
if (selectedOcularIndex == oculars.count()) { if (selectedOcularIndex == oculars.count()) {
selectedOcularIndex = 0; selectedOcularIndex = 0;
} }
skipping to change at line 501 skipping to change at line 565
void Oculars::drawCrosshairs() void Oculars::drawCrosshairs()
{ {
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 ector->getViewportHeight()/2); projector->getViewportPosY()+proj ector->getViewportHeight()/2);
GLdouble 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 (useMaxImageCircle && oculars[selectedOcularIndex]->getExitCircle if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO
(telescopes[selectedTelescopeIndex]) > 0.0) { V() > 0.0) {
length = oculars[selectedOcularIndex]->getExitCircle(telesco length = oculars[selectedOcularIndex]->appearentFOV() * leng
pes[selectedTelescopeIndex]) * length / maxImageCircle; th / maxEyepieceAngle;
} }
// Draw the lines // Draw the lines
StelPainter painter(projector); StelPainter painter(projector);
painter.setColor(0.77, 0.14, 0.16, 1); painter.setColor(0.77, 0.14, 0.16, 1);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] + length); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] + length);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] - length); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] , centerScreen[1] - length);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] + length, centerScreen[1]); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] + length, centerScreen[1]);
painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] - length, centerScreen[1]); painter.drawLine2d(centerScreen[0], centerScreen[1], centerScreen[0] - length, centerScreen[1]);
} }
skipping to change at line 552 skipping to change at line 616
// gluDisk(quadric, radius - 1.0, radius, 256, 1); // gluDisk(quadric, radius - 1.0, radius, 256, 1);
// radius = 0.5 * projector->getPixelPerRadAtCenter() * (M_PI/1 80) * (4.0); // radius = 0.5 * projector->getPixelPerRadAtCenter() * (M_PI/1 80) * (4.0);
// gluDisk(quadric, radius - 1.0, radius, 256, 1); // gluDisk(quadric, radius - 1.0, radius, 256, 1);
// gluDeleteQuadric(quadric); // gluDeleteQuadric(quadric);
// glPopMatrix(); // glPopMatrix();
} }
} }
void Oculars::initializeActivationActions() void Oculars::initializeActivationActions()
{ {
QString group = "Oculars Plugin"; // 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);
gui->addGuiActions("actionShow_Ocular", N_("Enable ocular"), "Ctrl+O gui->addGuiActions("actionShow_Ocular",
", "Plugin Key Bindings", true); N_("Ocular view"),
settings->value("bi
ndings/toggle_oculars", "Ctrl+O").toString(),
N_("Plugin Key Bind
ings"),
true);
gui->getGuiActions("actionShow_Ocular")->setChecked(flagShowOculars) ; gui->getGuiActions("actionShow_Ocular")->setChecked(flagShowOculars) ;
connect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(toggled(bool //This action needs to be connected to the enableOcular() slot after
)), this, SLOT(enableOcular(bool))); //the necessary button is created to prevent the button from being c
gui->addGuiActions("actionShow_Ocular_Window", N_("Configuration Win hecked
dow"), "ALT+O", group, true); //the first time this action is checked. See:
//http://doc.qt.nokia.com/4.7/signalsandslots.html#signals
gui->addGuiActions("actionShow_Ocular_Window",
N_("Oculars configu
ration window"),
settings->value("bi
ndings/toggle_config_dialog", "ALT+O").toString(),
group,
true);
connect(gui->getGuiActions("actionShow_Ocular_Window"), SIGNAL(toggl ed(bool)), ocularDialog, SLOT(setVisible(bool))); connect(gui->getGuiActions("actionShow_Ocular_Window"), SIGNAL(toggl ed(bool)), ocularDialog, SLOT(setVisible(bool)));
connect(ocularDialog, SIGNAL(visibleChanged(bool)), gui->getGuiActio ns("actionShow_Ocular_Window"), SLOT(setChecked(bool))); connect(ocularDialog, SIGNAL(visibleChanged(bool)), gui->getGuiActio ns("actionShow_Ocular_Window"), SLOT(setChecked(bool)));
gui->addGuiActions("actionShow_Ocular_Telrad", N_("Display Telrad"), gui->addGuiActions("actionShow_Ocular_Telrad",
"Ctrl+B", group, true); N_("Telrad circles"
),
settings->value("bi
ndings/toggle_telrad", "Ctrl+B").toString(),
group,
true);
gui->getGuiActions("actionShow_Ocular_Telrad")->setChecked(flagShowT elrad); gui->getGuiActions("actionShow_Ocular_Telrad")->setChecked(flagShowT elrad);
connect(gui->getGuiActions("actionShow_Ocular_Telrad"), SIGNAL(toggl ed(bool)), this, SLOT(toggleTelrad())); connect(gui->getGuiActions("actionShow_Ocular_Telrad"), SIGNAL(toggl ed(bool)), this, SLOT(toggleTelrad()));
// 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,
g ui->getGuiActions("actionShow_Ocular")); g ui->getGuiActions("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(gui->getGuiActions("actionShow_Ocular"), SIGNAL(toggled(bool )), this, SLOT(enableOcular(bool)));
} }
void Oculars::initializeActions() void Oculars::initializeActions()
{ {
static bool actions_initialized; static bool actions_initialized;
if (actions_initialized) if (actions_initialized)
return; return;
actions_initialized = true; actions_initialized = true;
QString group = "Oculars Plugin"; QString group = "Oculars Plugin";
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); Q_ASSERT(gui);
gui->addGuiActions("actionShow_Ocular_Crosshair", N_("Toggle Crossha //Bogdan: In the moment, these are not displayed in the Help dialog
ir"), "ALT+C", group, true); or
//anywhere, so I've removed the N_() to avoid confusing the translat
gui->addGuiActions("actionShow_CCD_increment", N_("Select next senso ors
r"), "Shift+Ctrl+]", group, false); //TODO: Fix this when the key bindings feature is implemented
gui->addGuiActions("actionShow_CCD_decrement", N_("Select previous s gui->addGuiActions("actionShow_Ocular_Crosshair",
ensor"), "Shift+Ctrl+[", group, false); ("Toggle Crosshair"
gui->addGuiActions("actionShow_Ocular_increment", N_("Select next oc ),
ular"), "Ctrl+]", group, false); settings->value("bi
gui->addGuiActions("actionShow_Ocular_decrement", N_("Select previou ndings/toggle_crosshair", "ALT+C").toString(),
s ocular"), "Ctrl+[", group, false); group, true);
gui->addGuiActions("actionShow_Telescope_increment", N_("Select next
telescope"), "Shift+]", group, false); gui->addGuiActions("actionShow_CCD_increment",
gui->addGuiActions("actionShow_Telescope_decrement", N_("Select prev ("Select next senso
ious telescope"), "Shift+[", group, false); r"),
settings->value("bi
ndings/next_ccd", "Shift+Ctrl+]").toString(),
group, false);
gui->addGuiActions("actionShow_CCD_decrement",
("Select previous s
ensor"),
settings->value("bi
ndings/prev_ccd", "Shift+Ctrl+[").toString(),
group, false);
gui->addGuiActions("actionShow_Ocular_increment",
("Select next ocula
r"),
settings->value("bi
ndings/next_ocular", "Ctrl+]").toString(),
group, false);
gui->addGuiActions("actionShow_Ocular_decrement",
("Select previous o
cular"),
settings->value("bi
ndings/prev_ocular", "Ctrl+[").toString(),
group, false);
gui->addGuiActions("actionShow_Telescope_increment",
("Select next teles
cope"),
settings->value("bi
ndings/next_telescope", "Shift+]").toString(),
group, false);
gui->addGuiActions("actionShow_Telescope_decrement",
("Select previous t
elescope"),
settings->value("bi
ndings/prev_telescope", "Shift+[").toString(),
group, false);
connect(gui->getGuiActions("actionShow_Ocular_Crosshair"), SIGNAL(to ggled(bool)), this, SLOT(toggleCrosshair())); connect(gui->getGuiActions("actionShow_Ocular_Crosshair"), SIGNAL(to ggled(bool)), this, SLOT(toggleCrosshair()));
connect(gui->getGuiActions("actionShow_CCD_increment"), SIGNAL(trigg ered()), this, SLOT(incrementCCDIndex())); connect(gui->getGuiActions("actionShow_CCD_increment"), SIGNAL(trigg ered()), this, SLOT(incrementCCDIndex()));
connect(gui->getGuiActions("actionShow_CCD_decrement"), SIGNAL(trigg ered()), this, SLOT(decrementCCDIndex())); connect(gui->getGuiActions("actionShow_CCD_decrement"), SIGNAL(trigg ered()), this, SLOT(decrementCCDIndex()));
connect(gui->getGuiActions("actionShow_Ocular_increment"), SIGNAL(tr iggered()), this, SLOT(incrementOcularIndex())); connect(gui->getGuiActions("actionShow_Ocular_increment"), SIGNAL(tr iggered()), this, SLOT(incrementOcularIndex()));
connect(gui->getGuiActions("actionShow_Ocular_decrement"), SIGNAL(tr iggered()), this, SLOT(decrementOcularIndex())); connect(gui->getGuiActions("actionShow_Ocular_decrement"), SIGNAL(tr iggered()), this, SLOT(decrementOcularIndex()));
connect(gui->getGuiActions("actionShow_Telescope_increment"), SIGNAL (triggered()), this, SLOT(incrementTelescopeIndex())); connect(gui->getGuiActions("actionShow_Telescope_increment"), SIGNAL (triggered()), this, SLOT(incrementTelescopeIndex()));
connect(gui->getGuiActions("actionShow_Telescope_decrement"), SIGNAL (triggered()), this, SLOT(decrementTelescopeIndex())); connect(gui->getGuiActions("actionShow_Telescope_decrement"), SIGNAL (triggered()), this, SLOT(decrementTelescopeIndex()));
/* /*
connect(telescopesTableModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged())); connect(telescopesTableModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged()));
connect(telescopesTableModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(rowsInserted())); connect(telescopesTableModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(rowsInserted()));
connect(telescopesTableModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(rowsRemoved())); connect(telescopesTableModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(rowsRemoved()));
*/ */
connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentCha nged())); connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentCha nged()));
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(ocularDialog, SIGNAL(scaleImageCircleChanged(bool)), this, S LOT(setScaleImageCircle(bool))); connect(ocularDialog, SIGNAL(scaleImageCircleChanged(bool)), this, S LOT(setScaleImageCircle(bool)));
} }
// Return true if we're ready (could read all required data), false otherwi
se
bool Oculars::initializeDB()
{
StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directo
ry|StelFileMgr::Writable);
QString dbPath = StelFileMgr::findFile("modules/Oculars/", flags);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "oculars");
db.setDatabaseName(dbPath + "oculars.sqlite");
if (db.open()) {
#define EXEC(sql) if (!query.exec(sql)) { qDebug() << query.lastError(); re
turn false;}
qDebug() << "Oculars opened the DB successfully.";
// See if the tables alreadt exist.
QStringList tableList = db.tables();
if (!tableList.contains("oculars")) {
QSqlQuery query = QSqlQuery(db);
EXEC("create table oculars (id INTEGER PRIMARY KEY,
name VARCHAR, afov FLOAT, efl FLOAT, fieldStop FLOAT)");
EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
p) VALUES ('one', 43, 40, 0)");
EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
p) VALUES ('two', 82, 31, 0)");
EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
p) VALUES ('three', 52, 10.5, 0)");
EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
p) VALUES ('four', 52, 26, 0)");
EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
p) VALUES ('five', 82, 20, 0)");
}
if (!tableList.contains("telescopes")) {
QSqlQuery query = QSqlQuery(db);
EXEC("create table telescopes (id INTEGER PRIMARY KE
Y, name VARCHAR, focalLength FLOAT, diameter FLOAT, vFlip VARCHAR, hFlip VA
RCHAR)");
EXEC("INSERT INTO telescopes (name, focalLength, dia
meter, vFlip, hFlip) VALUES ('C1400', 3190, 355.6, 'false', 'true')");
EXEC("INSERT INTO telescopes (name, focalLength, dia
meter, vFlip, hFlip) VALUES ('80EDF', 500, 80, 'false', 'false')");
}
if (!tableList.contains("ccd")) {
QSqlQuery query = QSqlQuery(db);
EXEC("create table ccd (id INTEGER PRIMARY KEY, name
VARCHAR, resolution_x INTEGER, resolution_y INTEGER, chip_width FLOAT, chi
p_height FLOAT, pixel_width FLOAT, pixel_height FLOAT)");
EXEC("INSERT INTO ccd (name, resolution_x, resolutio
n_y, chip_width, chip_height, pixel_width, pixel_height) VALUES ('None', 0,
0, 0, 0, 0, 0)");
EXEC("INSERT INTO ccd (name, resolution_x, resolutio
n_y, chip_width, chip_height, pixel_width, pixel_height) VALUES ('EOS 450D'
, 4272, 2848, 22.2, 14.8, 5.2, 5.2)");
}
// Set the table models
CCDsTableModel = new QSqlTableModel(0, db);
CCDsTableModel->setTable("ccd");
CCDsTableModel->select();
ocularsTableModel = new QSqlTableModel(0, db);
ocularsTableModel->setTable("oculars");
if (!ocularsTableModel->select())
return false;
telescopesTableModel = new QSqlTableModel(0, db);
telescopesTableModel->setTable("telescopes");
if (!telescopesTableModel->select())
return false;
#undef EXEC
return true;
} else {
qDebug() << "Oculars could not open its database; disabling
module.";
}
return false;
}
void Oculars::interceptMovementKey(QKeyEvent* event) void Oculars::interceptMovementKey(QKeyEvent* event)
{ {
// 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)
{ {
skipping to change at line 774 skipping to change at line 829
if (consumeEvent) if (consumeEvent)
{ {
event->accept(); event->accept();
} }
else else
{ {
event->setAccepted(false); event->setAccepted(false);
} }
} }
void Oculars::loadDatabaseObjects()
{
loadCCDs();
loadOculars();
loadTelescopes();
if (useMaxImageCircle) {
determineMaxImageCircle();
}
// A telescope and one of [CCD|Ocular] must be defined for the plugi
n to be usable.
if (telescopes.size() == 0)
{
ready = false;
qWarning() << "WARNING: no telescopes found. Ocular will be
disabled.";
}
else if (oculars.size() == 0 && CCDs.size() == 0) {
ready = false;
qWarning() << "WARNING: no oculars or CCDs found. Ocular wi
ll be disabled.";
}
else
{
ready = true;
}
}
void Oculars::paintMask() void Oculars::paintMask()
{ {
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); glDisable(GL_BLEND);
glColor3f(0.f,0.f,0.f); glColor3f(0.f,0.f,0.f);
glPushMatrix(); glPushMatrix();
glTranslated(params.viewportCenter[0], params.viewportCenter[1], 0.0 ); glTranslated(params.viewportCenter[0], params.viewportCenter[1], 0.0 );
GLUquadricObj *quadric = gluNewQuadric(); GLUquadricObj *quadric = gluNewQuadric();
GLdouble inner = 0.5 * params.viewportFovDiameter; GLdouble inner = 0.5 * params.viewportFovDiameter;
// See if we need to scale the mask // See if we need to scale the mask
if (useMaxImageCircle && oculars[selectedOcularIndex]->getExitCircle if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO
(telescopes[selectedTelescopeIndex]) > 0.0) { V() > 0.0) {
inner = oculars[selectedOcularIndex]->getExitCircle(telescop inner = oculars[selectedOcularIndex]->appearentFOV() * inner
es[selectedTelescopeIndex]) * inner / maxImageCircle; / maxEyepieceAngle;
} }
GLdouble outer = params.viewportXywh[2] + params.viewportXywh[3]; GLdouble outer = params.viewportXywh[2] + params.viewportXywh[3];
// Draw the mask // Draw the mask
gluDisk(quadric, inner, outer, 256, 1); gluDisk(quadric, inner, outer, 256, 1);
// the gray circle // the gray circle
glColor3f(0.15f,0.15f,0.15f); glColor3f(0.15f,0.15f,0.15f);
gluDisk(quadric, inner - 1.0, inner, 256, 1); gluDisk(quadric, inner - 1.0, inner, 256, 1);
gluDeleteQuadric(quadric); gluDeleteQuadric(quadric);
// draw sensor rectangle // draw sensor rectangle
CCD *ccd = CCDs[selectedCCDIndex]; if(selectedCCDIndex != -1) {
if (ccd) { CCD *ccd = ccds[selectedCCDIndex];
Ocular *ocular = oculars[selectedOcularIndex]; if (ccd) {
float CCDx = ccd->getActualFOVx(ocular); glColor4f(0.77, 0.14, 0.16, 0.5);
float CCDy = ccd->getActualFOVy(ocular); Telescope *telescope = telescopes[selectedTelescopeI
if (CCDx > 0.0 && CCDy > 0.0) { ndex];
glBegin(GL_LINE_LOOP); float CCDx = ccd->getActualFOVx(telescope);
glVertex2f(-CCDx, CCDy); float CCDy = ccd->getActualFOVy(telescope);
glVertex2f(CCDx, CCDy); if (CCDx > 0.0 && CCDy > 0.0) {
glVertex2f(CCDx, -CCDy); glBegin(GL_LINE_LOOP);
glVertex2f(-CCDx, -CCDy); glVertex2f(-CCDx, CCDy);
glEnd(); glVertex2f(CCDx, CCDy);
glVertex2f(CCDx, -CCDy);
glVertex2f(-CCDx, -CCDy);
glEnd();
}
} }
} }
glPopMatrix(); glPopMatrix();
} }
void Oculars::paintText(const StelCore* core) void Oculars::paintText(const StelCore* core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ; const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ;
StelPainter painter(prj); StelPainter painter(prj);
// Get the current instruments // Get the current instruments
CCD *ccd = CCDs[selectedCCDIndex]; CCD *ccd = NULL;
if(selectedCCDIndex != -1) {
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 the color and the GL state
painter.setColor(0.8, 0.48, 0.0, 1); painter.setColor(0.8, 0.48, 0.0, 1);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
// Get the X & Y positions, and the line height // Get the X & Y positions, and the line height
skipping to change at line 869 skipping to change at line 906
QString widthString = "MMMMMMMMMMMMMMMMMMM"; QString widthString = "MMMMMMMMMMMMMMMMMMM";
float insetFromRHS = painter.getFontMetrics().width(widthString); float insetFromRHS = painter.getFontMetrics().width(widthString);
StelProjector::StelProjectorParams projectorParams = core->getCurren tStelProjectorParams(); StelProjector::StelProjectorParams projectorParams = core->getCurren tStelProjectorParams();
int xPosition = projectorParams.viewportXywh[2]; int xPosition = projectorParams.viewportXywh[2];
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 = painter.getFontMetrics().height();
// The CCD // The CCD
QString ccdSensorLabel, ccdInfoLabel; QString ccdsensorLabel, ccdInfoLabel;
if (ccd && ccd->getChipWidth() > .0 && ccd->getChipHeight() > .0) { if (ccd && ccd->chipWidth() > .0 && ccd->chipHeight() > .0) {
ccdInfoLabel = "Dimension : " + QVariant(ccd->getChipWidth() ccdInfoLabel = "Dimension : " + QVariant(ccd->chipWidth()).t
).toString() + "x" + QVariant(ccd->getChipHeight()).toString() + " mm"; oString() + "x" + QVariant(ccd->chipHeight()).toString() + " mm";
if (ccd->getName() != QString("")) { if (ccd->name() != QString("")) {
ccdSensorLabel = "Sensor #" + QVariant(selectedCCDIn ccdsensorLabel = "Sensor #" + QVariant(selectedCCDIn
dex).toString(); dex).toString();
ccdSensorLabel.append(" : ").append(ccd->getName()); ccdsensorLabel.append(" : ").append(ccd->name());
} }
} }
if (ccdSensorLabel != QString("")) { if (ccdsensorLabel != QString("")) {
painter.drawText(xPosition, yPosition, ccdSensorLabel); painter.drawText(xPosition, yPosition, ccdsensorLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, ccdInfoLabel); painter.drawText(xPosition, yPosition, ccdInfoLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
} }
// The Ocular // The Ocular
QString ocularNumberLabel = "Ocular #" + QVariant(selectedOcularInde x).toString(); QString ocularNumberLabel = "Ocular #" + QVariant(selectedOcularInde x).toString();
if (ocular->getName() != QString("")) { if (ocular->name() != QString("")) {
ocularNumberLabel.append(" : ").append(ocular->getName()); ocularNumberLabel.append(" : ").append(ocular->name());
} }
painter.drawText(xPosition, yPosition, ocularNumberLabel); painter.drawText(xPosition, yPosition, ocularNumberLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
QString ocularFLLabel = "Ocular FL: " + QVariant(ocular->getEffectiv eFocalLength()).toString() + QChar(0x00B0); QString ocularFLLabel = "Ocular FL: " + QVariant(ocular->effectiveFo calLength()).toString() + "mm";
painter.drawText(xPosition, yPosition, ocularFLLabel); painter.drawText(xPosition, yPosition, ocularFLLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
QString ocularFOVLabel = "Ocular aFOV: " + QVariant(ocular->getAppea rentFOV()).toString() + QChar(0x00B0); QString ocularFOVLabel = "Ocular aFOV: " + QVariant(ocular->appearen tFOV()).toString() + QChar(0x00B0);
painter.drawText(xPosition, yPosition, ocularFOVLabel); painter.drawText(xPosition, yPosition, ocularFOVLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
// The telescope // The telescope
QString telescopeNumberLabel = "Telescope #" + QVariant(selectedTele scopeIndex).toString(); QString telescopeNumberLabel = "Telescope #" + QVariant(selectedTele scopeIndex).toString();
if (telescope->getName() != QString("")) { if (telescope->name() != QString("")) {
telescopeNumberLabel.append(" : ").append(telescope->getName telescopeNumberLabel.append(" : ").append(telescope->name())
()); ;
} }
painter.drawText(xPosition, yPosition, telescopeNumberLabel); painter.drawText(xPosition, yPosition, telescopeNumberLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
// General info // General info
QString magnificationLabel = "Magnification: " + QVariant(((int)(ocu QString magnificationLabel = "Magnification: "
lar->getMagnification(telescope) * 10.0)) / 10.0).toString() + "x";
+ QVariant(((int)(ocular->magnification(telescope) * 10.0)) / 10.0).t
oString()
+ "x";
painter.drawText(xPosition, yPosition, magnificationLabel); painter.drawText(xPosition, yPosition, magnificationLabel);
yPosition-=lineHeight; yPosition-=lineHeight;
QString imageCircleLabel = "Image Circle: " + QVariant(((int)(ocular QString fovLabel = "FOV: "
->getExitCircle(telescope) * 10.0)) / 10.0).toString() + "mm"; + QVariant(((int)(o
painter.drawText(xPosition, yPosition, imageCircleLabel); cular->actualFOV(telescope) * 10000.00)) / 10000.0).toString()
yPosition-=lineHeight; + QChar(0x00B0);
QString fovLabel = "FOV: " + QVariant(((int)(ocular->getActualFOV(te
lescope) * 10000.00)) / 10000.0).toString() + QChar(0x00B0);
painter.drawText(xPosition, yPosition, fovLabel); painter.drawText(xPosition, yPosition, fovLabel);
} }
void Oculars::validateIniFile() 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 qWarning() << "Oculars::validateIniFile cannot copy
default_ocular.ini resource to [non-existing] " + ocularIniPath; default_ocular.ini resource to [non-existing] "
+ 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();
skipping to change at line 972 skipping to change at line 1009
} else { } else {
qDebug() << "Oculars::validateIniFil e copied default_ocular.ini to " << ocularIniPath; qDebug() << "Oculars::validateIniFil e copied default_ocular.ini to " << ocularIniPath;
// The resource is read only, and th e new file inherits this... make sure the new file // The resource is read only, and th e new file inherits this... make sure the new file
// is writable by the Stellarium pro cess so that updates can be done. // is writable by the Stellarium pro cess so that updates can be done.
QFile dest(ocularIniPath); QFile dest(ocularIniPath);
dest.setPermissions(dest.permissions () | QFile::WriteOwner); dest.setPermissions(dest.permissions () | QFile::WriteOwner);
} }
} }
} }
} }
settings = new QSettings(ocularIniPath, QSettings::IniFormat, this);
}
QSettings* Oculars::appSettings()
{
return settings;
} }
void Oculars::unzoomOcular() void Oculars::unzoomOcular()
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
GridLinesMgr *gridManager = (GridLinesMgr *)StelApp::getInstance().g etModuleMgr().getModule("GridLinesMgr"); GridLinesMgr *gridManager = (GridLinesMgr *)StelApp::getInstance().g etModuleMgr().getModule("GridLinesMgr");
gridManager->setFlagAzimuthalGrid(flagAzimuthalGrid); gridManager->setFlagAzimuthalGrid(flagAzimuthalGrid);
gridManager->setFlagEquatorGrid(flagEquatorGrid); gridManager->setFlagEquatorGrid(flagEquatorGrid);
skipping to change at line 1053 skipping to change at line 1096
1); 1);
} }
// Set the screen display // Set the screen display
// core->setMaskType(StelProjector::MaskDisk); // core->setMaskType(StelProjector::MaskDisk);
Ocular *ocular = oculars[selectedOcularIndex]; Ocular *ocular = oculars[selectedOcularIndex];
Telescope *telescope = telescopes[selectedTelescopeIndex]; Telescope *telescope = telescopes[selectedTelescopeIndex];
core->setFlipHorz(telescope->isHFlipped()); core->setFlipHorz(telescope->isHFlipped());
core->setFlipVert(telescope->isVFlipped()); core->setFlipVert(telescope->isVFlipped());
double actualFOV = ocular->getActualFOV(telescope); double actualFOV = ocular->actualFOV(telescope);
// See if the mask was scaled; if so, correct the actualFOV. // See if the mask was scaled; if so, correct the actualFOV.
if (useMaxImageCircle && ocular->getExitCircle(telescope) > 0.0) { if (useMaxEyepieceAngle && ocular->appearentFOV() > 0.0) {
actualFOV = maxImageCircle * actualFOV / ocular->getExitCirc actualFOV = maxEyepieceAngle * actualFOV / ocular->appearent
le(telescope); FOV();
} }
movementManager->zoomTo(actualFOV, 0.0); movementManager->zoomTo(actualFOV, 0.0);
} }
 End of changes. 66 change blocks. 
308 lines changed or deleted 360 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/