Oculars.cpp   Oculars.cpp 
skipping to change at line 41 skipping to change at line 41
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelMainView.hpp" #include "StelMainView.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp"
#include <QAction> #include <QAction>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu> #include <QMenu>
#include <QMouseEvent> #include <QMouseEvent>
#include <QtNetwork> #include <QtNetwork>
#include <QPixmap> #include <QPixmap>
skipping to change at line 150 skipping to change at line 151
actionConfiguration(0), actionConfiguration(0),
actionMenu(0), actionMenu(0),
actionTelescopeIncrement(0), actionTelescopeIncrement(0),
actionTelescopeDecrement(0), actionTelescopeDecrement(0),
actionOcularIncrement(0), actionOcularIncrement(0),
actionOcularDecrement(0), actionOcularDecrement(0),
guiPanel(0), guiPanel(0),
actualFOV(0), actualFOV(0),
initialFOV(0), initialFOV(0),
flagInitFOVUsage(false), flagInitFOVUsage(false),
flagUseFlipForCCD(false),
reticleRotation(0) reticleRotation(0)
{ {
// Font size is 14 // Font size is 14
font.setPixelSize(StelApp::getInstance().getBaseFontSize()+1); font.setPixelSize(StelApp::getInstance().getBaseFontSize()+1);
ccds = QList<CCD *>(); ccds = QList<CCD *>();
oculars = QList<Ocular *>(); oculars = QList<Ocular *>();
telescopes = QList<Telescope *>(); telescopes = QList<Telescope *>();
lense = QList<Lens *> (); lense = QList<Lens *> ();
skipping to change at line 343 skipping to change at line 345
{ {
order = GETSTELMODULE(LabelMgr)->getCallOrder(actionName) + 100.0; order = GETSTELMODULE(LabelMgr)->getCallOrder(actionName) + 100.0;
} }
return order; return order;
} }
const StelStyle Oculars::getModuleStyleSheet(const StelStyle& style) const StelStyle Oculars::getModuleStyleSheet(const StelStyle& style)
{ {
StelStyle pluginStyle(style); StelStyle pluginStyle(style);
if (style.confSectionName == "color") { if (StelApp::getInstance().getVisionModeNight()) {
pluginStyle.qtStyleSheet.append(normalStyleSheet);
} else{
pluginStyle.qtStyleSheet.append(nightStyleSheet); pluginStyle.qtStyleSheet.append(nightStyleSheet);
} else{
pluginStyle.qtStyleSheet.append(normalStyleSheet);
} }
return pluginStyle; return pluginStyle;
} }
void Oculars::handleMouseClicks(class QMouseEvent* event) void Oculars::handleMouseClicks(class QMouseEvent* event)
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
if (StelApp::getInstance().getStelObjectMgr().getWasSelected()){ if (StelApp::getInstance().getStelObjectMgr().getWasSelected()){
if (flagShowOculars) { if (flagShowOculars) {
skipping to change at line 385 skipping to change at line 387
{ {
if (!flagShowOculars && !flagShowCCD) { if (!flagShowOculars && !flagShowCCD) {
return; return;
} }
// We onle care about the arrow keys. This flag tracks that. // We onle care about the arrow keys. This flag tracks that.
bool consumeEvent = false; bool consumeEvent = false;
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
if (event->type() == QEvent::KeyPress) if (event->type() == QEvent::KeyPress) {
{
// Direction and zoom replacements // Direction and zoom replacements
switch (event->key()) switch (event->key()) {
{
case Qt::Key_Left: case Qt::Key_Left:
movementManager->turnLeft(true); movementManager->turnLeft(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Right: case Qt::Key_Right:
movementManager->turnRight(true); movementManager->turnRight(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Up: case Qt::Key_Up:
if (!event->modifiers().testFlag(Qt::Control Modifier)) if (!event->modifiers().testFlag(Qt::Control Modifier))
skipping to change at line 426 skipping to change at line 426
case Qt::Key_PageDown: case Qt::Key_PageDown:
movementManager->zoomOut(true); movementManager->zoomOut(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Shift: case Qt::Key_Shift:
movementManager->moveSlow(true); movementManager->moveSlow(true);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_M: case Qt::Key_M:
double multiplier = 1.0; double multiplier = 1.0;
if (event->modifiers().testFlag(Qt::ControlM if (event->modifiers().testFlag(Qt::ControlM
odifier)) odifier)) {
{
multiplier = 0.1; multiplier = 0.1;
} }
if (event->modifiers().testFlag(Qt::AltModif if (event->modifiers().testFlag(Qt::AltModif
ier)) ier)) {
{
multiplier = 5.0; multiplier = 5.0;
} }
if (event->modifiers().testFlag(Qt::ShiftMod if (event->modifiers().testFlag(Qt::ShiftMod
ifier)) ifier)) {
{
reticleRotation += (1.0 * multiplier ); reticleRotation += (1.0 * multiplier );
} else { } else {
reticleRotation -= (1.0 * multiplier ); reticleRotation -= (1.0 * multiplier );
} }
qDebug() << reticleRotation; qDebug() << reticleRotation;
consumeEvent = true; consumeEvent = true;
break; break;
} }
} else { } else {
// When a deplacement key is released stop mooving // When a deplacement key is released stop mooving
switch (event->key()) switch (event->key()) {
{
case Qt::Key_Left: case Qt::Key_Left:
movementManager->turnLeft(false); movementManager->turnLeft(false);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Right: case Qt::Key_Right:
movementManager->turnRight(false); movementManager->turnRight(false);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Up: case Qt::Key_Up:
movementManager->turnUp(false); movementManager->turnUp(false);
skipping to change at line 477 skipping to change at line 473
break; break;
case Qt::Key_PageDown: case Qt::Key_PageDown:
movementManager->zoomOut(false); movementManager->zoomOut(false);
consumeEvent = true; consumeEvent = true;
break; break;
case Qt::Key_Shift: case Qt::Key_Shift:
movementManager->moveSlow(false); movementManager->moveSlow(false);
consumeEvent = true; consumeEvent = true;
break; break;
} }
if (consumeEvent) if (consumeEvent) {
{
// We don't want to re-center the object; just hold the current position. // We don't want to re-center the object; just hold the current position.
movementManager->setFlagLockEquPos(true); movementManager->setFlagLockEquPos(true);
} }
} }
if (consumeEvent) if (consumeEvent) {
{
event->accept(); event->accept();
} else { } else {
event->setAccepted(false); event->setAccepted(false);
} }
} }
void Oculars::init() void Oculars::init()
{ {
qDebug() << "Ocular plugin - press Command-O to toggle eyepiece view mode. Press ALT-o for configuration."; qDebug() << "Ocular plugin - press Command-O to toggle eyepiece view mode. Press ALT-o for configuration.";
skipping to change at line 586 skipping to change at line 580
ocularDialog = new OcularDialog(this, &ccds, &oculars, &tele scopes, &lense); ocularDialog = new OcularDialog(this, &ccds, &oculars, &tele scopes, &lense);
initializeActivationActions(); initializeActivationActions();
determineMaxEyepieceAngle(); determineMaxEyepieceAngle();
guiPanelEnabled = settings->value("enable_control_panel", fa lse).toBool(); guiPanelEnabled = settings->value("enable_control_panel", fa lse).toBool();
enableGuiPanel(guiPanelEnabled); enableGuiPanel(guiPanelEnabled);
setFlagDecimalDegrees(settings->value("use_decimal_degrees", false).toBool()); setFlagDecimalDegrees(settings->value("use_decimal_degrees", false).toBool());
setFlagLimitMagnitude(settings->value("limit_stellar_magnitu de", true).toBool()); setFlagLimitMagnitude(settings->value("limit_stellar_magnitu de", true).toBool());
setFlagInitFovUsage(settings->value("use_initial_fov", false ).toBool()); setFlagInitFovUsage(settings->value("use_initial_fov", false ).toBool());
setFlagUseFlipForCCD(settings->value("use_ccd_flip", false). toBool());
} catch (std::runtime_error& e) { } catch (std::runtime_error& e) {
qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what(); qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what();
ready = false; ready = false;
} }
//Load the module's custom style sheets //Load the module's custom style sheets
QFile styleSheetFile; QFile styleSheetFile;
styleSheetFile.setFileName(":/ocular/normalStyle.css"); styleSheetFile.setFileName(":/ocular/normalStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) { if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) {
normalStyleSheet = styleSheetFile.readAll(); normalStyleSheet = styleSheetFile.readAll();
skipping to change at line 927 skipping to change at line 922
selectedLensIndex = -1; selectedLensIndex = -1;
} }
if (selectedLensIndex == -2) { if (selectedLensIndex == -2) {
selectedLensIndex = lense.count() - 1; selectedLensIndex = lense.count() - 1;
} }
emit(selectedLensChanged()); emit(selectedLensChanged());
} }
void Oculars::displayPopupMenu() void Oculars::displayPopupMenu()
{ {
QMenu* popup = new QMenu(&StelMainView::getInstance()); QMenu * popup = new QMenu(&StelMainView::getInstance());
StelGui * gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui
());
Q_ASSERT(gui);
qDebug() <<this->getModuleStyleSheet(gui->getStelStyle()).qtStyleShe
et;
popup->setStyleSheet(this->getModuleStyleSheet(gui->getStelStyle()).
qtStyleSheet);
if (flagShowOculars) if (flagShowOculars) {
{
// We are in Oculars mode // We are in Oculars mode
// We want to show all of the Oculars, and if the current oc ular is not a binocular, // We want to show all of the Oculars, and if the current oc ular is not a binocular,
// we will also show the telescopes. // we will also show the telescopes.
if (!oculars.isEmpty()) if (!oculars.isEmpty()) {
{
popup->addAction(q_("&Previous ocular"), this, SLOT( decrementOcularIndex())); popup->addAction(q_("&Previous ocular"), this, SLOT( decrementOcularIndex()));
popup->addAction(q_("&Next ocular"), this, SLOT(incr ementOcularIndex())); popup->addAction(q_("&Next ocular"), this, SLOT(incr ementOcularIndex()));
QMenu* submenu = new QMenu(q_("Select &ocular"), pop up); QMenu* submenu = new QMenu(q_("Select &ocular"), pop up);
int availableOcularCount = 0; int availableOcularCount = 0;
for (int index = 0; index < oculars.count(); ++index for (int index = 0; index < oculars.count(); ++index
) ) {
{
QString label; QString label;
if (availableOcularCount < 10) if (availableOcularCount < 10) {
{
label = QString("&%1: %2").arg(avail ableOcularCount).arg(oculars[index]->name()); label = QString("&%1: %2").arg(avail ableOcularCount).arg(oculars[index]->name());
} } else {
else
{
label = oculars[index]->name(); label = oculars[index]->name();
} }
//BM: Does this happen at all any more? //BM: Does this happen at all any more?
QAction* action = 0; QAction* action = 0;
if (selectedTelescopeIndex == -1) { if (selectedTelescopeIndex == -1) {
if (oculars[index]->isBinoculars()) { if (oculars[index]->isBinoculars()) {
action = submenu->addAction( label, ocularsSignalMapper, SLOT(map())); action = submenu->addAction( label, ocularsSignalMapper, SLOT(map()));
availableOcularCount++; availableOcularCount++;
ocularsSignalMapper->setMapp ing(action, QString("%1").arg(index)); ocularsSignalMapper->setMapp ing(action, QString("%1").arg(index));
} }
} else { } else {
action = submenu->addAction(label, o cularsSignalMapper, SLOT(map())); action = submenu->addAction(label, o cularsSignalMapper, SLOT(map()));
availableOcularCount++; availableOcularCount++;
ocularsSignalMapper->setMapping(acti on, QString("%1").arg(index)); ocularsSignalMapper->setMapping(acti on, QString("%1").arg(index));
} }
if (action && index == selectedOcularIndex) if (action && index == selectedOcularIndex)
{ {
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
} }
} }
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
// If there is more than one telescope, show the prev/next/l ist complex. // If there is more than one telescope, show the prev/next/l ist complex.
// If the selected ocular is a binoculars, show nothing. // If the selected ocular is a binoculars, show nothing.
if (telescopes.count() > 1 && (selectedOcularIndex > -1 && ! if (telescopes.count() > 1 && (selectedOcularIndex > -1 && !
oculars[selectedOcularIndex]->isBinoculars())) oculars[selectedOcularIndex]->isBinoculars())) {
{
QMenu* submenu = addTelescopeSubmenu(popup); QMenu* submenu = addTelescopeSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
submenu = addLensSubmenu(popup); submenu = addLensSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
QAction* action = popup->addAction(q_("Toggle &crosshair")); QAction* action = popup->addAction(q_("Toggle &crosshair"));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(flagShowCrosshairs); action->setChecked(flagShowCrosshairs);
skipping to change at line 1015 skipping to change at line 1006
} }
if (!flagShowCCD) { if (!flagShowCCD) {
QAction* action = popup->addAction(q_("Toggle &Telra d")); QAction* action = popup->addAction(q_("Toggle &Telra d"));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(flagShowTelrad); action->setChecked(flagShowTelrad);
connect(action, SIGNAL(toggled(bool)), actionShowTel rad, SLOT(setChecked(bool))); connect(action, SIGNAL(toggled(bool)), actionShowTel rad, SLOT(setChecked(bool)));
} }
popup->addSeparator(); popup->addSeparator();
if (flagShowCCD && selectedCCDIndex > -1 && selectedTelescop if (flagShowCCD && selectedCCDIndex > -1 && selectedTelescop
eIndex > -1) eIndex > -1) {
{
popup->addAction(q_("&Previous CCD"), this, SLOT(dec rementCCDIndex())); popup->addAction(q_("&Previous CCD"), this, SLOT(dec rementCCDIndex()));
popup->addAction(q_("&Next CCD"), this, SLOT(increme ntCCDIndex())); popup->addAction(q_("&Next CCD"), this, SLOT(increme ntCCDIndex()));
QMenu* submenu = new QMenu(q_("&Select CCD"), popup) ; QMenu* submenu = new QMenu(q_("&Select CCD"), popup) ;
for (int index = 0; index < ccds.count(); ++index) for (int index = 0; index < ccds.count(); ++index) {
{
QString label; QString label;
if (index < 10) if (index < 10) {
{
label = QString("&%1: %2").arg(index ).arg(ccds[index]->name()); label = QString("&%1: %2").arg(index ).arg(ccds[index]->name());
} } else {
else
{
label = ccds[index]->name(); label = ccds[index]->name();
} }
QAction* action = submenu->addAction(label, ccdsSignalMapper, SLOT(map())); QAction* action = submenu->addAction(label, ccdsSignalMapper, SLOT(map()));
if (index == selectedCCDIndex) if (index == selectedCCDIndex) {
{
action->setCheckable(true); action->setCheckable(true);
action->setChecked(true); action->setChecked(true);
} }
ccdsSignalMapper->setMapping(action, QString ("%1").arg(index)); ccdsSignalMapper->setMapping(action, QString ("%1").arg(index));
} }
popup->addMenu(submenu); popup->addMenu(submenu);
submenu = new QMenu(q_("&Rotate CCD"), popup); submenu = new QMenu(q_("&Rotate CCD"), popup);
QAction* rotateAction = NULL; QAction* rotateAction = NULL;
rotateAction = submenu->addAction(QString("&1: -90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map())); rotateAction = submenu->addAction(QString("&1: -90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
skipping to change at line 1068 skipping to change at line 1053
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("15")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("15"));
rotateAction = submenu->addAction(QString("&9: +45") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map())); rotateAction = submenu->addAction(QString("&9: +45") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("45")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("45"));
rotateAction = submenu->addAction(QString("&0: +90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map())); rotateAction = submenu->addAction(QString("&0: +90") + QChar(0x00B0), ccdRotationSignalMapper, SLOT(map()));
ccdRotationSignalMapper->setMapping(rotateAction, QS tring("90")); ccdRotationSignalMapper->setMapping(rotateAction, QS tring("90"));
rotateAction = submenu->addAction(q_("&Reset rotatio n"), this, SLOT(ccdRotationReset())); rotateAction = submenu->addAction(q_("&Reset rotatio n"), this, SLOT(ccdRotationReset()));
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
if (flagShowCCD && selectedCCDIndex > -1 && telescopes.count if (flagShowCCD && selectedCCDIndex > -1 && telescopes.count
() > 1) () > 1) {
{
QMenu* submenu = addTelescopeSubmenu(popup); QMenu* submenu = addTelescopeSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
submenu = addLensSubmenu(popup); submenu = addLensSubmenu(popup);
popup->addMenu(submenu); popup->addMenu(submenu);
popup->addSeparator(); popup->addSeparator();
} }
} }
popup->exec(QCursor::pos()); popup->exec(QCursor::pos());
delete popup; delete popup;
skipping to change at line 1214 skipping to change at line 1198
selectedCCDIndex = -1; selectedCCDIndex = -1;
show = false; show = false;
if (actionShowSensor->isChecked()) { if (actionShowSensor->isChecked()) {
actionShowSensor->setChecked(false); actionShowSensor->setChecked(false);
} }
} }
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
StelMovementMgr *movementManager = core->getMovementMgr(); StelMovementMgr *movementManager = core->getMovementMgr();
if (show) { if (show) {
initialFOV = movementManager->getCurrentFov();
//Mutually exclusive with the ocular mode //Mutually exclusive with the ocular mode
hideUsageMessageIfDisplayed(); hideUsageMessageIfDisplayed();
if (flagShowOculars) { if (flagShowOculars) {
if (actionShowOcular->isChecked()) { if (actionShowOcular->isChecked()) {
actionShowOcular->setChecked(false); actionShowOcular->setChecked(false);
} }
} }
if (flagShowTelrad) { if (flagShowTelrad) {
if (actionShowTelrad->isChecked()) { if (actionShowTelrad->isChecked()) {
skipping to change at line 1236 skipping to change at line 1221
} }
if (selectedTelescopeIndex < 0) { if (selectedTelescopeIndex < 0) {
selectedTelescopeIndex = 0; selectedTelescopeIndex = 0;
} }
if (selectedCCDIndex < 0) { if (selectedCCDIndex < 0) {
selectedCCDIndex = 0; selectedCCDIndex = 0;
} }
flagShowCCD = true; flagShowCCD = true;
setScreenFOVForCCD(); setScreenFOVForCCD();
movementManager->setFlagEnableZoomKeys(false);
movementManager->setFlagEnableMouseNavigation(false);
if (guiPanel) { if (guiPanel) {
guiPanel->showCcdGui(); guiPanel->showCcdGui();
} }
} else { } else {
flagShowCCD = false; flagShowCCD = false;
//Zoom out
movementManager->zoomTo(movementManager->getInitFov());
movementManager->setFlagTracking(false); movementManager->setFlagTracking(false);
movementManager->setFlagEnableZoomKeys(true); //Zoom out
movementManager->setFlagEnableMouseNavigation(true); if (getFlagInitFovUsage())
core->setFlipHorz(false); movementManager->zoomTo(movementManager->getInitFov(
core->setFlipVert(false); ));
else
movementManager->zoomTo(initialFOV);
if (getFlagUseFlipForCCD())
{
core->setFlipHorz(false);
core->setFlipVert(false);
}
if (guiPanel) { if (guiPanel) {
guiPanel->foldGui(); guiPanel->foldGui();
} }
} }
} }
void Oculars::toggleCCD() void Oculars::toggleCCD()
{ {
if (flagShowCCD) { if (flagShowCCD) {
skipping to change at line 1389 skipping to change at line 1377
const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu); const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu);
double screenFOV = params.fov; double screenFOV = params.fov;
// draw sensor rectangle // draw sensor rectangle
if(selectedCCDIndex != -1) { if(selectedCCDIndex != -1) {
CCD *ccd = ccds[selectedCCDIndex]; CCD *ccd = ccds[selectedCCDIndex];
if (ccd) { if (ccd) {
StelPainter painter(projector); StelPainter painter(projector);
painter.setColor(0.77f, 0.14f, 0.16f, 1.0f); painter.setColor(0.77f, 0.14f, 0.16f, 1.0f);
Telescope *telescope = telescopes[selectedTelescopeI ndex]; Telescope *telescope = telescopes[selectedTelescopeI ndex];
// flip are needed?
core->setFlipHorz(telescope->isHFlipped());
core->setFlipVert(telescope->isVFlipped());
const double ccdXRatio = ccd->getActualFOVx(telescop e, lens) / screenFOV; const double ccdXRatio = ccd->getActualFOVx(telescop e, lens) / screenFOV;
const double ccdYRatio = ccd->getActualFOVy(telescop e, lens) / screenFOV; const double ccdYRatio = ccd->getActualFOVy(telescop e, lens) / screenFOV;
// flip are needed and allowed?
float ratioLimit = 0.125f;
if (getFlagUseFlipForCCD() && (ccdXRatio>=ratioLimit
|| ccdYRatio>=ratioLimit))
{
core->setFlipHorz(telescope->isHFlipped());
core->setFlipVert(telescope->isVFlipped());
}
else
{
core->setFlipHorz(false);
core->setFlipVert(false);
}
// As the FOV is based on the narrow aspect of the s creen, we need to calculate // As the FOV is based on the narrow aspect of the s creen, we need to calculate
// height & width based soley off of that dimension. // height & width based soley off of that dimension.
int aspectIndex = 2; int aspectIndex = 2;
if (params.viewportXywh[2] > params.viewportXywh[3]) { if (params.viewportXywh[2] > params.viewportXywh[3]) {
aspectIndex = 3; aspectIndex = 3;
} }
float width = params.viewportXywh[aspectIndex] * ccd YRatio * params.devicePixelsPerPixel; float width = params.viewportXywh[aspectIndex] * ccd YRatio * params.devicePixelsPerPixel;
float height = params.viewportXywh[aspectIndex] * cc dXRatio * params.devicePixelsPerPixel; float height = params.viewportXywh[aspectIndex] * cc dXRatio * params.devicePixelsPerPixel;
if (width > 0.0 && height > 0.0) { if (width > 0.0 && height > 0.0) {
QPoint a, b; QPoint a, b;
QTransform transform = QTransform().translat QTransform transform = QTransform().translat
e(params.viewportCenter[0], params.viewportCenter[1]).rotate(-ccdRotationAn e(params.viewportCenter[0] * params.devicePixelsPerPixel,
gle); params.viewportCenter[1] * p
arams.devicePixelsPerPixel).rotate(-ccdRotationAngle);
// bottom line // bottom line
a = transform.map(QPoint(-width/2.0, -height /2.0)); a = transform.map(QPoint(-width/2.0, -height /2.0));
b = transform.map(QPoint(width/2.0, -height/ 2.0)); b = transform.map(QPoint(width/2.0, -height/ 2.0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
// top line // top line
a = transform.map(QPoint(-width/2.0, height/ 2.0)); a = transform.map(QPoint(-width/2.0, height/ 2.0));
b = transform.map(QPoint(width/2.0, height/2 .0)); b = transform.map(QPoint(width/2.0, height/2 .0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
// left line // left line
a = transform.map(QPoint(-width/2.0, -height /2.0)); a = transform.map(QPoint(-width/2.0, -height /2.0));
b = transform.map(QPoint(-width/2.0, height/ 2.0)); b = transform.map(QPoint(-width/2.0, height/ 2.0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
// right line // right line
a = transform.map(QPoint(width/2.0, height/2 .0)); a = transform.map(QPoint(width/2.0, height/2 .0));
b = transform.map(QPoint(width/2.0, -height/ 2.0)); b = transform.map(QPoint(width/2.0, -height/ 2.0));
painter.drawLine2d(a.x(), a.y(), b.x(), b.y( )); painter.drawLine2d(a.x(), a.y(), b.x(), b.y( ));
// Tool for planning a mosaic astrophotograp
hy: shows a small cross at center of CCD's
// frame and equatorial coordinates for epoc
h J2000.0 of that center.
// Details: https://bugs.launchpad.net/stell
arium/+bug/1404695
ratioLimit = 0.25f;
if (ccdXRatio>=ratioLimit || ccdYRatio>=rati
oLimit)
{
// draw cross at center
float cross = width>height ? height/
50.f : width/50.f;
a = transform.map(QPoint(0.f, -cross
));
b = transform.map(QPoint(0.f, cross)
);
painter.drawLine2d(a.x(), a.y(), b.x
(), b.y());
a = transform.map(QPoint(-cross, 0.f
));
b = transform.map(QPoint(cross, 0.f)
);
painter.drawLine2d(a.x(), a.y(), b.x
(), b.y());
// calculate coordinates of the cent
er and show it
Vec3d centerPosition;
Vec2f center = projector->getViewpor
tCenter();
projector->unProject(center[0], cent
er[1], centerPosition);
double cx, cy;
QString cxt, cyt;
StelUtils::rectToSphe(&cx,&cy,core->
equinoxEquToJ2000(centerPosition)); // Calculate RA/DE (J2000.0) and show i
t...
bool withDecimalDegree = dynamic_cas
t<StelGui*>(StelApp::getInstance().getGui())->getFlagShowDecimalDegrees();
if (withDecimalDegree)
{
cxt = StelUtils::radToDecDeg
Str(cx, 5, false, true);
cyt = StelUtils::radToDecDeg
Str(cy);
}
else
{
cxt = StelUtils::radToHmsStr
(cx, true);
cyt = StelUtils::radToDmsStr
(cy, true);
}
QString coords = QString("%1: %2/%3"
).arg(qc_("RA/Dec (J2000.0) of cross", "abbreviated in the plugin")).arg(cx
t).arg(cyt);
a = transform.map(QPoint(-width/2.0,
height/2.0 + 5.f));
painter.drawText(a.x(), a.y(), coord
s, -ccdRotationAngle);
}
} }
} }
} }
} }
void Oculars::paintCrosshairs() void Oculars::paintCrosshairs()
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu); const StelProjectorP projector = core->getProjection(StelCore::Frame EquinoxEqu);
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
// Center of screen // Center of screen
Vec2i centerScreen(projector->getViewportPosX()+projector->getViewpo rtWidth()/2, Vec2i centerScreen(projector->getViewportPosX()+projector->getViewpo rtWidth()/2,
projector->getViewportPosY()+proj ector->getViewportHeight()/2); projector->getViewportPosY()+proj ector->getViewportHeight()/2);
GLdouble length = 0.5 * params.viewportFovDiameter; float length = 0.5 * params.viewportFovDiameter;
// See if we need to scale the length // See if we need to scale the length
if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO V() > 0.0) { if (useMaxEyepieceAngle && oculars[selectedOcularIndex]->appearentFO V() > 0.0) {
length = oculars[selectedOcularIndex]->appearentFOV() * leng th / maxEyepieceAngle; length = oculars[selectedOcularIndex]->appearentFOV() * leng th / maxEyepieceAngle;
} }
length *= params.devicePixelsPerPixel; length *= params.devicePixelsPerPixel;
// Draw the lines // Draw the lines
StelPainter painter(projector); StelPainter painter(projector);
painter.setColor(0.77, 0.14, 0.16, 1); painter.setColor(0.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);
skipping to change at line 1475 skipping to change at line 1513
} }
} }
void Oculars::paintOcularMask(const StelCore *core) void Oculars::paintOcularMask(const StelCore *core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ; const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ;
StelPainter painter(prj); StelPainter painter(prj);
StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams(); StelProjector::StelProjectorParams params = core->getCurrentStelProj ectorParams();
// Draw the ocular outline, as GLUT is not working
painter.setColor(0.0, 0.5, 0.25, 1.0);
double inner = 0.5 * params.viewportFovDiameter * params.devicePixel sPerPixel; double inner = 0.5 * params.viewportFovDiameter * params.devicePixel sPerPixel;
// See if we need to scale the mask // See if we need to scale the mask
if (useMaxEyepieceAngle if (useMaxEyepieceAngle
&& oculars[selectedOcularIndex]->appearentFOV() > 0.0 && oculars[selectedOcularIndex]->appearentFOV() > 0.0
&& !oculars[selectedOcularIndex]->isBinoculars()) { && !oculars[selectedOcularIndex]->isBinoculars()) {
inner = oculars[selectedOcularIndex]->appearentFOV() * inner / maxEyepieceAngle; inner = oculars[selectedOcularIndex]->appearentFOV() * inner / maxEyepieceAngle;
} }
painter.drawCircle(params.viewportCenter[0] * params.devicePixelsPer
Pixel,
params.viewportCent
er[1]* params.devicePixelsPerPixel,
inner);
// Paint the reticale, if needed // Paint the reticale, if needed
if (!reticleTexture.isNull()){ if (!reticleTexture.isNull()){
glEnable(GL_BLEND); glEnable(GL_BLEND);
painter.enableTexture2d(true); painter.enableTexture2d(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
painter.setColor(0.77, 0.14, 0.16, 1.0); painter.setColor(0.77, 0.14, 0.16, 1.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
reticleTexture->bind(); reticleTexture->bind();
int textureHeight; int textureHeight;
int textureWidth; int textureWidth;
reticleTexture->getDimensions(textureWidth, textureHeight); reticleTexture->getDimensions(textureWidth, textureHeight);
painter.drawSprite2dMode(params.viewportXywh[2] / 2 * params .devicePixelsPerPixel, painter.drawSprite2dMode(params.viewportXywh[2] / 2 * params .devicePixelsPerPixel,
params.viewportXywh[3] / 2 * params.devicePixelsPerPixel, params.viewportXywh[3] / 2 * params.devicePixelsPerPixel,
inner, inner,
reticleRotation); reticleRotation);
} }
if (oculars[selectedOcularIndex]->hasPermanentCrosshair()) if (oculars[selectedOcularIndex]->hasPermanentCrosshair()) {
{
paintCrosshairs(); paintCrosshairs();
} }
painter.drawViewportShape(inner);
} }
void Oculars::paintText(const StelCore* core) void Oculars::paintText(const StelCore* core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ; const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) ;
StelPainter painter(prj); StelPainter painter(prj);
// Get the current instruments // Get the current instruments
CCD *ccd = NULL; CCD *ccd = NULL;
if(selectedCCDIndex != -1) { if(selectedCCDIndex != -1) {
skipping to change at line 1762 skipping to change at line 1794
skyManager->setFlagLuminanceAdaptation(flagAdaptation); skyManager->setFlagLuminanceAdaptation(flagAdaptation);
skyManager->setFlagStarMagnitudeLimit(flagLimitStars); skyManager->setFlagStarMagnitudeLimit(flagLimitStars);
skyManager->setFlagNebulaMagnitudeLimit(flagLimitDSOs); skyManager->setFlagNebulaMagnitudeLimit(flagLimitDSOs);
skyManager->setCustomStarMagnitudeLimit(magLimitStars); skyManager->setCustomStarMagnitudeLimit(magLimitStars);
skyManager->setCustomNebulaMagnitudeLimit(magLimitDSOs); skyManager->setCustomNebulaMagnitudeLimit(magLimitDSOs);
movementManager->setFlagTracking(false); movementManager->setFlagTracking(false);
movementManager->setFlagEnableZoomKeys(true); movementManager->setFlagEnableZoomKeys(true);
movementManager->setFlagEnableMouseNavigation(true); movementManager->setFlagEnableMouseNavigation(true);
// Set the screen display // Set the screen display
// core->setMaskType(StelProjector::MaskNone); core->setMaskType(StelProjector::MaskNone);
core->setFlipHorz(false); core->setFlipHorz(false);
core->setFlipVert(false); core->setFlipVert(false);
if (getFlagInitFovUsage()) if (getFlagInitFovUsage())
movementManager->zoomTo(movementManager->getInitFov()); movementManager->zoomTo(movementManager->getInitFov());
else else
movementManager->zoomTo(initialFOV); movementManager->zoomTo(initialFOV);
} }
void Oculars::zoom(bool zoomedIn) void Oculars::zoom(bool zoomedIn)
skipping to change at line 1848 skipping to change at line 1880
movementManager->setFlagEnableZoomKeys(false); movementManager->setFlagEnableZoomKeys(false);
movementManager->setFlagEnableMouseNavigation(false); movementManager->setFlagEnableMouseNavigation(false);
// We won't always have a selected object // We won't always have a selected object
if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) { if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) {
StelObjectP selectedObject = StelApp::getInstance().getStelO bjectMgr().getSelectedObject()[0]; StelObjectP selectedObject = StelApp::getInstance().getStelO bjectMgr().getSelectedObject()[0];
movementManager->moveToJ2000(selectedObject->getEquinoxEquat orialPos(core), 0.0, 1); movementManager->moveToJ2000(selectedObject->getEquinoxEquat orialPos(core), 0.0, 1);
} }
// Set the screen display // Set the screen display
core->setMaskType(StelProjector::MaskDisk);
Ocular * ocular = oculars[selectedOcularIndex]; Ocular * ocular = oculars[selectedOcularIndex];
Telescope * telescope = NULL; Telescope * telescope = NULL;
Lens * lens = NULL; Lens * lens = NULL;
// Only consider flip is we're not binoculars // Only consider flip is we're not binoculars
if (ocular->isBinoculars()) if (ocular->isBinoculars())
{ {
core->setFlipHorz(false); core->setFlipHorz(false);
core->setFlipVert(false); core->setFlipVert(false);
} }
else else
skipping to change at line 1889 skipping to change at line 1922
actualFOV = ocular->actualFOV(telescope, lens); actualFOV = ocular->actualFOV(telescope, lens);
// See if the mask was scaled; if so, correct the actualFOV. // See if the mask was scaled; if so, correct the actualFOV.
if (useMaxEyepieceAngle && ocular->appearentFOV() > 0.0 && !ocular-> isBinoculars()) { if (useMaxEyepieceAngle && ocular->appearentFOV() > 0.0 && !ocular-> isBinoculars()) {
actualFOV = maxEyepieceAngle * actualFOV / ocular->appearent FOV(); actualFOV = maxEyepieceAngle * actualFOV / ocular->appearent FOV();
} }
movementManager->zoomTo(actualFOV, 0.0); movementManager->zoomTo(actualFOV, 0.0);
} }
void Oculars::hideUsageMessageIfDisplayed() void Oculars::hideUsageMessageIfDisplayed()
{ {
if (usageMessageLabelID > -1) if (usageMessageLabelID > -1) {
{
LabelMgr *labelManager = GETSTELMODULE(LabelMgr); LabelMgr *labelManager = GETSTELMODULE(LabelMgr);
labelManager->setLabelShow(usageMessageLabelID, false); labelManager->setLabelShow(usageMessageLabelID, false);
labelManager->deleteLabel(usageMessageLabelID); labelManager->deleteLabel(usageMessageLabelID);
usageMessageLabelID = -1; usageMessageLabelID = -1;
} }
} }
Lens* Oculars::selectedLens() Lens* Oculars::selectedLens()
{ {
if (selectedLensIndex >= 0 && selectedLensIndex < lense.count()) if (selectedLensIndex >= 0 && selectedLensIndex < lense.count()) {
return lense[selectedLensIndex]; return lense[selectedLensIndex];
return NULL; }
return NULL;
} }
QMenu* Oculars::addLensSubmenu(QMenu* parent) QMenu* Oculars::addLensSubmenu(QMenu* parent)
{ {
Q_ASSERT(parent); Q_ASSERT(parent);
QMenu *submenu = new QMenu(q_("&Lens"), parent); QMenu *submenu = new QMenu(q_("&Lens"), parent);
submenu->addAction(q_("&Previous lens"), this, SLOT(decrementLensInd ex())); submenu->addAction(q_("&Previous lens"), this, SLOT(decrementLensInd ex()));
submenu->addAction(q_("&Next lens"), this, SLOT(incrementLensIndex() )); submenu->addAction(q_("&Next lens"), this, SLOT(incrementLensIndex() ));
submenu->addSeparator(); submenu->addSeparator();
skipping to change at line 2004 skipping to change at line 2037
flagInitFOVUsage = b; flagInitFOVUsage = b;
settings->setValue("use_initial_fov", b); settings->setValue("use_initial_fov", b);
settings->sync(); settings->sync();
} }
bool Oculars::getFlagInitFovUsage() const bool Oculars::getFlagInitFovUsage() const
{ {
return flagInitFOVUsage; return flagInitFOVUsage;
} }
void Oculars::setFlagUseFlipForCCD(const bool b)
{
flagUseFlipForCCD = b;
settings->setValue("use_ccd_flip", b);
settings->sync();
}
bool Oculars::getFlagUseFlipForCCD() const
{
return flagUseFlipForCCD;
}
QString Oculars::getDimensionsString(double fovX, double fovY) const QString Oculars::getDimensionsString(double fovX, double fovY) const
{ {
QString stringFovX, stringFovY; QString stringFovX, stringFovY;
if (getFlagDecimalDegrees()) if (getFlagDecimalDegrees())
{ {
if (fovX >= 1.0) if (fovX >= 1.0)
{ {
int degrees = (int)fovX; int degrees = (int)fovX;
int minutes = (int)((fovX - degrees) * 60); int minutes = (int)((fovX - degrees) * 60);
stringFovX = QString::number(degrees) + QChar(0x00B0 ) + QString::number(minutes) + QChar(0x2032); stringFovX = QString::number(degrees) + QChar(0x00B0 ) + QString::number(minutes) + QChar(0x2032);
 End of changes. 45 change blocks. 
86 lines changed or deleted 160 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/