Skip to content

Commit

Permalink
Fixed CCD frame rotation after changing language (fix Stellarium#3627)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-w committed Feb 13, 2024
1 parent 206f48c commit 93a5f14
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 62 deletions.
26 changes: 26 additions & 0 deletions plugins/Oculars/src/Oculars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,32 @@ void Oculars::initializeActivationActions()
addAction("actionShow_Sensor_Pixel_Grid", ocularsGroup, N_("Toggle sensor pixel grid"), "togglePixelGrid()");
addAction("actionShow_Sensor_Focuser_Overlay", ocularsGroup, N_("Toggle focuser overlay"), "toggleFocuserOverlay()");

// NOTE: GUI elements in OcularsGuiPanel
addAction("actionToggle_Oculars_Rotate_Frame_Reset", ocularsGroup, N_("Reset the sensor frame rotation"), this, "ccdRotationReset()", "", "");
addAction("actionToggle_Oculars_Rotate_Prism_Reset", ocularsGroup, N_("Reset the prism rotation"), this, "prismPositionAngleReset()", "", "");
QList<int> angles = { 1, 5, 15, 90 };
for (int i = 0; i < angles.size(); ++i)
{
QString angle = QString::number(angles.at(i));
QString degree = (angles.at(i)==1 ? "degree" : "degrees");

QString actionCounterclockwiseCCDName = QString("actionToggle_Oculars_Rotate_Frame_%1_Counterclockwise").arg(angle);
QString actionCounterclockwiseCCDDescription = QString("Rotate the sensor frame %1 %2 counterclockwise").arg(angle, degree);
addAction(actionCounterclockwiseCCDName, ocularsGroup, actionCounterclockwiseCCDDescription, this, [=](){rotateCCD(-1*angles.at(i));}, "");

QString actionClockwiseCCDName = QString("actionToggle_Oculars_Rotate_Frame_%1_Clockwise").arg(angle);
QString actionClockwiseCCDDescription = QString("Rotate the sensor frame %1 %2 clockwise").arg(angle, degree);
addAction(actionClockwiseCCDName, ocularsGroup, actionClockwiseCCDDescription, this, [=](){rotateCCD(angles.at(i));}, "");

QString actionCounterclockwisePrismName = QString("actionToggle_Oculars_Rotate_Prism_%1_Counterclockwise").arg(angle);
QString actionCounterclockwisePrismDescription = QString("Rotate the prism %1 %2 counterclockwise").arg(angle, degree);
addAction(actionCounterclockwisePrismName, ocularsGroup, actionCounterclockwisePrismDescription, this, [=](){rotatePrism(-1*angles.at(i));}, "");

QString actionClockwisePrismName = QString("actionToggle_Oculars_Rotate_Prism_%1_Clockwise").arg(angle);
QString actionClockwisePrismDescription = QString("Rotate the prism %1 %2 clockwise").arg(angle, degree);
addAction(actionClockwisePrismName, ocularsGroup, actionClockwisePrismDescription, this, [=](){rotatePrism(angles.at(i));}, "");
}

connect(this, SIGNAL(selectedCCDChanged(int)), this, SLOT(instrumentChanged()));
connect(this, SIGNAL(selectedOcularChanged(int)), this, SLOT(instrumentChanged()));
connect(this, SIGNAL(selectedTelescopeChanged(int)), this, SLOT(instrumentChanged()));
Expand Down
60 changes: 7 additions & 53 deletions plugins/Oculars/src/gui/OcularsGuiPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,33 +181,6 @@ OcularsGuiPanel::OcularsGuiPanel(Oculars* plugin,
QPixmap naOff(":/graphicGui/btTimeForward-off.png");
QPixmap nextArrowOff = naOff.scaledToHeight(scale * StelButton::getInputPixmapsDevicePixelRatio(), Qt::SmoothTransformation);

StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManager();
QString ocularsGroup = N_("Oculars"); // Possible group name: Oculars on-screen control panel
actionMgr->addAction("actionToggle_Oculars_Rotate_Frame_Reset", ocularsGroup, N_("Reset the sensor frame rotation"), this, "resetCCDRotation()", "", "");
actionMgr->addAction("actionToggle_Oculars_Rotate_Prism_Reset", ocularsGroup, N_("Reset the prism rotation"), this, "resetPrismRotation()", "", "");
QList<int> angles = { 1, 5, 15, 90 };
for (int i = 0; i < angles.size(); ++i)
{
QString angle = QString::number(angles.at(i));
QString degree = (angles.at(i)==1 ? "degree" : "degrees");

QString actionCounterclockwiseCCDName = QString("actionToggle_Oculars_Rotate_Frame_%1_Counterclockwise").arg(angle);
QString actionCounterclockwiseCCDDescription = QString("Rotate the sensor frame %1 %2 counterclockwise").arg(angle, degree);
actionMgr->addAction(actionCounterclockwiseCCDName, ocularsGroup, actionCounterclockwiseCCDDescription, this, [=](){rotateCCD(-1*angles.at(i));}, "");

QString actionClockwiseCCDName = QString("actionToggle_Oculars_Rotate_Frame_%1_Clockwise").arg(angle);
QString actionClockwiseCCDDescription = QString("Rotate the sensor frame %1 %2 clockwise").arg(angle, degree);
actionMgr->addAction(actionClockwiseCCDName, ocularsGroup, actionClockwiseCCDDescription, this, [=](){rotateCCD(angles.at(i));}, "");

QString actionCounterclockwisePrismName = QString("actionToggle_Oculars_Rotate_Prism_%1_Counterclockwise").arg(angle);
QString actionCounterclockwisePrismDescription = QString("Rotate the prism %1 %2 counterclockwise").arg(angle, degree);
actionMgr->addAction(actionCounterclockwisePrismName, ocularsGroup, actionCounterclockwisePrismDescription, this, [=](){rotatePrism(-1*angles.at(i));}, "");

QString actionClockwisePrismName = QString("actionToggle_Oculars_Rotate_Prism_%1_Clockwise").arg(angle);
QString actionClockwisePrismDescription = QString("Rotate the prism %1 %2 clockwise").arg(angle, degree);
actionMgr->addAction(actionClockwisePrismName, ocularsGroup, actionClockwisePrismDescription, this, [=](){rotatePrism(angles.at(i));}, "");
}

prevOcularButton = new StelButton(ocularControls, prevArrow, prevArrowOff, QPixmap(), "actionShow_Ocular_Decrement");
prevOcularButton->setToolTip(q_("Select previous eyepiece"));
nextOcularButton = new StelButton(ocularControls, nextArrow, nextArrowOff, QPixmap(), "actionShow_Ocular_Increment");
Expand All @@ -225,6 +198,7 @@ OcularsGuiPanel::OcularsGuiPanel(Oculars* plugin,
nextTelescopeButton = new StelButton(telescopeControls, nextArrow, nextArrowOff, QPixmap(), "actionShow_Telescope_Increment");
nextTelescopeButton->setToolTip(q_("Select next telescope"));

// NOTE: actions for rotation in Oculars.cpp file
QColor cOn(255, 255, 255);
QColor cOff(102, 102, 102);
QColor cHover(162, 162, 162);
Expand Down Expand Up @@ -348,6 +322,8 @@ OcularsGuiPanel::OcularsGuiPanel(Oculars* plugin,
connect(ocularsPlugin, SIGNAL(selectedCCDChanged(int)), this, SLOT(updateCcdControls()));
connect(ocularsPlugin, SIGNAL(selectedTelescopeChanged(int)), this, SLOT(updateTelescopeControls()));
connect(ocularsPlugin, SIGNAL(selectedLensChanged(int)), this, SLOT(updateTelescopeControls()));
connect(ocularsPlugin, SIGNAL(selectedCCDRotationAngleChanged(double)), this, SLOT(updateCcdControls()));
connect(ocularsPlugin, SIGNAL(selectedCCDPrismPositionAngleChanged(double)), this, SLOT(updateCcdControls()));

//Night mode
connect(&stelApp, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(setColorScheme(const QString&)));
Expand Down Expand Up @@ -406,30 +382,6 @@ void OcularsGuiPanel::showCcdGui()
updateCcdControls();
}

void OcularsGuiPanel::rotateCCD(int angle)
{
ocularsPlugin->rotateCCD(angle);
updateCcdControls();
}

void OcularsGuiPanel::rotatePrism(int angle)
{
ocularsPlugin->rotatePrism(angle);
updateCcdControls();
}

void OcularsGuiPanel::resetCCDRotation()
{
ocularsPlugin->ccdRotationReset();
updateCcdControls();
}

void OcularsGuiPanel::resetPrismRotation()
{
ocularsPlugin->prismPositionAngleReset();
updateCcdControls();
}

void OcularsGuiPanel::foldGui()
{
//qDebug() << "hidePanel()";
Expand Down Expand Up @@ -630,8 +582,10 @@ void OcularsGuiPanel::updateCcdControls()
int index = ocularsPlugin->selectedCCDIndex;
CCD* ccd = ocularsPlugin->ccds[index];
Q_ASSERT(ccd);
ocularsPlugin->setSelectedCCDRotationAngle(ccd->chipRotAngle());
ocularsPlugin->setSelectedCCDPrismPositionAngle(ccd->prismPosAngle());
if (ccd->chipRotAngle()!=ocularsPlugin->getSelectedCCDRotationAngle())
ocularsPlugin->setSelectedCCDRotationAngle(ccd->chipRotAngle());
if (ccd->prismPosAngle()!=ocularsPlugin->getSelectedCCDPrismPositionAngle())
ocularsPlugin->setSelectedCCDPrismPositionAngle(ccd->prismPosAngle());
QString name = ccd->name();
QString fullName;
if (name.isEmpty())
Expand Down
9 changes: 0 additions & 9 deletions plugins/Oculars/src/gui/OcularsGuiPanel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ private slots:
//! Tied to the parent's geometryChanged() signal.
void updatePosition();

//! Rotate the sensor frame X degrees clockwise or counterclockwise
void rotateCCD(int angle);
//! Rotate the prism X degrees clockwise
void rotatePrism(int angle);
//! Reset the sensor frame rotation or counterclockwise
void resetCCDRotation();
//! Reset the prism rotation
void resetPrismRotation();

//! Updates the information shown when a sensor overlay is displayed
void updateCcdControls();
//! Updates the information that depends on the current lens
Expand Down

0 comments on commit 93a5f14

Please sign in to comment.