Oculars.cpp   Oculars.cpp 
skipping to change at line 96 skipping to change at line 96
#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 MessageLabelID(-1), Oculars::Oculars() : selectedOcularIndex(-1), flagShowOculars(false), usage MessageLabelID(-1),
pxmapGlow(NULL), pxmapOnIcon(NULL), pxmap OffIcon(NULL), toolbarButton(NULL) pxmapGlow(NULL), pxmapOnIcon(NULL), pxmap OffIcon(NULL), toolbarButton(NULL)
{ {
flagShowOculars = false; flagShowOculars = false;
flagShowCrosshairs = false; flagShowCrosshairs = false;
flagShowTelrad = false;
font.setPixelSize(14); font.setPixelSize(14);
maxImageCircle = 0.0; maxImageCircle = 0.0;
CCDs = QList<CCD *>();
oculars = QList<Ocular *>(); oculars = QList<Ocular *>();
ready = true; ready = false;
selectedCCDIndex = 0;
selectedOcularIndex = 0; selectedOcularIndex = 0;
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
setObjectName("Oculars"); setObjectName("Oculars");
telescopes = QList<Telescope *>(); telescopes = QList<Telescope *>();
useMaxImageCircle = true; useMaxImageCircle = true;
visible = false; visible = false;
ocularsTableModel = NULL;
telescopesTableModel = NULL;
ocularDialog = NULL;
} }
Oculars::~Oculars() Oculars::~Oculars()
{ {
QSqlDatabase db = QSqlDatabase::database("oculars"); delete CCDsTableModel;
db.close(); CCDsTableModel = NULL;
QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection);
delete ocularsTableModel; delete ocularsTableModel;
ocularsTableModel = NULL; ocularsTableModel = NULL;
delete telescopesTableModel; delete telescopesTableModel;
telescopesTableModel = NULL; 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
/* ********************************************************************* */ /* ********************************************************************* */
bool Oculars::configureGui(bool show) bool Oculars::configureGui(bool show)
{ {
if (show) if (show)
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
Q_ASSERT(gui);
gui->getGuiActions("actionShow_Ocular_Window")->setChecked(t rue); gui->getGuiActions("actionShow_Ocular_Window")->setChecked(t rue);
} }
return true; return ready;
} }
//! 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)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) if (flagShowTelrad) {
; drawTelrad();
StelPainter painter(prj);
painter.setFont(font);
// Insure there is a selected ocular & telescope
if (selectedOcularIndex > oculars.count()) {
qWarning() << "Oculars: the selected ocular index of " << se
lectedOcularIndex << " is greate that the ocular count of "
<< oculars.count() << ". Module disable.";
ready = false;
}
if (selectedTelescopeIndex > telescopes.count()) {
qWarning() << "Oculars: the selected telescope index of " <<
selectedTelescopeIndex << " is greate that the telescope count of "
<< telescopes.count() << ". Module disable.";
ready = false;
} }
if (flagShowOculars){
if (ready && flagShowOculars) { // Insure there is a selected ocular & telescope
paintMask(); if (selectedCCDIndex > CCDs.count()) {
if (flagShowCrosshairs) { qWarning() << "Oculars: the selected sensor index of
drawCrosshairs(); " << selectedCCDIndex << " is greater than the sensor count of "
<< CCDs.count() << ". Module disabled!";
ready = false;
}
if (selectedOcularIndex > oculars.count()) {
qWarning() << "Oculars: the selected ocular index of
" << selectedOcularIndex << " is greater than the ocular count of "
<< oculars.count() << ". Module disabled!";
ready = false;
}
else if (selectedTelescopeIndex > telescopes.count()) {
qWarning() << "Oculars: the selected telescope index
of " << selectedTelescopeIndex << " is greater than the telescope count of
"
<< telescopes.count() << ". Module disabled!";
ready = false;
}
if (ready) {
paintMask();
if (flagShowCrosshairs) {
drawCrosshairs();
}
// Paint the information in the upper-right hand cor
ner
paintText(core);
} }
Ocular *ocular = oculars[selectedOcularIndex]; newInstrument = false; // Now that it's been drawn once
Telescope *telescope = telescopes[selectedTelescopeIndex];
QString widthString = "MMMMMMMMMMMMMMMMMMM";
QString string1 = "Ocular #" + QVariant(selectedOcularIndex)
.toString();
if (ocular->getName() != QString("")) {
string1.append(" : ").append(ocular->getName());
}
QString string2 = "Ocular aFOV: " + QVariant(ocular->getAppe
arentFOV()).toString() + QChar(0x00B0);
QString string4 = "Telescope #" + QVariant(selectedTelescope
Index).toString();
if (telescope->getName() != QString("")) {
string4.append(" : ").append(telescope->getName());
}
QString string5 = "Magnification: " + QVariant(((int)(ocular
->getMagnification(telescope) * 10.0)) / 10.0).toString() + "x";
QString string6 = "Image Circle: " + QVariant(((int)(ocular-
>getExitCircle(telescope) * 10.0)) / 10.0).toString() + "mm";
QString string7 = "FOV: " + QVariant(((int)(ocular->getAcuta
lFOV(telescope) * 10000.00)) / 10000.0).toString() + QChar(0x00B0);
float insetFromRHS = painter.getFontMetrics().width(widthStr
ing);
StelProjector::StelProjectorParams projectorParams = core->g
etCurrentStelProjectorParams();
int xPosition = projectorParams.viewportXywh[2];
xPosition -= insetFromRHS;
int yPosition = projectorParams.viewportXywh[3];
yPosition -= 40;
painter.setColor(0.8, 0.48, 0.0, 1);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
const int lineHeight = painter.getFontMetrics().height();
painter.drawText(xPosition, yPosition, string1);
yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, string2);
yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, string4);
yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, string5);
yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, string6);
yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, string7);
} }
newIntrument = false; // Now that it's been drawn once
} }
//! Determine which "layer" the plagin's drawing will happen on. //! Determine which "layer" the plagin'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;
if (actionName==StelModule::ActionHandleKeys || actionName==StelModu le::ActionHandleMouseMoves) if (actionName==StelModule::ActionHandleKeys || actionName==StelModu le::ActionHandleMouseMoves)
{ {
skipping to change at line 228 skipping to change at line 201
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;
} }
void Oculars::handleMouseClicks(class QMouseEvent* event) void Oculars::handleMouseClicks(class QMouseEvent* event)
{ {
StelCore::StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr::StelMovementMgr *movementManager = core->getMovemen StelMovementMgr *movementManager = core->getMovementMgr();
tMgr();
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.
movementManager->setFlagTracking(true); movementManager->setFlagTracking(true);
} }
else else
{ {
skipping to change at line 257 skipping to change at line 230
} }
} }
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);
} }
bool Oculars::handleMouseMoves(int x, int y, Qt::MouseButtons b)
{
// Allow it to go up the stack
return 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(); validateIniFile();
if (initializeDB()) { if (initializeDB()) {
// assume all is well
ready = true; ready = true;
ocularDialog = new OcularDialog(ocularsTableModel, telescope ocularDialog = new OcularDialog(CCDsTableModel, ocularsTable
sTableModel); Model, telescopesTableModel);
initializeActions(); initializeActivationActions();
} }
try { try {
StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr: :Directory|StelFileMgr::Writable); StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr: :Directory|StelFileMgr::Writable);
QString ocularIniPath = StelFileMgr::findFile("modules/Ocula rs/", flags) + "ocular.ini"; QString ocularIniPath = StelFileMgr::findFile("modules/Ocula rs/", flags) + "ocular.ini";
QSettings settings(ocularIniPath, QSettings::IniFormat); QSettings settings(ocularIniPath, QSettings::IniFormat);
useMaxImageCircle = settings.value("use_max_exit_circle", 0. 0).toBool(); useMaxImageCircle = settings.value("use_max_exit_circle", 0. 0).toBool();
} catch (std::runtime_error& e) { } catch (std::runtime_error& e) {
qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what(); qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what();
} }
//Load the module's custom style sheets
QFile styleSheetFile;
styleSheetFile.setFileName(":/ocular/normalStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
normalStyleSheet = styleSheetFile.readAll();
}
styleSheetFile.close();
styleSheetFile.setFileName(":/ocular/nightStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
nightStyleSheet = styleSheetFile.readAll();
}
styleSheetFile.close();
} }
void Oculars::setStelStyle(const StelStyle& style) void Oculars::deinit()
{ {
/* QSqlDatabase db = QSqlDatabase::database("oculars");
if(dialog) { db.close();
dialog->setStyleSheet(telescopeManager->getModuleStyleSheet( QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection);
style.confSectionName)); }
}
*/ void Oculars::setStelStyle(const QString&)
{
ocularDialog->updateStyle();
}
//Change the styles of all children, too const StelStyle Oculars::getModuleStyleSheet(const StelStyle& style)
ocularDialog->setStelStyle(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::determineMaxImageCircle()
{ {
skipping to change at line 328 skipping to change at line 325
} }
} }
// insure it is not zero // insure it is not zero
if (maxImageCircle == 0.0) { if (maxImageCircle == 0.0) {
maxImageCircle = 1.0; maxImageCircle = 1.0;
} }
} }
void Oculars::instrumentChanged() void Oculars::instrumentChanged()
{ {
newIntrument = 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() void Oculars::loadOculars()
{ {
oculars.clear(); oculars.clear();
int rowCount = ocularsTableModel->rowCount(); int rowCount = ocularsTableModel->rowCount();
for (int row = 0; row < rowCount; row++) { for (int row = 0; row < rowCount; row++) {
oculars.append(new Ocular(ocularsTableModel->record(row))); oculars.append(new Ocular(ocularsTableModel->record(row)));
} }
if (oculars.size() == 0) {
ready = false;
qWarning() << "WARNING: no oculars found. Feature will be d
isabled.";
}
} }
void Oculars::loadTelescopes() void Oculars::loadTelescopes()
{ {
telescopes.clear(); telescopes.clear();
int rowCount = telescopesTableModel->rowCount(); int rowCount = telescopesTableModel->rowCount();
for (int row = 0; row < rowCount; row++) { for (int row = 0; row < rowCount; row++) {
telescopes.append(new Telescope(telescopesTableModel->record (row))); telescopes.append(new Telescope(telescopesTableModel->record (row)));
} }
if (telescopes.size() == 0) {
ready = false;
qWarning() << "WARNING: no telescopes found. Feature will b
e disabled.";
}
} }
void Oculars::setScaleImageCircle(bool state) void Oculars::setScaleImageCircle(bool state)
{ {
if (state) { if (state) {
determineMaxImageCircle(); determineMaxImageCircle();
} }
useMaxImageCircle = state; useMaxImageCircle = state;
} }
skipping to change at line 382 skipping to change at line 378
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
void Oculars::enableOcular(bool b) void Oculars::enableOcular(bool b)
{ {
if (!ready) { if (!ready) {
qDebug() << "The Oculars module has been disabled."; qDebug() << "The Oculars module has been disabled.";
return; return;
} }
if (b) { if (b) {
// load data and determine if we're ready (if we have all re quired data)
loadDatabaseObjects(); loadDatabaseObjects();
} }
if (!ready) {
// no, some data was missing. We already warned, done.
return;
}
StelCore::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];
skipping to change at line 415 skipping to change at line 416
// 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 = b;
zoom(false); zoom(false);
} }
} }
if (flagShowOculars) {
initializeActions();
}
}
void Oculars::decrementCCDIndex()
{
selectedCCDIndex--;
if (selectedCCDIndex == -1) {
selectedCCDIndex = CCDs.count() - 1;
}
emit(selectedCCDChanged());
} }
void Oculars::decrementOcularIndex() void Oculars::decrementOcularIndex()
{ {
selectedOcularIndex--; selectedOcularIndex--;
if (selectedOcularIndex == -1) { if (selectedOcularIndex == -1) {
selectedOcularIndex = oculars.count() - 1; selectedOcularIndex = oculars.count() - 1;
} }
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} }
void Oculars::decrementTelescopeIndex() void Oculars::decrementTelescopeIndex()
{ {
selectedTelescopeIndex--; selectedTelescopeIndex--;
if (selectedTelescopeIndex == -1) { if (selectedTelescopeIndex == -1) {
selectedTelescopeIndex = telescopes.count() - 1; selectedTelescopeIndex = telescopes.count() - 1;
} }
emit(selectedTelescopeChanged()); emit(selectedTelescopeChanged());
} }
void Oculars::incrementCCDIndex()
{
selectedCCDIndex++;
if (selectedCCDIndex == CCDs.count()) {
selectedCCDIndex = 0;
}
emit(selectedCCDChanged());
}
void Oculars::incrementOcularIndex() void Oculars::incrementOcularIndex()
{ {
selectedOcularIndex++; selectedOcularIndex++;
if (selectedOcularIndex == oculars.count()) { if (selectedOcularIndex == oculars.count()) {
selectedOcularIndex = 0; selectedOcularIndex = 0;
} }
emit(selectedOcularChanged()); emit(selectedOcularChanged());
} }
void Oculars::incrementTelescopeIndex() void Oculars::incrementTelescopeIndex()
skipping to change at line 458 skipping to change at line 480
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
} }
emit(selectedTelescopeChanged()); emit(selectedTelescopeChanged());
} }
void Oculars::toggleCrosshair() void Oculars::toggleCrosshair()
{ {
flagShowCrosshairs = !flagShowCrosshairs; flagShowCrosshairs = !flagShowCrosshairs;
} }
void Oculars::toggleTelrad()
{
flagShowTelrad = !flagShowTelrad;
}
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Private Methods #pragma mark Private Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
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::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 (telescopes[selectedTelescopeIndex]) > 0.0) { if (useMaxImageCircle && oculars[selectedOcularIndex]->getExitCircle (telescopes[selectedTelescopeIndex]) > 0.0) {
length = oculars[selectedOcularIndex]->getExitCircle(telesco pes[selectedTelescopeIndex]) * length / maxImageCircle; length = oculars[selectedOcularIndex]->getExitCircle(telesco pes[selectedTelescopeIndex]) * length / maxImageCircle;
} }
// 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]);
} }
void Oculars::initializeActions() void Oculars::drawTelrad()
{
if (!flagShowOculars) {
const StelProjectorP projector = StelApp::getInstance().getC
ore()->getProjection(StelCore::FrameEquinoxEqu);
StelCore *core = StelApp::getInstance().getCore();
StelProjector::StelProjectorParams params = core->getCurrent
StelProjectorParams();
// StelPainter drawing
StelPainter painter(projector);
painter.setColor(0.77, 0.14, 0.16, 1.0);
Vec2i centerScreen(projector->getViewportPosX()+projector->g
etViewportWidth()/2,
projector->getViewportPos
Y()+projector->getViewportHeight()/2);
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p
rojector->getPixelPerRadAtCenter() * (M_PI/180) * (0.5));
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p
rojector->getPixelPerRadAtCenter() * (M_PI/180) * (2.0));
painter.drawCircle(centerScreen[0], centerScreen[1], 0.5 * p
rojector->getPixelPerRadAtCenter() * (M_PI/180) * (4.0));
// // Direct drawing
// glDisable(GL_BLEND);
// glColor3f(0.f,0.f,0.f);
// glPushMatrix();
// glTranslated(params.viewportCenter[0], params.viewportCenter
[1], 0.0);
// GLUquadricObj *quadric = gluNewQuadric();
// // the gray circle
// glColor4f(0.77, 0.14, 0.16, 0.5);
// float radius = 0.5 * projector->getPixelPerRadAtCenter() * (
M_PI/180) * (0.5);
// gluDisk(quadric, radius - 1.0, radius, 256, 1);
// radius = 0.5 * projector->getPixelPerRadAtCenter() * (M_PI/1
80) * (2.0);
// gluDisk(quadric, radius - 1.0, radius, 256, 1);
// radius = 0.5 * projector->getPixelPerRadAtCenter() * (M_PI/1
80) * (4.0);
// gluDisk(quadric, radius - 1.0, radius, 256, 1);
// gluDeleteQuadric(quadric);
// glPopMatrix();
}
}
void Oculars::initializeActivationActions()
{ {
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", N_("Enable ocular"), "Ctrl+O ", "Plugin Key Bindings", true); gui->addGuiActions("actionShow_Ocular", N_("Enable ocular"), "Ctrl+O ", "Plugin Key Bindings", true);
gui->getGuiActions("actionShow_Ocular")->setChecked(flagShowOculars) ; gui->getGuiActions("actionShow_Ocular")->setChecked(flagShowOculars) ;
gui->addGuiActions("actionShow_Ocular_Crosshair", N_("Toggle Crossha ir"), "ALT+C", group, true); connect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(toggled(bool )), this, SLOT(enableOcular(bool)));
gui->addGuiActions("actionShow_Ocular_Window", N_("Configuration Win dow"), "ALT+O", group, true); gui->addGuiActions("actionShow_Ocular_Window", N_("Configuration Win dow"), "ALT+O", group, true);
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)));
gui->addGuiActions("actionShow_Ocular_Telrad", N_("Display Telrad"),
"Ctrl+B", group, true);
gui->getGuiActions("actionShow_Ocular_Telrad")->setChecked(flagShowT
elrad);
connect(gui->getGuiActions("actionShow_Ocular_Telrad"), SIGNAL(toggl
ed(bool)), this, SLOT(toggleTelrad()));
// Make a toolbar button
try {
pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png");
pxmapOnIcon = new QPixmap(":/ocular/bt_ocular_on.png");
pxmapOffIcon = new QPixmap(":/ocular/bt_ocular_off.png");
toolbarButton = new StelButton(NULL,
*
pxmapOnIcon,
*
pxmapOffIcon,
*
pxmapGlow,
g
ui->getGuiActions("actionShow_Ocular"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr
oup");
} catch (std::runtime_error& e) {
qWarning() << "WARNING: unable create toolbar button for Ocu
lars plugin: " << e.what();
}
}
void Oculars::initializeActions()
{
static bool actions_initialized;
if (actions_initialized)
return;
actions_initialized = true;
QString group = "Oculars Plugin";
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
Q_ASSERT(gui);
gui->addGuiActions("actionShow_Ocular_Crosshair", N_("Toggle Crossha
ir"), "ALT+C", group, true);
gui->addGuiActions("actionShow_CCD_increment", N_("Select next senso
r"), "Shift+Ctrl+]", group, false);
gui->addGuiActions("actionShow_CCD_decrement", N_("Select previous s
ensor"), "Shift+Ctrl+[", group, false);
gui->addGuiActions("actionShow_Ocular_increment", N_("Select next oc ular"), "Ctrl+]", group, false); gui->addGuiActions("actionShow_Ocular_increment", N_("Select next oc ular"), "Ctrl+]", group, false);
gui->addGuiActions("actionShow_Ocular_decrement", N_("Select previou s ocular"), "Ctrl+[", group, false); gui->addGuiActions("actionShow_Ocular_decrement", N_("Select previou s ocular"), "Ctrl+[", group, false);
gui->addGuiActions("actionShow_Telescope_increment", N_("Select next telescope"), "Shift+]", group, false); gui->addGuiActions("actionShow_Telescope_increment", N_("Select next telescope"), "Shift+]", group, false);
gui->addGuiActions("actionShow_Telescope_decrement", N_("Select prev ious telescope"), "Shift+[", group, false); gui->addGuiActions("actionShow_Telescope_decrement", N_("Select prev ious telescope"), "Shift+[", group, false);
connect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(toggled(bool )), this, SLOT(enableOcular(bool)));
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_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(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_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(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)));
// Make a toolbar button
try {
pxmapGlow = new QPixmap(":/graphicGui/gui/glow32x32.png");
pxmapOnIcon = new QPixmap(":/ocular/bt_ocular_on.png");
pxmapOffIcon = new QPixmap(":/ocular/bt_ocular_off.png");
toolbarButton = new StelButton(NULL,
*
pxmapOnIcon,
*
pxmapOffIcon,
*
pxmapGlow,
g
ui->getGuiActions("actionShow_Ocular"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr
oup");
} catch (std::runtime_error& e) {
qWarning() << "WARNING: unable create toolbar button for Ocu
lars plugin: " << e.what();
}
} }
// Return true if we're ready (could read all required data), false otherwi se
bool Oculars::initializeDB() bool Oculars::initializeDB()
{ {
bool result = false;
StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directo ry|StelFileMgr::Writable); StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directo ry|StelFileMgr::Writable);
QString dbPath = StelFileMgr::findFile("modules/Oculars/", flags); QString dbPath = StelFileMgr::findFile("modules/Oculars/", flags);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "oculars"); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "oculars");
db.setDatabaseName(dbPath + "oculars.sqlite"); db.setDatabaseName(dbPath + "oculars.sqlite");
if (db.open()) { if (db.open()) {
#define EXEC(sql) if (!query.exec(sql)) { qDebug() << query.lastError(); re turn false;}
qDebug() << "Oculars opened the DB successfully."; qDebug() << "Oculars opened the DB successfully.";
// See if the tables alreadt exist. // See if the tables alreadt exist.
QStringList tableList = db.tables(); QStringList tableList = db.tables();
if (!tableList.contains("oculars")) { if (!tableList.contains("oculars")) {
QSqlQuery query = QSqlQuery(db); QSqlQuery query = QSqlQuery(db);
query.exec("create table oculars (id INTEGER PRIMARY EXEC("create table oculars (id INTEGER PRIMARY KEY,
KEY, name VARCHAR, afov FLOAT, efl FLOAT, fieldStop FLOAT)"); name VARCHAR, afov FLOAT, efl FLOAT, fieldStop FLOAT)");
query.exec("INSERT INTO oculars (name, afov, efl, fi EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
eldStop) VALUES ('one', 43, 40, 0)"); p) VALUES ('one', 43, 40, 0)");
query.exec("INSERT INTO oculars (name, afov, efl, fi EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
eldStop) VALUES ('two', 82, 31, 0)"); p) VALUES ('two', 82, 31, 0)");
query.exec("INSERT INTO oculars (name, afov, efl, fi EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
eldStop) VALUES ('three', 52, 10.5, 0)"); p) VALUES ('three', 52, 10.5, 0)");
query.exec("INSERT INTO oculars (name, afov, efl, fi EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
eldStop) VALUES ('four', 52, 26, 0)"); p) VALUES ('four', 52, 26, 0)");
query.exec("INSERT INTO oculars (name, afov, efl, fi EXEC("INSERT INTO oculars (name, afov, efl, fieldSto
eldStop) VALUES ('five', 82, 20, 0)"); p) VALUES ('five', 82, 20, 0)");
} }
if (!tableList.contains("telescopes")) { if (!tableList.contains("telescopes")) {
QSqlQuery query = QSqlQuery(db); QSqlQuery query = QSqlQuery(db);
query.exec("create table telescopes (id INTEGER PRIM EXEC("create table telescopes (id INTEGER PRIMARY KE
ARY KEY, name VARCHAR, focalLength FLOAT, diameter FLOAT, vFlip VARCHAR, hF Y, name VARCHAR, focalLength FLOAT, diameter FLOAT, vFlip VARCHAR, hFlip VA
lip VARCHAR)"); RCHAR)");
query.exec("INSERT INTO telescopes (name, focalLengt EXEC("INSERT INTO telescopes (name, focalLength, dia
h, diameter, vFlip, hFlip) VALUES ('C1400', 3190, 355.6, 'false', 'true')") meter, vFlip, hFlip) VALUES ('C1400', 3190, 355.6, 'false', 'true')");
; EXEC("INSERT INTO telescopes (name, focalLength, dia
query.exec("INSERT INTO telescopes (name, focalLengt meter, vFlip, hFlip) VALUES ('80EDF', 500, 80, 'false', 'false')");
h, diameter, 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 // Set the table models
CCDsTableModel = new QSqlTableModel(0, db);
CCDsTableModel->setTable("ccd");
CCDsTableModel->select();
ocularsTableModel = new QSqlTableModel(0, db); ocularsTableModel = new QSqlTableModel(0, db);
ocularsTableModel->setTable("oculars"); ocularsTableModel->setTable("oculars");
ocularsTableModel->select(); if (!ocularsTableModel->select())
return false;
telescopesTableModel = new QSqlTableModel(0, db); telescopesTableModel = new QSqlTableModel(0, db);
telescopesTableModel->setTable("telescopes"); telescopesTableModel->setTable("telescopes");
telescopesTableModel->select(); if (!telescopesTableModel->select())
return false;
result = true; #undef EXEC
return true;
} else { } else {
qDebug() << "Oculars could not open its databse; disableing qDebug() << "Oculars could not open its database; disabling
module."; module.";
result = false;
} }
return result; 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::StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr::StelMovementMgr *movementManager = core->getMovemen StelMovementMgr *movementManager = core->getMovementMgr();
tMgr();
if (event->type() == QEvent::KeyPress) if (event->type() == QEvent::KeyPress)
{ {
// Direction and zoom deplacements // Direction and zoom replacements
switch (event->key()) switch (event->key())
{ {
case Qt::Key_Left: case Qt::Key_Left:
movementManager->turnLeft(true); movementManager->turnLeft(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Right: case Qt::Key_Right:
movementManager->turnRight(true); movementManager->turnRight(true);
consumeEvent = true; consumeEvent = true;
break; break;
skipping to change at line 684 skipping to change at line 776
event->accept(); event->accept();
} }
else else
{ {
event->setAccepted(false); event->setAccepted(false);
} }
} }
void Oculars::loadDatabaseObjects() void Oculars::loadDatabaseObjects()
{ {
loadCCDs();
loadOculars(); loadOculars();
loadTelescopes(); loadTelescopes();
if (useMaxImageCircle) { if (useMaxImageCircle) {
determineMaxImageCircle(); 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::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;
skipping to change at line 716 skipping to change at line 823
inner = oculars[selectedOcularIndex]->getExitCircle(telescop es[selectedTelescopeIndex]) * inner / maxImageCircle; inner = oculars[selectedOcularIndex]->getExitCircle(telescop es[selectedTelescopeIndex]) * inner / maxImageCircle;
} }
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
CCD *ccd = CCDs[selectedCCDIndex];
if (ccd) {
Ocular *ocular = oculars[selectedOcularIndex];
float CCDx = ccd->getActualFOVx(ocular);
float CCDy = ccd->getActualFOVy(ocular);
if (CCDx > 0.0 && CCDy > 0.0) {
glBegin(GL_LINE_LOOP);
glVertex2f(-CCDx, CCDy);
glVertex2f(CCDx, CCDy);
glVertex2f(CCDx, -CCDy);
glVertex2f(-CCDx, -CCDy);
glEnd();
}
}
glPopMatrix(); glPopMatrix();
} }
void Oculars::paintText(const StelCore* core)
{
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz)
;
StelPainter painter(prj);
// Get the current instruments
CCD *ccd = CCDs[selectedCCDIndex];
Ocular *ocular = oculars[selectedOcularIndex];
Telescope *telescope = telescopes[selectedTelescopeIndex];
// set up the color and the GL state
painter.setColor(0.8, 0.48, 0.0, 1);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
// Get the X & Y positions, and the line height
painter.setFont(font);
QString widthString = "MMMMMMMMMMMMMMMMMMM";
float insetFromRHS = painter.getFontMetrics().width(widthString);
StelProjector::StelProjectorParams projectorParams = core->getCurren
tStelProjectorParams();
int xPosition = projectorParams.viewportXywh[2];
xPosition -= insetFromRHS;
int yPosition = projectorParams.viewportXywh[3];
yPosition -= 40;
const int lineHeight = painter.getFontMetrics().height();
// The CCD
QString ccdSensorLabel, ccdInfoLabel;
if (ccd && ccd->getChipWidth() > .0 && ccd->getChipHeight() > .0) {
ccdInfoLabel = "Dimension : " + QVariant(ccd->getChipWidth()
).toString() + "x" + QVariant(ccd->getChipHeight()).toString() + " mm";
if (ccd->getName() != QString("")) {
ccdSensorLabel = "Sensor #" + QVariant(selectedCCDIn
dex).toString();
ccdSensorLabel.append(" : ").append(ccd->getName());
}
}
if (ccdSensorLabel != QString("")) {
painter.drawText(xPosition, yPosition, ccdSensorLabel);
yPosition-=lineHeight;
painter.drawText(xPosition, yPosition, ccdInfoLabel);
yPosition-=lineHeight;
}
// The Ocular
QString ocularNumberLabel = "Ocular #" + QVariant(selectedOcularInde
x).toString();
if (ocular->getName() != QString("")) {
ocularNumberLabel.append(" : ").append(ocular->getName());
}
painter.drawText(xPosition, yPosition, ocularNumberLabel);
yPosition-=lineHeight;
QString ocularFLLabel = "Ocular FL: " + QVariant(ocular->getEffectiv
eFocalLength()).toString() + QChar(0x00B0);
painter.drawText(xPosition, yPosition, ocularFLLabel);
yPosition-=lineHeight;
QString ocularFOVLabel = "Ocular aFOV: " + QVariant(ocular->getAppea
rentFOV()).toString() + QChar(0x00B0);
painter.drawText(xPosition, yPosition, ocularFOVLabel);
yPosition-=lineHeight;
// The telescope
QString telescopeNumberLabel = "Telescope #" + QVariant(selectedTele
scopeIndex).toString();
if (telescope->getName() != QString("")) {
telescopeNumberLabel.append(" : ").append(telescope->getName
());
}
painter.drawText(xPosition, yPosition, telescopeNumberLabel);
yPosition-=lineHeight;
// General info
QString magnificationLabel = "Magnification: " + QVariant(((int)(ocu
lar->getMagnification(telescope) * 10.0)) / 10.0).toString() + "x";
painter.drawText(xPosition, yPosition, magnificationLabel);
yPosition-=lineHeight;
QString imageCircleLabel = "Image Circle: " + QVariant(((int)(ocular
->getExitCircle(telescope) * 10.0)) / 10.0).toString() + "mm";
painter.drawText(xPosition, yPosition, imageCircleLabel);
yPosition-=lineHeight;
QString fovLabel = "FOV: " + QVariant(((int)(ocular->getActualFOV(te
lescope) * 10000.00)) / 10000.0).toString() + QChar(0x00B0);
painter.drawText(xPosition, yPosition, fovLabel);
}
void Oculars::validateIniFile() void Oculars::validateIniFile()
{ {
// 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()) {
skipping to change at line 746 skipping to change at line 948
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
<< " to old to use; required version is " << MIN_OCULARS_INI_VERSION << ". Coping over new one."; << " too old to use; require d version is " << MIN_OCULARS_INI_VERSION << ". Copying over new one.";
// delete last "old" file, if it exists // delete last "old" file, if it exists
QFile deleteFile(ocularIniPath + ".old"); QFile deleteFile(ocularIniPath + ".old");
deleteFile.remove(); deleteFile.remove();
// Rename the old one, and copy over a new one // Rename the old one, and copy over a new one
QFile oldFile(ocularIniPath); QFile oldFile(ocularIniPath);
if (!oldFile.rename(ocularIniPath + ".old")) { if (!oldFile.rename(ocularIniPath + ".old")) {
qWarning() << "Oculars::validateIniFile cann ot move ocular.ini resource to ocular.ini.old at path " + 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 774 skipping to change at line 976
QFile dest(ocularIniPath); QFile dest(ocularIniPath);
dest.setPermissions(dest.permissions () | QFile::WriteOwner); dest.setPermissions(dest.permissions () | QFile::WriteOwner);
} }
} }
} }
} }
} }
void Oculars::unzoomOcular() void Oculars::unzoomOcular()
{ {
StelCore::StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr::StelMovementMgr *movementManager = core->getMovemen StelMovementMgr *movementManager = core->getMovementMgr();
tMgr(); GridLinesMgr *gridManager = (GridLinesMgr *)StelApp::getInstance().g
GridLinesMgr::GridLinesMgr *gridManager = (GridLinesMgr *)StelApp::g etModuleMgr().getModule("GridLinesMgr");
etInstance().getModuleMgr().getModule("GridLinesMgr");
gridManager->setFlagAzimuthalGrid(flagAzimuthalGrid); gridManager->setFlagAzimuthalGrid(flagAzimuthalGrid);
gridManager->setFlagEquatorGrid(flagEquatorGrid); gridManager->setFlagEquatorGrid(flagEquatorGrid);
gridManager->setFlagEquatorJ2000Grid(flagEquatorJ2000Grid); gridManager->setFlagEquatorJ2000Grid(flagEquatorJ2000Grid);
gridManager->setFlagEquatorLine(flagEquatorLine); gridManager->setFlagEquatorLine(flagEquatorLine);
gridManager->setFlagEclipticLine(flagEclipticLine); gridManager->setFlagEclipticLine(flagEclipticLine);
gridManager->setFlagMeridianLine(flagMeridianLine); gridManager->setFlagMeridianLine(flagMeridianLine);
movementManager->setFlagTracking(false); movementManager->setFlagTracking(false);
movementManager->setFlagEnableZoomKeys(true); movementManager->setFlagEnableZoomKeys(true);
movementManager->setFlagEnableMouseNavigation(true); movementManager->setFlagEnableMouseNavigation(true);
skipping to change at line 798 skipping to change at line 1000
// Set the screen display // Set the screen display
// core->setMaskType(StelProjector::MaskNone); // core->setMaskType(StelProjector::MaskNone);
core->setFlipHorz(false); core->setFlipHorz(false);
core->setFlipVert(false); core->setFlipVert(false);
movementManager->zoomTo(movementManager->getInitFov()); movementManager->zoomTo(movementManager->getInitFov());
} }
void Oculars::zoom(bool rezoom) void Oculars::zoom(bool rezoom)
{ {
if (flagShowOculars) { if (flagShowOculars) {
if (!rezoom) { if (!rezoom) {
GridLinesMgr::GridLinesMgr *gridManager = (GridLines Mgr *)StelApp::getInstance().getModuleMgr().getModule("GridLinesMgr"); GridLinesMgr *gridManager = (GridLinesMgr *)StelApp: :getInstance().getModuleMgr().getModule("GridLinesMgr");
// Current state // Current state
flagAzimuthalGrid = gridManager->getFlagAzimuthalGri d(); flagAzimuthalGrid = gridManager->getFlagAzimuthalGri d();
flagEquatorGrid = gridManager->getFlagEquatorGrid(); flagEquatorGrid = gridManager->getFlagEquatorGrid();
flagEquatorJ2000Grid = gridManager->getFlagEquatorJ2 000Grid(); flagEquatorJ2000Grid = gridManager->getFlagEquatorJ2 000Grid();
flagEquatorLine = gridManager->getFlagEquatorLine(); flagEquatorLine = gridManager->getFlagEquatorLine();
flagEclipticLine = gridManager->getFlagEclipticLine( ); flagEclipticLine = gridManager->getFlagEclipticLine( );
flagMeridianLine = gridManager->getFlagMeridianLine( ); flagMeridianLine = gridManager->getFlagMeridianLine( );
} }
// set new state // set new state
zoomOcular(); zoomOcular();
} else { } else {
//reset to original state //reset to original state
unzoomOcular(); unzoomOcular();
} }
} }
void Oculars::zoomOcular() void Oculars::zoomOcular()
{ {
StelCore::StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr::StelMovementMgr *movementManager = core->getMovemen StelMovementMgr *movementManager = core->getMovementMgr();
tMgr(); GridLinesMgr *gridManager =
GridLinesMgr::GridLinesMgr *gridManager =
(GridLinesMgr *)StelApp::getInstance().getModuleMgr().getMod ule("GridLinesMgr"); (GridLinesMgr *)StelApp::getInstance().getModuleMgr().getMod ule("GridLinesMgr");
gridManager->setFlagAzimuthalGrid(false); gridManager->setFlagAzimuthalGrid(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->setFlagMeridianLine(false); gridManager->setFlagMeridianLine(false);
movementManager->setFlagTracking(true); movementManager->setFlagTracking(true);
movementManager->setFlagEnableZoomKeys(false); movementManager->setFlagEnableZoomKeys(false);
movementManager->setFlagEnableMouseNavigation(false); movementManager->setFlagEnableMouseNavigation(false);
// We won't always have a selected object // We won't always have a selected object
if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) { if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) {
movementManager-> movementManager->
moveToJ2000(StelApp::getInstance().getStelObjectMgr( ).getSelectedObject()[0]->getEquinoxEquatorialPos(core->getNavigator()), moveToJ2000(StelApp::getInstance().getStelObjectMgr( ).getSelectedObject()[0]->getEquinoxEquatorialPos(core->getNavigator()),
0.5, 0.0,
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->getAcutalFOV(telescope); double actualFOV = ocular->getActualFOV(telescope);
// See if the mask was scaled // See if the mask was scaled; if so, correct the actualFOV.
if (maxImageCircle > 0.0 && ocular->getExitCircle(telescope) > 0.0) if (useMaxImageCircle && ocular->getExitCircle(telescope) > 0.0) {
{
actualFOV = maxImageCircle * actualFOV / ocular->getExitCirc le(telescope); actualFOV = maxImageCircle * actualFOV / ocular->getExitCirc le(telescope);
} }
movementManager->zoomTo(actualFOV, 0.0); movementManager->zoomTo(actualFOV, 0.0);
} }
 End of changes. 65 change blocks. 
196 lines changed or deleted 425 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/