Index: kstars/ekos/align/align.h =================================================================== --- kstars/ekos/align/align.h +++ kstars/ekos/align/align.h @@ -9,6 +9,7 @@ #pragma once +#include "kstarsenum.h" #include "ui_align.h" #include "ui_mountmodel.h" #include "ekos/ekos.h" @@ -158,7 +159,7 @@ * Returns the solver's current status * @return Returns solver status (Ekos::AlignState) */ - Q_SCRIPTABLE int getStatus() { return state; } + Q_SCRIPTABLE int getStatus() { return KStarsEnum::toType(state); } /** DBUS interface function. * @return Returns State of load slew procedure. Idle if not started. Busy if in progress. Ok if complete. Alert if procedure failed. @@ -669,8 +670,8 @@ int retries { 0 }; // State - AlignState state { ALIGN_IDLE }; - FocusState focusState { FOCUS_IDLE }; + AlignState state { Ekos::AlignState::ALIGN_IDLE }; + FocusState focusState { Ekos::FocusState::FOCUS_IDLE }; // Track which upload mode the CCD is set to. If set to UPLOAD_LOCAL, then we need to switch it to UPLOAD_CLIENT in order to do focusing, and then switch it back to UPLOAD_LOCAL ISD::CCD::UploadMode rememberUploadMode { ISD::CCD::UPLOAD_CLIENT }; Index: kstars/ekos/align/align.cpp =================================================================== --- kstars/ekos/align/align.cpp +++ kstars/ekos/align/align.cpp @@ -2425,7 +2425,7 @@ { filterPositionPending = true; filterManager->setFilterPosition(targetPosition); - state = ALIGN_PROGRESS; + state = Ekos::AlignState::ALIGN_PROGRESS; return true; } } @@ -2449,7 +2449,7 @@ ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); - if (focusState >= FOCUS_PROGRESS) + if (focusState >= Ekos::FocusState::FOCUS_PROGRESS) { appendLogText(i18n("Cannot capture while focus module is busy! Retrying...")); QTimer::singleShot(5000, this, SLOT(captureAndSolve())); @@ -2552,7 +2552,7 @@ differentialSlewingActivated = false; - state = ALIGN_PROGRESS; + state = Ekos::AlignState::ALIGN_PROGRESS; emit newStatus(state); // If we're just refreshing, then we're done @@ -2811,7 +2811,7 @@ if (currentGotoMode == GOTO_SLEW) appendLogText(i18n("Solver iteration #%1", solverIterations + 1)); - state = ALIGN_PROGRESS; + state = Ekos::AlignState::ALIGN_PROGRESS; emit newStatus(state); parser->startSovler(filename, solverArgs, isGenerated); @@ -3144,7 +3144,7 @@ } KNotification::event(QLatin1String("AlignSuccessful"), i18n("Astrometry alignment completed successfully")); - state = ALIGN_COMPLETE; + state = Ekos::AlignState::ALIGN_COMPLETE; emit newStatus(state); solverIterations = 0; @@ -3182,7 +3182,7 @@ //emit solverComplete(false); - state = ALIGN_FAILED; + state = Ekos::AlignState::ALIGN_FAILED; emit newStatus(state); int currentRow = solutionTable->rowCount() - 1; @@ -3256,7 +3256,7 @@ } } - state = ALIGN_ABORTED; + state = Ekos::AlignState::ALIGN_ABORTED; emit newStatus(state); int currentRow = solutionTable->rowCount() - 1; @@ -3392,10 +3392,10 @@ switch (state) { - case ALIGN_PROGRESS: + case Ekos::AlignState::ALIGN_PROGRESS: break; - case ALIGN_SYNCING: + case Ekos::AlignState::ALIGN_SYNCING: { isSlewDirty = false; if (currentGotoMode == GOTO_SLEW) @@ -3408,7 +3408,7 @@ appendLogText(i18n("Mount is synced to solution coordinates. Astrometric solver is successful.")); KNotification::event(QLatin1String("AlignSuccessful"), i18n("Astrometry alignment completed successfully")); - state = ALIGN_COMPLETE; + state = Ekos::AlignState::ALIGN_COMPLETE; emit newStatus(state); solverIterations = 0; @@ -3418,7 +3418,7 @@ } break; - case ALIGN_SLEWING: + case Ekos::AlignState::ALIGN_SLEWING: if (isSlewDirty == false) break; @@ -3429,7 +3429,7 @@ qCDebug(KSTARS_EKOS_ALIGN) << "loadSlewState is IDLE."; - state = ALIGN_PROGRESS; + state = Ekos::AlignState::ALIGN_PROGRESS; emit newStatus(state); QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve())); @@ -3439,7 +3439,7 @@ { appendLogText(i18n("Differential slewing complete. Astrometric solver is successful.")); KNotification::event(QLatin1String("AlignSuccessful"), i18n("Astrometry alignment completed successfully")); - state = ALIGN_COMPLETE; + state = Ekos::AlignState::ALIGN_COMPLETE; emit newStatus(state); solverIterations = 0; @@ -3455,7 +3455,7 @@ targetAccuracyNotMet = false; - state = ALIGN_PROGRESS; + state = Ekos::AlignState::ALIGN_PROGRESS; emit newStatus(state); QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve())); @@ -3480,9 +3480,9 @@ case IPS_ALERT: { - if (state == ALIGN_SYNCING || state == ALIGN_SLEWING) + if (state == Ekos::AlignState::ALIGN_SYNCING || state == Ekos::AlignState::ALIGN_SLEWING) { - if (state == ALIGN_SYNCING) + if (state == Ekos::AlignState::ALIGN_SYNCING) appendLogText(i18n("Syncing failed!")); else appendLogText(i18n("Slewing failed!")); @@ -3609,7 +3609,7 @@ void Align::Sync() { - state = ALIGN_SYNCING; + state = Ekos::AlignState::ALIGN_SYNCING; if (currentTelescope->Sync(&alignCoord)) { @@ -3619,7 +3619,7 @@ } else { - state = ALIGN_IDLE; + state = Ekos::AlignState::ALIGN_IDLE; emit newStatus(state); appendLogText(i18n("Syncing failed.")); } @@ -3627,7 +3627,7 @@ void Align::Slew() { - state = ALIGN_SLEWING; + state = Ekos::AlignState::ALIGN_SLEWING; emit newStatus(state); isSlewDirty = currentTelescope->Slew(&targetCoord); @@ -4552,7 +4552,7 @@ { switch (newState) { - case CAPTURE_ALIGNING: + case Ekos::CaptureState::CAPTURE_ALIGNING: if (currentTelescope && currentTelescope->hasAlignmentModel() && Options::resetMountModelAfterMeridian()) { mountModelReset = currentTelescope->clearAlignmentModel(); @@ -5277,7 +5277,7 @@ break; default: - if (state != ALIGN_PROGRESS) + if (state != Ekos::AlignState::ALIGN_PROGRESS) { solveB->setEnabled(true); PAHFirstCaptureB->setEnabled(true); @@ -5326,7 +5326,7 @@ { if (filterPositionPending) { - focusState = FOCUS_IDLE; + focusState = Ekos::FocusState::FOCUS_IDLE; filterPositionPending = false; captureAndSolve(); } @@ -5346,15 +5346,15 @@ { switch (filterState) { - case FILTER_OFFSET: + case Ekos::FilterState::FILTER_OFFSET: appendLogText(i18n("Changing focus offset by %1 steps...", filterManager->getTargetFilterOffset())); break; - case FILTER_CHANGE: + case Ekos::FilterState::FILTER_CHANGE: appendLogText(i18n("Changing filter to %1...", FilterPosCombo->itemText(filterManager->getTargetFilterPosition()-1))); break; - case FILTER_AUTOFOCUS: + case Ekos::FilterState::FILTER_AUTOFOCUS: appendLogText(i18n("Auto focus on filter change...")); break; Index: kstars/ekos/auxiliary/filtermanager.h =================================================================== --- kstars/ekos/auxiliary/filtermanager.h +++ kstars/ekos/auxiliary/filtermanager.h @@ -153,9 +153,9 @@ INumberVectorProperty *m_FilterPositionProperty { nullptr }; // Operation stack - void buildOperationQueue(FilterState operation); + void buildOperationQueue(Ekos::FilterState operation); bool executeOperationQueue(); - bool executeOneOperation(FilterState operation); + bool executeOneOperation(Ekos::FilterState operation); // Update model void syncDBToINDI(); @@ -163,7 +163,7 @@ // Operation Queue QQueue operationQueue; - FilterState state = { FILTER_IDLE }; + FilterState state = { Ekos::FilterState::FILTER_IDLE }; int targetFilterPosition { -1 }; int targetFilterOffset { - 1 }; Index: kstars/ekos/auxiliary/filtermanager.cpp =================================================================== --- kstars/ekos/auxiliary/filtermanager.cpp +++ kstars/ekos/auxiliary/filtermanager.cpp @@ -16,7 +16,6 @@ #include "auxiliary/kspaths.h" #include "ekos/auxiliary/filterdelegate.h" - #include #include #include @@ -267,7 +266,7 @@ return true; } - buildOperationQueue(FILTER_CHANGE); + buildOperationQueue(Ekos::FilterState::FILTER_CHANGE); executeOperationQueue(); @@ -287,10 +286,10 @@ emit positionChanged(m_currentFilterPosition); } - if (state == FILTER_CHANGE) + if (state == Ekos::FilterState::FILTER_CHANGE) executeOperationQueue(); // If filter is changed externally, record its current offset as the starting offset. - else if (state == FILTER_IDLE) + else if (state == Ekos::FilterState::FILTER_IDLE) lastFilterOffset = m_ActiveFilters[m_currentFilterPosition-1]->offset(); // Check if we have to apply Focus Offset @@ -398,27 +397,27 @@ } -void FilterManager::buildOperationQueue(FilterState operation) +void FilterManager::buildOperationQueue(Ekos::FilterState operation) { operationQueue.clear(); m_useTargetFilter = false; switch (operation) { - case FILTER_CHANGE: + case Ekos::FilterState::FILTER_CHANGE: { if ( (m_Policy & CHANGE_POLICY) && targetFilter != currentFilter) m_useTargetFilter = true; if (m_useTargetFilter) { - operationQueue.enqueue(FILTER_CHANGE); + operationQueue.enqueue(Ekos::FilterState::FILTER_CHANGE); if (m_Policy & OFFSET_POLICY) - operationQueue.enqueue(FILTER_OFFSET); + operationQueue.enqueue(Ekos::FilterState::FILTER_OFFSET); } if ( (m_Policy & AUTOFOCUS_POLICY) && targetFilter->useAutoFocus()) - operationQueue.enqueue(FILTER_AUTOFOCUS); + operationQueue.enqueue(Ekos::FilterState::FILTER_AUTOFOCUS); } break; @@ -431,7 +430,7 @@ { if (operationQueue.isEmpty()) { - state = FILTER_IDLE; + state = Ekos::FilterState::FILTER_IDLE; emit newStatus(state); emit ready(); return false; @@ -443,9 +442,9 @@ switch (nextOperation) { - case FILTER_CHANGE: + case Ekos::FilterState::FILTER_CHANGE: { - state = FILTER_CHANGE; + state = Ekos::FilterState::FILTER_CHANGE; if (m_useTargetFilter) targetFilterPosition = m_ActiveFilters.indexOf(targetFilter) + 1; m_currentFilterDevice->runCommand(INDI_SET_FILTER, &targetFilterPosition); @@ -453,9 +452,9 @@ } break; - case FILTER_OFFSET: + case Ekos::FilterState::FILTER_OFFSET: { - state = FILTER_OFFSET; + state = Ekos::FilterState::FILTER_OFFSET; if (m_useTargetFilter) { targetFilterOffset = targetFilter->offset() - lastFilterOffset; @@ -473,8 +472,8 @@ } break; - case FILTER_AUTOFOCUS: - state = FILTER_AUTOFOCUS; + case Ekos::FilterState::FILTER_AUTOFOCUS: + state = Ekos::FilterState::FILTER_AUTOFOCUS; emit newStatus(state); emit checkFocus(0.01); break; @@ -491,7 +490,7 @@ return executeOperationQueue(); } -bool FilterManager::executeOneOperation(FilterState operation) +bool FilterManager::executeOneOperation(Ekos::FilterState operation) { bool actionRequired = false; @@ -506,7 +505,7 @@ void FilterManager::setFocusOffsetComplete() { - if (state == FILTER_OFFSET) + if (state == Ekos::FilterState::FILTER_OFFSET) executeOperationQueue(); } @@ -594,15 +593,15 @@ void FilterManager::setFocusStatus(Ekos::FocusState focusState) { - if (state == FILTER_AUTOFOCUS) + if (state == Ekos::FilterState::FILTER_AUTOFOCUS) { switch (focusState) { - case FOCUS_COMPLETE: + case Ekos::FocusState::FOCUS_COMPLETE: executeOperationQueue(); break; - case FOCUS_FAILED: + case Ekos::FocusState::FOCUS_FAILED: if (++retries == 3) { retries = 0; Index: kstars/ekos/capture/capture.h =================================================================== --- kstars/ekos/capture/capture.h +++ kstars/ekos/capture/capture.h @@ -639,10 +639,10 @@ bool suspendGuideOnDownload { false }; // State - CaptureState state { CAPTURE_IDLE }; - FocusState focusState { FOCUS_IDLE }; - GuideState guideState { GUIDE_IDLE }; - AlignState alignState { ALIGN_IDLE }; + CaptureState state { Ekos::CaptureState::CAPTURE_IDLE }; + FocusState focusState { Ekos::FocusState::FOCUS_IDLE }; + GuideState guideState { Ekos::GuideState::GUIDE_IDLE }; + AlignState alignState { Ekos::AlignState::ALIGN_IDLE }; PauseFunctionPointer pauseFunction; Index: kstars/ekos/capture/capture.cpp =================================================================== --- kstars/ekos/capture/capture.cpp +++ kstars/ekos/capture/capture.cpp @@ -290,8 +290,8 @@ void Capture::pause() { pauseFunction = nullptr; - state = CAPTURE_PAUSED; - emit newStatus(Ekos::CAPTURE_PAUSED); + state = Ekos::CaptureState::CAPTURE_PAUSED; + emit newStatus(Ekos::CaptureState::CAPTURE_PAUSED); appendLogText(i18n("Sequence shall be paused after current exposure is complete.")); pauseB->setEnabled(false); @@ -301,15 +301,15 @@ void Capture::toggleSequence() { - if (state == CAPTURE_PAUSED) + if (state == Ekos::CaptureState::CAPTURE_PAUSED) { startB->setIcon( QIcon::fromTheme("media-playback-stop")); startB->setToolTip(i18n("Stop Sequence")); pauseB->setEnabled(true); - state = CAPTURE_CAPTURING; - emit newStatus(Ekos::CAPTURE_CAPTURING); + state = Ekos::CaptureState::CAPTURE_CAPTURING; + emit newStatus(Ekos::CaptureState::CAPTURE_CAPTURING); appendLogText(i18n("Sequence resumed.")); @@ -317,7 +317,7 @@ if (pauseFunction) (this->*pauseFunction)(); } - else if (state == CAPTURE_IDLE || state == CAPTURE_COMPLETE) + else if (state == Ekos::CaptureState::CAPTURE_IDLE || state == Ekos::CaptureState::CAPTURE_COMPLETE) { start(); } @@ -415,8 +415,8 @@ ditherCounter = Options::ditherFrames(); inSequenceFocusCounter = Options::inSequenceCheckFrames(); - state = CAPTURE_PROGRESS; - emit newStatus(Ekos::CAPTURE_PROGRESS); + state = Ekos::CaptureState::CAPTURE_PROGRESS; + emit newStatus(Ekos::CaptureState::CAPTURE_PROGRESS); startB->setIcon(QIcon::fromTheme("media-playback-stop")); startB->setToolTip(i18n("Stop Sequence")); @@ -446,7 +446,7 @@ { KNotification::event(QLatin1String("CaptureFailed"), i18n("CCD capture failed with errors")); activeJob->abort(); - emit newStatus(Ekos::CAPTURE_ABORTED); + emit newStatus(Ekos::CaptureState::CAPTURE_ABORTED); } // In case of batch job @@ -475,7 +475,7 @@ } calibrationStage = CAL_NONE; - state = CAPTURE_IDLE; + state = Ekos::CaptureState::CAPTURE_IDLE; // Turn off any calibration light, IF they were turned on by Capture module if (dustCap && dustCapLightEnabled) @@ -1066,7 +1066,7 @@ bool Capture::startNextExposure() { - if (state == CAPTURE_PAUSED) + if (state == Ekos::CaptureState::CAPTURE_PAUSED) { pauseFunction = &Capture::startNextExposure; appendLogText(i18n("Sequence paused.")); @@ -1077,8 +1077,8 @@ if (seqDelay > 0) { secondsLabel->setText(i18n("Waiting...")); - state = CAPTURE_WAITING; - emit newStatus(Ekos::CAPTURE_WAITING); + state = Ekos::CaptureState::CAPTURE_WAITING; + emit newStatus(Ekos::CaptureState::CAPTURE_WAITING); } seqTimer->start(seqDelay); @@ -1121,7 +1121,7 @@ // If the FITS is not for our device, simply ignore //if (QString(bp->bvp->device) != currentCCD->getDeviceName() || (startB->isEnabled() && previewB->isEnabled())) - if (QString(bp->bvp->device) != currentCCD->getDeviceName() || state == CAPTURE_IDLE) + if (QString(bp->bvp->device) != currentCCD->getDeviceName() || state == Ekos::CaptureState::CAPTURE_IDLE) return; if (currentCCD->isLooping() == false) @@ -1182,12 +1182,12 @@ // Reset active job pointer activeJob = nullptr; abort(); - if (guideState == GUIDE_SUSPENDED && suspendGuideOnDownload) + if (guideState == Ekos::GuideState::GUIDE_SUSPENDED && suspendGuideOnDownload) emit resumeGuiding(); return true; } - if (state == CAPTURE_PAUSED) + if (state == Ekos::CaptureState::CAPTURE_PAUSED) { pauseFunction = &Capture::setCaptureComplete; appendLogText(i18n("Sequence paused.")); @@ -1210,8 +1210,8 @@ appendLogText(i18n("Received image %1 out of %2.", seqCurrentCount, seqTotalCount)); - state = CAPTURE_IMAGE_RECEIVED; - emit newStatus(Ekos::CAPTURE_IMAGE_RECEIVED); + state = Ekos::CaptureState::CAPTURE_IMAGE_RECEIVED; + emit newStatus(Ekos::CaptureState::CAPTURE_IMAGE_RECEIVED); currentImgCountOUT->setText(QString::number(seqCurrentCount)); @@ -1258,19 +1258,19 @@ abort(); - state = CAPTURE_COMPLETE; - emit newStatus(Ekos::CAPTURE_COMPLETE); + state = Ekos::CaptureState::CAPTURE_COMPLETE; + emit newStatus(Ekos::CaptureState::CAPTURE_COMPLETE); //Resume guiding if it was suspended before //if (isAutoGuiding && currentCCD->getChip(ISD::CCDChip::GUIDE_CCD) == guideChip) - if (guideState == GUIDE_SUSPENDED && suspendGuideOnDownload) + if (guideState == Ekos::GuideState::GUIDE_SUSPENDED && suspendGuideOnDownload) emit resumeGuiding(); } } bool Capture::resumeSequence() { - if (state == CAPTURE_PAUSED) + if (state == Ekos::CaptureState::CAPTURE_PAUSED) { pauseFunction = &Capture::resumeSequence; appendLogText(i18n("Sequence paused.")); @@ -1298,7 +1298,7 @@ //Resume guiding if it was suspended before //if (isAutoGuiding && currentCCD->getChip(ISD::CCDChip::GUIDE_CCD) == guideChip) - if (guideState == GUIDE_SUSPENDED && suspendGuideOnDownload) + if (guideState == Ekos::GuideState::GUIDE_SUSPENDED && suspendGuideOnDownload) { qCDebug(KSTARS_EKOS_CAPTURE) << "Resuming guiding..."; emit resumeGuiding(); @@ -1338,7 +1338,7 @@ } // If we suspended guiding due to primary chip download, resume guide chip guiding now - if (guideState == GUIDE_SUSPENDED && suspendGuideOnDownload) + if (guideState == Ekos::GuideState::GUIDE_SUSPENDED && suspendGuideOnDownload) { qCInfo(KSTARS_EKOS_CAPTURE) << "Resuming guiding..."; emit resumeGuiding(); @@ -1351,7 +1351,7 @@ // If CCD is looping, we cannot dither UNLESS a different camera and NOT a guide chip is doing the guiding for us. && (currentCCD->isLooping() == false || guideChip == nullptr) // We must be either in guide mode or if non-guide dither (via pulsing) is enabled - && (guideState == GUIDE_GUIDING || Options::ditherNoGuiding()) + && (guideState == Ekos::GuideState::GUIDE_GUIDING || Options::ditherNoGuiding()) // Must be only done for light frames && activeJob->getFrameType() == FRAME_LIGHT // Check dither counter @@ -1366,8 +1366,8 @@ if (currentCCD->isLooping()) targetChip->abortExposure(); - state = CAPTURE_DITHERING; - emit newStatus(Ekos::CAPTURE_DITHERING); + state = Ekos::CaptureState::CAPTURE_DITHERING; + emit newStatus(Ekos::CaptureState::CAPTURE_DITHERING); } else if (isRefocus && activeJob->getFrameType() == FRAME_LIGHT) { @@ -1381,8 +1381,8 @@ // force refocus emit checkFocus(0.1); - state = CAPTURE_FOCUSING; - emit newStatus(Ekos::CAPTURE_FOCUSING); + state = Ekos::CaptureState::CAPTURE_FOCUSING; + emit newStatus(Ekos::CaptureState::CAPTURE_FOCUSING); } else if (isInSequenceFocus && activeJob->getFrameType() == FRAME_LIGHT && --inSequenceFocusCounter == 0) { @@ -1412,8 +1412,8 @@ qCDebug(KSTARS_EKOS_CAPTURE) << "In-sequence focusing started..."; - state = CAPTURE_FOCUSING; - emit newStatus(Ekos::CAPTURE_FOCUSING); + state = Ekos::CaptureState::CAPTURE_FOCUSING; + emit newStatus(Ekos::CaptureState::CAPTURE_FOCUSING); } else { @@ -1470,7 +1470,7 @@ return; } - if (focusState >= FOCUS_PROGRESS) + if (focusState >= Ekos::FocusState::FOCUS_PROGRESS) { appendLogText(i18n("Cannot capture while focus module is busy.")); abort(); @@ -1540,10 +1540,10 @@ currentCCD->setNextSequenceID(nextSequenceID); } - state = CAPTURE_CAPTURING; + state = Ekos::CaptureState::CAPTURE_CAPTURING; if (activeJob->isPreview() == false) - emit newStatus(Ekos::CAPTURE_CAPTURING); + emit newStatus(Ekos::CaptureState::CAPTURE_CAPTURING); if (frameSettings.contains(activeJob->getActiveChip())) { @@ -1601,7 +1601,7 @@ bool Capture::resumeCapture() { - if (state == CAPTURE_PAUSED) + if (state == Ekos::CaptureState::CAPTURE_PAUSED) { pauseFunction = &Capture::resumeCapture; appendLogText(i18n("Sequence paused.")); @@ -1618,8 +1618,8 @@ secondsLabel->setText(i18n("Focusing...")); qCDebug(KSTARS_EKOS_CAPTURE) << "Requesting focusing if HFR >" << HFRPixels->value(); emit checkFocus(HFRPixels->value()); - state = CAPTURE_FOCUSING; - emit newStatus(Ekos::CAPTURE_FOCUSING); + state = Ekos::CaptureState::CAPTURE_FOCUSING; + emit newStatus(Ekos::CaptureState::CAPTURE_FOCUSING); return true; } else if (isRefocus) @@ -1628,8 +1628,8 @@ secondsLabel->setText(i18n("Focusing...")); emit checkFocus(0.1); - state = CAPTURE_FOCUSING; - emit newStatus(Ekos::CAPTURE_FOCUSING); + state = Ekos::CaptureState::CAPTURE_FOCUSING; + emit newStatus(Ekos::CaptureState::CAPTURE_FOCUSING); return true; } @@ -1763,7 +1763,7 @@ } //if (isAutoGuiding && Options::useEkosGuider() && currentCCD->getChip(ISD::CCDChip::GUIDE_CCD) == guideChip) - if (guideState == GUIDE_GUIDING && Options::guiderType() == 0 && suspendGuideOnDownload) + if (guideState == Ekos::GuideState::GUIDE_GUIDING && Options::guiderType() == 0 && suspendGuideOnDownload) { qCDebug(KSTARS_EKOS_CAPTURE) << "Autoguiding suspended until primary CCD chip completes downloading..."; emit suspendGuiding(); @@ -2347,12 +2347,12 @@ switch (prepareState) { - case CAPTURE_SETTING_TEMPERATURE: + case Ekos::CaptureState::CAPTURE_SETTING_TEMPERATURE: appendLogText(i18n("Setting temperature to %1 C...", activeJob->getTargetTemperature())); secondsLabel->setText(i18n("Set %1 C...", activeJob->getTargetTemperature())); break; - case CAPTURE_SETTING_ROTATOR: + case Ekos::CaptureState::CAPTURE_SETTING_ROTATOR: appendLogText(i18n("Setting rotation to %1 degrees E of N...", activeJob->getTargetRotation())); secondsLabel->setText(i18n("Set Rotator %1...", activeJob->getTargetRotation())); break; @@ -2521,10 +2521,10 @@ focusState = state; - if (focusState > FOCUS_ABORTED) + if (focusState > Ekos::FocusState::FOCUS_ABORTED) return; - if (focusState == FOCUS_COMPLETE) + if (focusState == Ekos::FocusState::FOCUS_COMPLETE) { // enable option to have a refocus event occur if HFR goes over threshold autoFocusReady = true; @@ -2604,12 +2604,12 @@ { secondsLabel->setText(QString()); - if (focusState == FOCUS_COMPLETE) + if (focusState == Ekos::FocusState::FOCUS_COMPLETE) { appendLogText(i18n("Focus complete.")); startNextExposure(); } - else if (focusState == FOCUS_FAILED) + else if (focusState == Ekos::FocusState::FOCUS_FAILED) { appendLogText(i18n("Autofocus failed. Aborting exposure...")); abort(); @@ -3619,7 +3619,7 @@ if (aborted > 0) { - if (guideState >= GUIDE_GUIDING && deviationDetected) + if (guideState >= Ekos::GuideState::GUIDE_GUIDING && deviationDetected) return "Suspended"; else return "Aborted"; @@ -3693,8 +3693,8 @@ secondsLabel->setText(i18n("Aligning...")); retries = 0; - state = CAPTURE_ALIGNING; - emit newStatus(Ekos::CAPTURE_ALIGNING); + state = Ekos::CaptureState::CAPTURE_ALIGNING; + emit newStatus(Ekos::CaptureState::CAPTURE_ALIGNING); meridianFlipStage = MF_ALIGNING; //QTimer::singleShot(Options::settlingTime(), [this]() {emit meridialFlipTracked();}); @@ -3725,8 +3725,8 @@ appendLogText(i18n("Performing post flip re-calibration and guiding...")); secondsLabel->setText(i18n("Calibrating...")); - state = CAPTURE_CALIBRATING; - emit newStatus(Ekos::CAPTURE_CALIBRATING); + state = Ekos::CaptureState::CAPTURE_CALIBRATING; + emit newStatus(Ekos::CaptureState::CAPTURE_CALIBRATING); meridianFlipStage = MF_GUIDING; emit meridianFlipCompleted(); @@ -3785,9 +3785,9 @@ // emit suspendGuiding(false); // If we are autoguiding, we should resume autoguiding after flip - resumeGuidingAfterFlip = (guideState == GUIDE_GUIDING); + resumeGuidingAfterFlip = (guideState == Ekos::GuideState::GUIDE_GUIDING); - if ((guideState == GUIDE_GUIDING) || isInSequenceFocus) + if ((guideState == Ekos::GuideState::GUIDE_GUIDING) || isInSequenceFocus) emit meridianFlipStarted(); //double dec; @@ -3797,8 +3797,8 @@ retries = 0; - state = CAPTURE_MERIDIAN_FLIP; - emit newStatus(Ekos::CAPTURE_MERIDIAN_FLIP); + state = Ekos::CaptureState::CAPTURE_MERIDIAN_FLIP; + emit newStatus(Ekos::CaptureState::CAPTURE_MERIDIAN_FLIP); QTimer::singleShot(MF_TIMER_TIMEOUT, this, SLOT(checkMeridianFlipTimeout())); return true; @@ -3841,7 +3841,7 @@ } } -void Capture::setAlignStatus(AlignState state) +void Capture::setAlignStatus(Ekos::AlignState state) { alignState = state; @@ -3849,7 +3849,7 @@ switch (state) { - case ALIGN_COMPLETE: + case Ekos::AlignState::ALIGN_COMPLETE: if (meridianFlipStage == MF_ALIGNING) { appendLogText(i18n("Post flip re-alignment completed successfully.")); @@ -3858,7 +3858,7 @@ } break; - case ALIGN_FAILED: + case Ekos::AlignState::ALIGN_FAILED: // TODO run it 3 times before giving up if (meridianFlipStage == MF_ALIGNING) { @@ -3872,8 +3872,8 @@ appendLogText(i18n("Post-flip alignment failed. Retrying...")); secondsLabel->setText(i18n("Aligning...")); - this->state = CAPTURE_ALIGNING; - emit newStatus(Ekos::CAPTURE_ALIGNING); + this->state = Ekos::CaptureState::CAPTURE_ALIGNING; + emit newStatus(Ekos::CaptureState::CAPTURE_ALIGNING); meridianFlipStage = MF_ALIGNING; } @@ -3889,10 +3889,10 @@ { switch (state) { - case GUIDE_IDLE: - case GUIDE_ABORTED: + case Ekos::GuideState::GUIDE_IDLE: + case Ekos::GuideState::GUIDE_ABORTED: // If Autoguiding was started before and now stopped, let's abort (unless we're doing a meridian flip) - if (guideState == GUIDE_GUIDING && meridianFlipStage == MF_NONE && activeJob && + if (guideState == Ekos::GuideState::GUIDE_GUIDING && meridianFlipStage == MF_NONE && activeJob && activeJob->getStatus() == SequenceJob::JOB_BUSY) { appendLogText(i18n("Autoguiding stopped. Aborting...")); @@ -3900,12 +3900,12 @@ } break; - case GUIDE_GUIDING: - case GUIDE_CALIBRATION_SUCESS: + case Ekos::GuideState::GUIDE_GUIDING: + case Ekos::GuideState::GUIDE_CALIBRATION_SUCESS: autoGuideReady = true; break; - case GUIDE_CALIBRATION_ERROR: + case Ekos::GuideState::GUIDE_CALIBRATION_ERROR: // TODO try restarting calibration a couple of times before giving up if (meridianFlipStage == MF_GUIDING) { @@ -3923,12 +3923,12 @@ autoGuideReady = false; break; - case GUIDE_DITHERING_SUCCESS: + case Ekos::GuideState::GUIDE_DITHERING_SUCCESS: appendLogText(i18n("Dither complete.")); resumeCapture(); break; - case GUIDE_DITHERING_ERROR: + case Ekos::GuideState::GUIDE_DITHERING_ERROR: appendLogText(i18n("Warning: Dithering failed. Resuming capture...")); resumeCapture(); break; @@ -4266,7 +4266,7 @@ calibrationStage = CAL_PRECAPTURE_COMPLETE; - if (guideState == GUIDE_SUSPENDED) + if (guideState == Ekos::GuideState::GUIDE_SUSPENDED) { appendLogText(i18n("Autoguiding resumed.")); emit resumeGuiding(); @@ -4276,7 +4276,7 @@ return IPS_OK; } - if (activeJob->getFrameType() != FRAME_LIGHT && guideState == GUIDE_GUIDING) + if (activeJob->getFrameType() != FRAME_LIGHT && guideState == Ekos::GuideState::GUIDE_GUIDING) { appendLogText(i18n("Autoguiding suspended.")); emit suspendGuiding(); @@ -4974,7 +4974,7 @@ { currentFilterPosition = filterManager->getFilterPosition(); // Due to race condition, - focusState = FOCUS_IDLE; + focusState = Ekos::FocusState::FOCUS_IDLE; if (activeJob) activeJob->setCurrentFilter(currentFilterPosition); @@ -4993,20 +4993,20 @@ connect(filterManager.data(), &FilterManager::newStatus, [this](Ekos::FilterState filterState) { - if (state == CAPTURE_CHANGING_FILTER) + if (state == Ekos::CaptureState::CAPTURE_CHANGING_FILTER) { secondsLabel->setText(Ekos::getFilterStatusString(filterState)); switch (filterState) { - case FILTER_OFFSET: + case Ekos::FilterState::FILTER_OFFSET: appendLogText(i18n("Changing focus offset by %1 steps...", filterManager->getTargetFilterOffset())); break; - case FILTER_CHANGE: + case Ekos::FilterState::FILTER_CHANGE: appendLogText(i18n("Changing filter to %1...", FilterPosCombo->itemText(filterManager->getTargetFilterPosition()-1))); break; - case FILTER_AUTOFOCUS: + case Ekos::FilterState::FILTER_AUTOFOCUS: appendLogText(i18n("Auto focus on filter change...")); clearAutoFocusHFR(); break; Index: kstars/ekos/capture/sequencejob.cpp =================================================================== --- kstars/ekos/capture/sequencejob.cpp +++ kstars/ekos/capture/sequencejob.cpp @@ -136,7 +136,7 @@ { prepareActions[ACTION_FILTER] = false; - emit prepareState(CAPTURE_CHANGING_FILTER); + emit prepareState(Ekos::CaptureState::CAPTURE_CHANGING_FILTER); FilterManager::FilterPolicy policy = FilterManager::ALL_POLICIES; // Don't perform autofocus on preview @@ -155,7 +155,7 @@ if (enforceTemperature && fabs(targetTemperature - currentTemperature) > Options::maxTemperatureDiff()) { prepareActions[ACTION_TEMPERATURE] = false; - emit prepareState(CAPTURE_SETTING_TEMPERATURE); + emit prepareState(Ekos::CaptureState::CAPTURE_SETTING_TEMPERATURE); activeCCD->setTemperature(targetTemperature); } @@ -165,7 +165,7 @@ // PA = RawAngle * Multiplier + Offset double rawAngle = (targetRotation - Options::pAOffset()) / Options::pAMultiplier(); prepareActions[ACTION_ROTATOR] = false; - emit prepareState(CAPTURE_SETTING_ROTATOR); + emit prepareState(Ekos::CaptureState::CAPTURE_SETTING_ROTATOR); activeRotator->runCommand(INDI_SET_ROTATOR_ANGLE, &rawAngle); } Index: kstars/ekos/ekos.h =================================================================== --- kstars/ekos/ekos.h +++ kstars/ekos/ekos.h @@ -39,7 +39,8 @@ I18N_NOOP("Dithering successful"), I18N_NOOP("Settling")}; -typedef enum { +enum class GuideState : int +{ GUIDE_IDLE, GUIDE_ABORTED, GUIDE_CONNECTED, @@ -59,7 +60,7 @@ GUIDE_DITHERING_ERROR, GUIDE_DITHERING_SUCCESS, GUIDE_DITHERING_SETTLE -} GuideState; +}; const QString &getGuideStatusString(GuideState state); @@ -72,8 +73,9 @@ I18N_NOOP("Complete") }; -typedef enum { - CAPTURE_IDLE, +enum class CaptureState : int +{ + CAPTURE_IDLE = 0, CAPTURE_PROGRESS, CAPTURE_CAPTURING, CAPTURE_PAUSED, @@ -90,7 +92,7 @@ CAPTURE_CALIBRATING, CAPTURE_MERIDIAN_FLIP, CAPTURE_COMPLETE -} CaptureState; +}; const QString &getCaptureStatusString(CaptureState state); @@ -99,8 +101,9 @@ I18N_NOOP("Aborted"), I18N_NOOP("User Input"), I18N_NOOP("In Progress"), I18N_NOOP("Framing"), I18N_NOOP("Changing Filter") }; -typedef enum { - FOCUS_IDLE, +enum class FocusState : int +{ + FOCUS_IDLE = 0, FOCUS_COMPLETE, FOCUS_FAILED, FOCUS_ABORTED, @@ -108,7 +111,7 @@ FOCUS_PROGRESS, FOCUS_FRAMING, FOCUS_CHANGING_FILTER -} FocusState; +}; const QString &getFocusStatusString(FocusState state); @@ -117,28 +120,29 @@ I18N_NOOP("Aborted"), I18N_NOOP("In Progress"), I18N_NOOP("Syncing"), I18N_NOOP("Slewing") }; -typedef enum { - ALIGN_IDLE, +enum class AlignState : int +{ + ALIGN_IDLE = 0, ALIGN_COMPLETE, ALIGN_FAILED, ALIGN_ABORTED, ALIGN_PROGRESS, ALIGN_SYNCING, ALIGN_SLEWING -} AlignState; +}; const QString &getAlignStatusString(AlignState state); // Filter Manager States static const QStringList filterStates = { I18N_NOOP("Idle"), I18N_NOOP("Changing Filter"), I18N_NOOP("Focus Offset"), I18N_NOOP("Auto Focus")}; -typedef enum +enum class FilterState : int { - FILTER_IDLE, + FILTER_IDLE = 0, FILTER_CHANGE, FILTER_OFFSET, FILTER_AUTOFOCUS -} FilterState; +}; const QString &getFilterStatusString(FilterState state); Index: kstars/ekos/ekos.cpp =================================================================== --- kstars/ekos/ekos.cpp +++ kstars/ekos/ekos.cpp @@ -7,36 +7,38 @@ version 2 of the License, or (at your option) any later version. */ +#include "ekos.h" + +#include "kstarsenum.h" + +#include + #include #include #include #include -#include - -#include "ekos.h" - namespace Ekos { const QString &getGuideStatusString(GuideState state) { - return guideStates[state]; + return guideStates[KStarsEnum::toType(state)]; } const QString &getCaptureStatusString(CaptureState state) { - return captureStates[state]; + return captureStates[KStarsEnum::toType(state)]; } const QString &getFocusStatusString(FocusState state) { - return focusStates[state]; + return focusStates[KStarsEnum::toType(state)]; } const QString &getAlignStatusString(AlignState state) { - return alignStates[state]; + return alignStates[KStarsEnum::toType(state)]; } const QString &getFilterStatusString(FilterState state) { - return filterStates[state]; + return filterStates[KStarsEnum::toType(state)]; } /* Taken from http://codereview.stackexchange.com/questions/71300/wrapper-function-to-do-polynomial-fits-with-gsl */ Index: kstars/ekos/ekosmanager.cpp =================================================================== --- kstars/ekos/ekosmanager.cpp +++ kstars/ekos/ekosmanager.cpp @@ -2349,9 +2349,9 @@ sequenceCountDown.setHMS(0, 0, 0); sequenceCountDown = sequenceCountDown.addSecs(captureProcess->getActiveJobRemainingTime()); - if (status != Ekos::CAPTURE_ABORTED && status != Ekos::CAPTURE_COMPLETE) + if (status != Ekos::CaptureState::CAPTURE_ABORTED && status != Ekos::CaptureState::CAPTURE_COMPLETE) { - if (status == Ekos::CAPTURE_CAPTURING) + if (status == Ekos::CaptureState::CAPTURE_CAPTURING) capturePI->setColor(Qt::darkGreen); else capturePI->setColor(QColor(KStarsData::Instance()->colorScheme()->colorNamed("TargetColor"))); @@ -2453,13 +2453,14 @@ { focusStatus->setText(Ekos::getFocusStatusString(status)); - if (status >= Ekos::FOCUS_PROGRESS) + if (status >= Ekos::FocusState::FOCUS_PROGRESS) { focusPI->setColor(QColor(KStarsData::Instance()->colorScheme()->colorNamed("TargetColor"))); if (focusPI->isAnimated() == false) focusPI->startAnimation(); } - else if (status == Ekos::FOCUS_COMPLETE && Options::enforceAutofocus() && captureProcess->getActiveJobID() != -1) + else if (status == Ekos::FocusState::FOCUS_COMPLETE && Options::enforceAutofocus() && + captureProcess->getActiveJobID() != -1) { focusPI->setColor(Qt::darkGreen); if (focusPI->isAnimated() == false) @@ -2478,32 +2479,32 @@ switch (status) { - case Ekos::GUIDE_IDLE: - case Ekos::GUIDE_CALIBRATION_ERROR: - case Ekos::GUIDE_ABORTED: - case Ekos::GUIDE_SUSPENDED: - case Ekos::GUIDE_DITHERING_ERROR: - case Ekos::GUIDE_CALIBRATION_SUCESS: + case Ekos::GuideState::GUIDE_IDLE: + case Ekos::GuideState::GUIDE_CALIBRATION_ERROR: + case Ekos::GuideState::GUIDE_ABORTED: + case Ekos::GuideState::GUIDE_SUSPENDED: + case Ekos::GuideState::GUIDE_DITHERING_ERROR: + case Ekos::GuideState::GUIDE_CALIBRATION_SUCESS: if (guidePI->isAnimated()) guidePI->stopAnimation(); break; - case Ekos::GUIDE_CALIBRATING: + case Ekos::GuideState::GUIDE_CALIBRATING: guidePI->setColor(QColor(KStarsData::Instance()->colorScheme()->colorNamed("TargetColor"))); if (guidePI->isAnimated() == false) guidePI->startAnimation(); break; - case Ekos::GUIDE_GUIDING: + case Ekos::GuideState::GUIDE_GUIDING: guidePI->setColor(Qt::darkGreen); if (guidePI->isAnimated() == false) guidePI->startAnimation(); break; - case Ekos::GUIDE_DITHERING: + case Ekos::GuideState::GUIDE_DITHERING: guidePI->setColor(QColor(KStarsData::Instance()->colorScheme()->colorNamed("TargetColor"))); if (guidePI->isAnimated() == false) guidePI->startAnimation(); break; - case Ekos::GUIDE_DITHERING_SUCCESS: + case Ekos::GuideState::GUIDE_DITHERING_SUCCESS: guidePI->setColor(Qt::darkGreen); if (guidePI->isAnimated() == false) guidePI->startAnimation(); Index: kstars/ekos/focus/focus.h =================================================================== --- kstars/ekos/focus/focus.h +++ kstars/ekos/focus/focus.h @@ -9,6 +9,7 @@ #pragma once +#include "kstarsenum.h" #include "ui_focus.h" #include "ekos/ekos.h" #include "ekos/auxiliary/filtermanager.h" @@ -129,7 +130,7 @@ * Return state of Focuser modue (Ekos::FocusState) */ - Q_SCRIPTABLE int getStatus() { return state; } + Q_SCRIPTABLE int getStatus() { return KStarsEnum::toType(state); } /** @}*/ @@ -479,7 +480,7 @@ QPixmap profilePixmap; /// State - Ekos::FocusState state { Ekos::FOCUS_IDLE }; + Ekos::FocusState state { Ekos::FocusState::FOCUS_IDLE }; /// FITS Scale FITSScale defaultScale; Index: kstars/ekos/focus/focus.cpp =================================================================== --- kstars/ekos/focus/focus.cpp +++ kstars/ekos/focus/focus.cpp @@ -730,7 +730,7 @@ emit suspendGuiding(); //emit statusUpdated(true); - state = Ekos::FOCUS_PROGRESS; + state = Ekos::FocusState::FOCUS_PROGRESS; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); @@ -809,7 +809,7 @@ //emit statusUpdated(false); if (aborted) { - state = Ekos::FOCUS_ABORTED; + state = Ekos::FocusState::FOCUS_ABORTED; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); } @@ -1336,7 +1336,7 @@ focusBoxSize->value() / subBinX, focusBoxSize->value() / subBinY)); focusView->setTrackingBoxEnabled(true); - state = Ekos::FOCUS_WAITING; + state = Ekos::FocusState::FOCUS_WAITING; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); @@ -1432,7 +1432,7 @@ focusBoxSize->value() / subBinX, focusBoxSize->value() / subBinY)); focusView->setTrackingBoxEnabled(true); - state = Ekos::FOCUS_WAITING; + state = Ekos::FocusState::FOCUS_WAITING; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); @@ -1498,9 +1498,9 @@ if (inAutoFocus == false) return; - if (state != Ekos::FOCUS_PROGRESS) + if (state != Ekos::FocusState::FOCUS_PROGRESS) { - state = Ekos::FOCUS_PROGRESS; + state = Ekos::FocusState::FOCUS_PROGRESS; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); } @@ -2207,7 +2207,7 @@ clearDataPoints(); //emit statusUpdated(true); - state = Ekos::FOCUS_FRAMING; + state = Ekos::FocusState::FOCUS_FRAMING; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); @@ -2298,7 +2298,7 @@ void Focus::focusStarSelected(int x, int y) { - if (state == Ekos::FOCUS_PROGRESS) + if (state == Ekos::FocusState::FOCUS_PROGRESS) return; if (subFramed == false) @@ -2415,7 +2415,7 @@ } waitStarSelectTimer.stop(); - state = inAutoFocus ? FOCUS_PROGRESS : FOCUS_IDLE; + state = inAutoFocus ? Ekos::FocusState::FOCUS_PROGRESS : Ekos::FocusState::FOCUS_IDLE; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); @@ -2516,12 +2516,12 @@ if (status) { KNotification::event(QLatin1String("FocusSuccessful"), i18n("Autofocus operation completed successfully")); - state = Ekos::FOCUS_COMPLETE; + state = Ekos::FocusState::FOCUS_COMPLETE; } else { KNotification::event(QLatin1String("FocusFailed"), i18n("Autofocus operation failed with errors")); - state = Ekos::FOCUS_FAILED; + state = Ekos::FocusState::FOCUS_FAILED; } qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); @@ -2552,9 +2552,9 @@ abort(); setAutoFocusResult(false); } - else if (state == FOCUS_WAITING) + else if (state == Ekos::FocusState::FOCUS_WAITING) { - state = FOCUS_IDLE; + state = Ekos::FocusState::FOCUS_IDLE; qCDebug(KSTARS_EKOS_FOCUS) << "State:" << Ekos::getFocusStatusString(state); emit newStatus(state); } @@ -2847,7 +2847,7 @@ connect(this, &Focus::newStatus, [this](Ekos::FocusState state) { - if (FilterPosCombo->currentIndex() != -1 && canAbsMove && state == Ekos::FOCUS_COMPLETE) + if (FilterPosCombo->currentIndex() != -1 && canAbsMove && state == Ekos::FocusState::FOCUS_COMPLETE) { filterManager->setFilterAbsoluteFocusPosition(FilterPosCombo->currentIndex(), currentPosition); } Index: kstars/ekos/guide/externalguide/linguider.cpp =================================================================== --- kstars/ekos/guide/externalguide/linguider.cpp +++ kstars/ekos/guide/externalguide/linguider.cpp @@ -44,7 +44,7 @@ } // Already connected, let's connect equipment else - emit newStatus(GUIDE_CONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_CONNECTED); return true; } @@ -55,7 +55,7 @@ connection = DISCONNECTED; tcpSocket->disconnectFromHost(); - emit newStatus(GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); return true; } @@ -68,12 +68,12 @@ break; case QAbstractSocket::HostNotFoundError: emit newLog(i18n("The host was not found. Please check the host name and port settings in Guide options.")); - emit newStatus(GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); break; case QAbstractSocket::ConnectionRefusedError: emit newLog(i18n("The connection was refused by the peer. Make sure the LinGuider is running, and check " "that the host name and port settings are correct.")); - emit newStatus(GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); break; default: emit newLog(i18n("The following error occurred: %1.", tcpSocket->errorString())); @@ -128,7 +128,7 @@ if (reply == "Error: Guiding not started.") { state = IDLE; - emit newStatus(GUIDE_ABORTED); + emit newStatus(Ekos::GuideState::GUIDE_ABORTED); deviationTimer.stop(); return; } @@ -151,7 +151,7 @@ if (reply == "GUIDING") { state = GUIDING; - emit newStatus(GUIDE_GUIDING); + emit newStatus(Ekos::GuideState::GUIDE_GUIDING); deviationTimer.start(); } else @@ -173,7 +173,7 @@ else { emit newLog(i18n("Failed to process star position.")); - emit newStatus(GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); } } break; @@ -186,19 +186,19 @@ else { emit newLog(i18n("Failed to set guider reticle position.")); - emit newStatus(GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); } break; case SET_GUIDER_SQUARE_POS: if (reply == "OK") { - emit newStatus(GUIDE_CALIBRATION_SUCESS); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_SUCESS); } else { emit newLog(i18n("Failed to set guider square position.")); - emit newStatus(GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); } break; @@ -207,14 +207,14 @@ { if (state == IDLE) { - emit newStatus(GUIDE_GUIDING); + emit newStatus(Ekos::GuideState::GUIDE_GUIDING); state = GUIDING; deviationTimer.start(); } else { - emit newStatus(GUIDE_IDLE); + emit newStatus(Ekos::GuideState::GUIDE_IDLE); state = IDLE; deviationTimer.stop(); @@ -234,7 +234,7 @@ if (state != GUIDING) { state = GUIDING; - emit newStatus(GUIDE_GUIDING); + emit newStatus(Ekos::GuideState::GUIDE_GUIDING); } QStringList pos = reply.split(' '); @@ -270,9 +270,9 @@ case DITHER: if (reply == "Long time cmd finished") - emit newStatus(GUIDE_DITHERING_SUCCESS); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_SUCCESS); else - emit newStatus(GUIDE_DITHERING_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); state = GUIDING; deviationTimer.start(); @@ -287,7 +287,7 @@ { connection = CONNECTED; - emit newStatus(GUIDE_CONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_CONNECTED); // Get version sendCommand(GET_VER); @@ -323,7 +323,7 @@ bool LinGuider::calibrate() { // Let's start calibraiton. It is already calibrated but in this step we auto-select and star and set the square - emit newStatus(Ekos::GUIDE_CALIBRATING); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATING); sendCommand(FIND_STAR); Index: kstars/ekos/guide/externalguide/phd2.cpp =================================================================== --- kstars/ekos/guide/externalguide/phd2.cpp +++ kstars/ekos/guide/externalguide/phd2.cpp @@ -120,13 +120,13 @@ if (Options::ditherFailAbortsAutoGuide()) { state = DITHER_FAILED; - emit newStatus(GUIDE_DITHERING_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); } else { emit newLog(i18n("PHD2: There was no dithering response from PHD2, but continue guiding.")); state = GUIDING; - emit newStatus(Ekos::GUIDE_DITHERING_SUCCESS); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_SUCCESS); } }); } @@ -156,7 +156,7 @@ connection = DISCONNECTED; tcpSocket->disconnectFromHost(); - emit newStatus(GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); return true; } @@ -169,12 +169,12 @@ break; case QAbstractSocket::HostNotFoundError: emit newLog(i18n("The host was not found. Please check the host name and port settings in Guide options.")); - emit newStatus(GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); break; case QAbstractSocket::ConnectionRefusedError: emit newLog(i18n("The connection was refused by the peer. Make sure the PHD2 is running, and check that " "the host name and port settings are correct.")); - emit newStatus(GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); break; default: emit newLog(i18n("The following error occurred: %1.", tcpSocket->errorString())); @@ -257,7 +257,7 @@ state = GUIDING; setEquipmentConnected(); emit newLog(i18n("PHD2: Calibration Complete.")); - emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_SUCESS); break; case StartGuiding: @@ -265,19 +265,19 @@ setEquipmentConnected(); updateGuideParameters(); emit newLog(i18n("PHD2: Guiding Started.")); - emit newStatus(Ekos::GUIDE_GUIDING); + emit newStatus(Ekos::GuideState::GUIDE_GUIDING); break; case Paused: state = PAUSED; emit newLog(i18n("PHD2: Guiding Paused.")); - emit newStatus(Ekos::GUIDE_SUSPENDED); + emit newStatus(Ekos::GuideState::GUIDE_SUSPENDED); break; case StartCalibration: state = CALIBRATING; emit newLog(i18n("PHD2: Calibration Started.")); - emit newStatus(Ekos::GUIDE_CALIBRATING); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATING); break; case AppState: @@ -287,7 +287,7 @@ case CalibrationFailed: state = CALIBRATION_FAILED; emit newLog(i18n("PHD2: Calibration Failed (%1).", jsonEvent["Reason"].toString())); - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); break; case CalibrationDataFlipped: @@ -330,14 +330,14 @@ if (error && Options::ditherFailAbortsAutoGuide()) { state = DITHER_FAILED; - emit newStatus(GUIDE_DITHERING_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); } else { if(error) emit newLog(i18n("PHD2: There was a dithering error, but continue guiding.")); state = GUIDING; - emit newStatus(Ekos::GUIDE_DITHERING_SUCCESS); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_SUCCESS); } } } @@ -359,12 +359,12 @@ case GuidingStopped: emit newLog(i18n("PHD2: Guiding Stopped.")); state = STOPPED; - emit newStatus(Ekos::GUIDE_IDLE); + emit newStatus(Ekos::GuideState::GUIDE_IDLE); break; case Resumed: emit newLog(i18n("PHD2: Guiding Resumed.")); - emit newStatus(Ekos::GUIDE_GUIDING); + emit newStatus(Ekos::GuideState::GUIDE_GUIDING); state = GUIDING; break; @@ -381,7 +381,7 @@ else if(state != GUIDING) { emit newLog(i18n("PHD2: Guiding started up again.")); - emit newStatus(Ekos::GUIDE_GUIDING); + emit newStatus(Ekos::GuideState::GUIDE_GUIDING); state = GUIDING; } double diff_ra_pixels, diff_de_pixels, diff_ra_arcsecs, diff_de_arcsecs, pulse_ra, pulse_dec; @@ -440,7 +440,7 @@ if(state == GUIDING) { state = DITHERING; - emit newStatus(Ekos::GUIDE_DITHERING); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING); } break; @@ -451,7 +451,7 @@ case LockPositionLost: emit newLog(i18n("PHD2: Lock Position Lost.")); if (state == CALIBRATING) - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); break; case Alert: @@ -509,7 +509,7 @@ case DITHER_COMMAND_RECEIVED: //dither state = DITHERING; - emit newStatus(Ekos::GUIDE_DITHERING); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING); break; //find_star @@ -530,7 +530,7 @@ else { connection = EQUIPMENT_DISCONNECTED; - emit newStatus(Ekos::GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); } } break; @@ -653,18 +653,18 @@ else if(resultRequest == CONNECTION_RESULT) { connection = EQUIPMENT_DISCONNECTED; - emit newStatus(Ekos::GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); } else if(resultRequest == DITHER_COMMAND_RECEIVED && state == DITHERING) { ditherTimer->stop(); state = DITHER_FAILED; - emit newStatus(GUIDE_DITHERING_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); if (Options::ditherFailAbortsAutoGuide()) { state = STOPPED; - emit newStatus(GUIDE_ABORTED); + emit newStatus(Ekos::GuideState::GUIDE_ABORTED); } else { @@ -732,7 +732,7 @@ { setConnectedRetries = 0; connection = EQUIPMENT_CONNECTED; - emit newStatus(Ekos::GUIDE_CONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_CONNECTED); updateGuideParameters(); QTimer::singleShot(800, [=]{requestExposureDurations();}); } @@ -870,7 +870,7 @@ if (state == GUIDING) { emit newLog(i18n("PHD2: Guiding is already running.")); - emit newStatus(Ekos::GUIDE_GUIDING); + emit newStatus(Ekos::GuideState::GUIDE_GUIDING); return true; } @@ -911,7 +911,7 @@ { setConnectedRetries = 0; connection = EQUIPMENT_DISCONNECTED; - emit newStatus(Ekos::GUIDE_DISCONNECTED); + emit newStatus(Ekos::GuideState::GUIDE_DISCONNECTED); return; } @@ -1035,7 +1035,7 @@ bool PHD2::calibrate() { // We don't explicitly do calibration since it is done in the guide step by PHD2 anyway - //emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); + //emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_SUCESS); return true; } Index: kstars/ekos/guide/guide.h =================================================================== --- kstars/ekos/guide/guide.h +++ kstars/ekos/guide/guide.h @@ -9,6 +9,7 @@ #pragma once +#include "kstarsenum.h" #include "ui_guide.h" #include "ekos/ekos.h" #include "indi/indiccd.h" @@ -23,7 +24,6 @@ class FITSView; class FITSViewer; -class ScrollGraph; namespace Ekos { @@ -93,7 +93,7 @@ * @brief getStatus Return guide module status * @return state of guide module from Ekos::GuideState */ - Q_SCRIPTABLE uint getStatus() { return state; } + Q_SCRIPTABLE uint getStatus() { return KStarsEnum::toType(state); } /** DBUS interface function. * @return Returns guiding deviation from guide star in arcsecs. First elemenet is RA guiding deviation, second element is DEC guiding deviation. @@ -560,14 +560,17 @@ QPointer linGuider; QPointer fv; - double primaryFL = -1, primaryAperture = -1, guideFL = -1, guideAperture = -1; + double primaryFL { -1 }; + double primaryAperture { -1 }; + double guideFL { -1 }; + double guideAperture { -1 }; QCPCurve *centralTarget { nullptr }; QCPCurve *yellowTarget { nullptr }; QCPCurve *redTarget { nullptr }; QCPCurve *concentricRings { nullptr }; - bool graphOnLatestPt=true; + bool graphOnLatestPt { true }; QUrl guideURLPath; }; } Index: kstars/ekos/guide/guide.cpp =================================================================== --- kstars/ekos/guide/guide.cpp +++ kstars/ekos/guide/guide.cpp @@ -192,7 +192,7 @@ // Capture connect(captureB, &QPushButton::clicked, this, [this]() { - state = GUIDE_CAPTURE; + state = Ekos::GuideState::GUIDE_CAPTURE; emit newStatus(state); capture(); @@ -200,7 +200,7 @@ connect(loopB, &QPushButton::clicked, this, [this]() { - state = GUIDE_LOOPING; + state = Ekos::GuideState::GUIDE_LOOPING; emit newStatus(state); capture(); @@ -449,7 +449,7 @@ internalGuider->setGuideView(guideView); - state = GUIDE_IDLE; + state = Ekos::GuideState::GUIDE_IDLE; // Set current guide type setGuiderType(-1); @@ -1148,7 +1148,7 @@ bool Guide::capture() { - buildOperationStack(GUIDE_CAPTURE); + buildOperationStack(Ekos::GuideState::GUIDE_CAPTURE); return executeOperationStack(); } @@ -1195,7 +1195,7 @@ #if 0 switch (state) { - case GUIDE_GUIDING: + case Ekos::GuideState::GUIDE_GUIDING: if (Options::rapidGuideEnabled() == false) connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB *)), this, SLOT(newFITS(IBLOB *)), Qt::UniqueConnection); targetChip->capture(seqExpose); @@ -1216,7 +1216,7 @@ // Increase exposure for calibration frame if we need auto-select a star // To increase chances we detect one. - if (operationStack.contains(GUIDE_STAR_SELECT) && Options::guideAutoStarEnabled()) + if (operationStack.contains(Ekos::GuideState::GUIDE_STAR_SELECT) && Options::guideAutoStarEnabled()) finalExposure *= 3; // Timeout is exposure duration + timeout threshold in seconds @@ -1243,20 +1243,20 @@ switch (state) { - case GUIDE_IDLE: - case GUIDE_CONNECTED: + case Ekos::GuideState::GUIDE_IDLE: + case Ekos::GuideState::GUIDE_CONNECTED: setBLOBEnabled(false); break; - case GUIDE_DISCONNECTED: + case Ekos::GuideState::GUIDE_DISCONNECTED: setBLOBEnabled(true); break; - case GUIDE_CALIBRATING: - case GUIDE_DITHERING: - case GUIDE_STAR_SELECT: - case GUIDE_CAPTURE: - case GUIDE_GUIDING: - case GUIDE_LOOPING: + case Ekos::GuideState::GUIDE_CALIBRATING: + case Ekos::GuideState::GUIDE_DITHERING: + case Ekos::GuideState::GUIDE_STAR_SELECT: + case Ekos::GuideState::GUIDE_CAPTURE: + case Ekos::GuideState::GUIDE_GUIDING: + case Ekos::GuideState::GUIDE_LOOPING: guider->abort(); default: break; @@ -1316,11 +1316,11 @@ if (captureTimeoutCounter >= 3) { captureTimeoutCounter = 0; - if (state == GUIDE_GUIDING) + if (state == Ekos::GuideState::GUIDE_GUIDING) appendLogText(i18n("Exposure timeout. Aborting Autoguide.")); - else if (state == GUIDE_DITHERING) + else if (state == Ekos::GuideState::GUIDE_DITHERING) appendLogText(i18n("Exposure timeout. Aborting Dithering.")); - else if (state == GUIDE_CALIBRATING) + else if (state == Ekos::GuideState::GUIDE_CALIBRATING) appendLogText(i18n("Exposure timeout. Aborting Calibration.")); abort(); @@ -1388,43 +1388,43 @@ switch (state) { - case GUIDE_IDLE: - case GUIDE_ABORTED: - case GUIDE_CONNECTED: - case GUIDE_DISCONNECTED: - case GUIDE_CALIBRATION_SUCESS: - case GUIDE_CALIBRATION_ERROR: - case GUIDE_DITHERING_ERROR: + case Ekos::GuideState::GUIDE_IDLE: + case Ekos::GuideState::GUIDE_ABORTED: + case Ekos::GuideState::GUIDE_CONNECTED: + case Ekos::GuideState::GUIDE_DISCONNECTED: + case Ekos::GuideState::GUIDE_CALIBRATION_SUCESS: + case Ekos::GuideState::GUIDE_CALIBRATION_ERROR: + case Ekos::GuideState::GUIDE_DITHERING_ERROR: setBusy(false); break; - case GUIDE_CAPTURE: - state = GUIDE_IDLE; + case Ekos::GuideState::GUIDE_CAPTURE: + state = Ekos::GuideState::GUIDE_IDLE; emit newStatus(state); setBusy(false); break; - case GUIDE_LOOPING: + case Ekos::GuideState::GUIDE_LOOPING: capture(); break; - case GUIDE_CALIBRATING: + case Ekos::GuideState::GUIDE_CALIBRATING: guider->calibrate(); break; - case GUIDE_GUIDING: + case Ekos::GuideState::GUIDE_GUIDING: guider->guide(); break; - case GUIDE_DITHERING: + case Ekos::GuideState::GUIDE_DITHERING: guider->dither(Options::ditherPixels()); break; - case GUIDE_REACQUIRE: + case Ekos::GuideState::GUIDE_REACQUIRE: guider->reacquire(); break; - case GUIDE_DITHERING_SETTLE: + case Ekos::GuideState::GUIDE_DITHERING_SETTLE: if (Options::ditherNoGuiding()) return; capture(); @@ -1470,7 +1470,7 @@ if (GuideDriver == nullptr || (ra_dir == NO_DIR && dec_dir == NO_DIR)) return false; - if (state == GUIDE_CALIBRATING) + if (state == Ekos::GuideState::GUIDE_CALIBRATING) pulseTimer.start((ra_msecs > dec_msecs ? ra_msecs : dec_msecs) + 100); return GuideDriver->doPulse(ra_dir, ra_msecs, dec_dir, dec_msecs); @@ -1481,7 +1481,7 @@ if (GuideDriver == nullptr || dir == NO_DIR) return false; - if (state == GUIDE_CALIBRATING) + if (state == Ekos::GuideState::GUIDE_CALIBRATING) pulseTimer.start(msecs + 100); return GuideDriver->doPulse(dir, msecs); @@ -1535,7 +1535,7 @@ if (guider->dither() == false) { appendLogText(i18n("Dithering failed. Autoguiding aborted.")); - emit newStatus(GUIDE_DITHERING_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); guider->abort(); //emit ditherFailed(); } @@ -1585,7 +1585,7 @@ bool Guide::calibrate() { // Set status to idle and let the operations change it as they get executed - state = GUIDE_IDLE; + state = Ekos::GuideState::GUIDE_IDLE; emit newStatus(state); ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); @@ -1607,7 +1607,7 @@ saveSettings(); - buildOperationStack(GUIDE_CALIBRATING); + buildOperationStack(Ekos::GuideState::GUIDE_CALIBRATING); executeOperationStack(); @@ -1633,13 +1633,13 @@ bool Guide::dither() { - if (Options::ditherNoGuiding() && state == GUIDE_IDLE) + if (Options::ditherNoGuiding() && state == Ekos::GuideState::GUIDE_IDLE) { ditherDirectly(); return true; } - if (state == GUIDE_DITHERING || state == GUIDE_DITHERING_SETTLE) + if (state == Ekos::GuideState::GUIDE_DITHERING || state == Ekos::GuideState::GUIDE_DITHERING_SETTLE) return true; //This adds a dither text item to the graph where dithering occurred. @@ -1656,10 +1656,10 @@ if (guiderType == GUIDE_INTERNAL) { - if (state != GUIDE_GUIDING) + if (state != Ekos::GuideState::GUIDE_GUIDING) capture(); - setStatus(GUIDE_DITHERING); + setStatus(Ekos::GuideState::GUIDE_DITHERING); return true; } @@ -1669,9 +1669,9 @@ bool Guide::suspend() { - if (state == GUIDE_SUSPENDED) + if (state == Ekos::GuideState::GUIDE_SUSPENDED) return true; - else if (state >= GUIDE_CAPTURE) + else if (state >= Ekos::GuideState::GUIDE_CAPTURE) return guider->suspend(); else return false; @@ -1679,9 +1679,9 @@ bool Guide::resume() { - if (state == GUIDE_GUIDING) + if (state == Ekos::GuideState::GUIDE_GUIDING) return true; - else if (state == GUIDE_SUSPENDED) + else if (state == Ekos::GuideState::GUIDE_SUSPENDED) return guider->resume(); else return false; @@ -1691,7 +1691,7 @@ { switch (newState) { - case CAPTURE_DITHERING: + case Ekos::CaptureState::CAPTURE_DITHERING: dither(); break; @@ -1703,7 +1703,8 @@ void Guide::setMountStatus(ISD::Telescope::TelescopeStatus newState) { // If we're guiding, and the mount either slews or parks, then we abort. - if ((state == GUIDE_GUIDING || state == GUIDE_DITHERING) && (newState == ISD::Telescope::MOUNT_PARKING || newState == ISD::Telescope::MOUNT_SLEWING)) + if ((state == Ekos::GuideState::GUIDE_GUIDING || state == Ekos::GuideState::GUIDE_DITHERING) && + (newState == ISD::Telescope::MOUNT_PARKING || newState == ISD::Telescope::MOUNT_SLEWING)) { if (newState == ISD::Telescope::MOUNT_PARKING) appendLogText(i18n("Mount is parking! Aborting guide...")); @@ -1857,7 +1858,7 @@ switch (state) { - case GUIDE_CONNECTED: + case Ekos::GuideState::GUIDE_CONNECTED: appendLogText(i18n("External guider connected.")); externalConnectB->setEnabled(false); externalDisconnectB->setEnabled(true); @@ -1868,7 +1869,7 @@ setBLOBEnabled(false); break; - case GUIDE_DISCONNECTED: + case Ekos::GuideState::GUIDE_DISCONNECTED: appendLogText(i18n("External guider disconnected.")); setBusy(false); //This needs to come before caputureB since it will set it to enabled again. externalConnectB->setEnabled(true); @@ -1883,7 +1884,7 @@ #endif break; - case GUIDE_CALIBRATION_SUCESS: + case Ekos::GuideState::GUIDE_CALIBRATION_SUCESS: appendLogText(i18n("Calibration completed.")); calibrationComplete = true; /*if (autoCalibrateGuide) @@ -1897,19 +1898,22 @@ guide(); break; - case GUIDE_CALIBRATION_ERROR: - case GUIDE_IDLE: + case Ekos::GuideState::GUIDE_CALIBRATION_ERROR: + case Ekos::GuideState::GUIDE_IDLE: setBusy(false); break; - case GUIDE_CALIBRATING: + case Ekos::GuideState::GUIDE_CALIBRATING: appendLogText(i18n("Calibration started.")); setBusy(true); break; - case GUIDE_GUIDING: - if (previousState == GUIDE_SUSPENDED || previousState == GUIDE_DITHERING_SUCCESS) + case Ekos::GuideState::GUIDE_GUIDING: + if (previousState == Ekos::GuideState::GUIDE_SUSPENDED || + previousState == Ekos::GuideState::GUIDE_DITHERING_SUCCESS) + { appendLogText(i18n("Guiding resumed.")); + } else { appendLogText(i18n("Autoguiding started.")); @@ -1922,46 +1926,46 @@ break; - case GUIDE_ABORTED: + case Ekos::GuideState::GUIDE_ABORTED: appendLogText(i18n("Autoguiding aborted.")); setBusy(false); break; - case GUIDE_SUSPENDED: + case Ekos::GuideState::GUIDE_SUSPENDED: appendLogText(i18n("Guiding suspended.")); break; - case GUIDE_REACQUIRE: + case Ekos::GuideState::GUIDE_REACQUIRE: capture(); break; - case GUIDE_DITHERING: + case Ekos::GuideState::GUIDE_DITHERING: appendLogText(i18n("Dithering in progress.")); break; - case GUIDE_DITHERING_SETTLE: + case Ekos::GuideState::GUIDE_DITHERING_SETTLE: if (Options::ditherSettle() > 0) appendLogText(i18np("Post-dither settling for %1 second...", "Post-dither settling for %1 seconds...", Options::ditherSettle())); capture(); break; - case GUIDE_DITHERING_ERROR: + case Ekos::GuideState::GUIDE_DITHERING_ERROR: appendLogText(i18n("Dithering failed!")); // LinGuider guide continue after dithering failure if (guiderType != GUIDE_LINGUIDER) { - //state = GUIDE_IDLE; - state = GUIDE_ABORTED; + //state = Ekos::GuideState::GUIDE_IDLE; + state = Ekos::GuideState::GUIDE_ABORTED; setBusy(false); } break; - case GUIDE_DITHERING_SUCCESS: + case Ekos::GuideState::GUIDE_DITHERING_SUCCESS: appendLogText(i18n("Dithering completed successfully.")); // Go back to guiding state immediately if using regular guider if (Options::ditherNoGuiding() == false) { - setStatus(GUIDE_GUIDING); + setStatus(Ekos::GuideState::GUIDE_GUIDING); // Only capture again if we are using internal guider if (guiderType == GUIDE_INTERNAL) capture(); @@ -2012,7 +2016,8 @@ INDI_UNUSED(exposure); if (expState == IPS_ALERT && - ((state == GUIDE_GUIDING) || (state == GUIDE_DITHERING) || (state == GUIDE_CALIBRATING))) + ((state == Ekos::GuideState::GUIDE_GUIDING) || (state == Ekos::GuideState::GUIDE_DITHERING) || + (state == Ekos::GuideState::GUIDE_CALIBRATING))) { appendLogText(i18n("Exposure failed. Restarting exposure...")); currentCCD->setTransformFormat(ISD::CCD::FORMAT_FITS); @@ -2094,7 +2099,8 @@ else if (type == guiderType) return true; - if (state == GUIDE_CALIBRATING || state == GUIDE_GUIDING || state == GUIDE_DITHERING) + if (state == Ekos::GuideState::GUIDE_CALIBRATING || state == Ekos::GuideState::GUIDE_GUIDING || + state == Ekos::GuideState::GUIDE_DITHERING) { appendLogText(i18n("Cannot change guider type while active.")); return false; @@ -2561,7 +2567,7 @@ QVector3D newStarPosition(x, y, -1); setStarPosition(newStarPosition, true); - /*if (state == GUIDE_STAR_SELECT) + /*if (state == Ekos::GuideState::GUIDE_STAR_SELECT) { guider->setStarPosition(newStarPosition); guider->calibrate(); @@ -2749,38 +2755,38 @@ switch (operation) { - case GUIDE_CAPTURE: + case Ekos::GuideState::GUIDE_CAPTURE: if (Options::guideDarkFrameEnabled()) - operationStack.push(GUIDE_DARK); + operationStack.push(Ekos::GuideState::GUIDE_DARK); - operationStack.push(GUIDE_CAPTURE); - operationStack.push(GUIDE_SUBFRAME); + operationStack.push(Ekos::GuideState::GUIDE_CAPTURE); + operationStack.push(Ekos::GuideState::GUIDE_SUBFRAME); break; - case GUIDE_CALIBRATING: - operationStack.push(GUIDE_CALIBRATING); + case Ekos::GuideState::GUIDE_CALIBRATING: + operationStack.push(Ekos::GuideState::GUIDE_CALIBRATING); if (guiderType == GUIDE_INTERNAL && (starCenter.isNull() || (Options::guideAutoStarEnabled()))) { if (Options::guideDarkFrameEnabled()) - operationStack.push(GUIDE_DARK); + operationStack.push(Ekos::GuideState::GUIDE_DARK); // If subframe is enabled and we need to auto select a star, then we need to make the final capture // of the subframed image. This is only done if we aren't already subframed. if (subFramed == false && Options::guideSubframeEnabled() && Options::guideAutoStarEnabled()) - operationStack.push(GUIDE_CAPTURE); + operationStack.push(Ekos::GuideState::GUIDE_CAPTURE); // Do not subframe and auto-select star on Image Guiding mode if (Options::imageGuidingEnabled() == false) { - operationStack.push(GUIDE_SUBFRAME); - operationStack.push(GUIDE_STAR_SELECT); + operationStack.push(Ekos::GuideState::GUIDE_SUBFRAME); + operationStack.push(Ekos::GuideState::GUIDE_STAR_SELECT); } - operationStack.push(GUIDE_CAPTURE); + operationStack.push(Ekos::GuideState::GUIDE_CAPTURE); // If we are being ask to go full frame, let's do that first if (subFramed == true && Options::guideSubframeEnabled() == false) - operationStack.push(GUIDE_SUBFRAME); + operationStack.push(Ekos::GuideState::GUIDE_SUBFRAME); } break; @@ -2800,23 +2806,23 @@ switch (nextOperation) { - case GUIDE_SUBFRAME: + case Ekos::GuideState::GUIDE_SUBFRAME: actionRequired = executeOneOperation(nextOperation); break; - case GUIDE_DARK: + case Ekos::GuideState::GUIDE_DARK: actionRequired = executeOneOperation(nextOperation); break; - case GUIDE_CAPTURE: + case Ekos::GuideState::GUIDE_CAPTURE: actionRequired = captureOneFrame(); break; - case GUIDE_STAR_SELECT: + case Ekos::GuideState::GUIDE_STAR_SELECT: actionRequired = executeOneOperation(nextOperation); break; - case GUIDE_CALIBRATING: + case Ekos::GuideState::GUIDE_CALIBRATING: if (guiderType == GUIDE_INTERNAL) { guider->setStarPosition(starCenter); @@ -2825,7 +2831,7 @@ // No need to calibrate if (Options::imageGuidingEnabled()) { - setStatus(GUIDE_CALIBRATION_SUCESS); + setStatus(Ekos::GuideState::GUIDE_CALIBRATION_SUCESS); break; } @@ -2843,8 +2849,8 @@ } else { - emit newStatus(GUIDE_CALIBRATION_ERROR); - state = GUIDE_IDLE; + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); + state = Ekos::GuideState::GUIDE_IDLE; appendLogText(i18n("Calibration failed to start!")); setBusy(false); } @@ -2873,7 +2879,7 @@ switch (operation) { - case GUIDE_SUBFRAME: + case Ekos::GuideState::GUIDE_SUBFRAME: { // Do not subframe if we are capturing calibration frame if (subFramed == false && Options::guideSubframeEnabled() == true && targetChip->canSubframe()) @@ -2943,7 +2949,7 @@ } break; - case GUIDE_DARK: + case Ekos::GuideState::GUIDE_DARK: { // Do we need to take a dark frame? if (Options::guideDarkFrameEnabled()) @@ -2975,9 +2981,9 @@ } break; - case GUIDE_STAR_SELECT: + case Ekos::GuideState::GUIDE_STAR_SELECT: { - state = GUIDE_STAR_SELECT; + state = Ekos::GuideState::GUIDE_STAR_SELECT; emit newStatus(state); if (Options::guideAutoStarEnabled()) @@ -2991,7 +2997,7 @@ { appendLogText(i18n("Failed to select an auto star.")); actionRequired = true; - state = GUIDE_CALIBRATION_ERROR; + state = Ekos::GuideState::GUIDE_CALIBRATION_ERROR; emit newStatus(state); setBusy(false); } @@ -3099,15 +3105,15 @@ qCInfo(KSTARS_EKOS_GUIDE) << "Non-guiding dither successful."; QTimer::singleShot( (ra_msec > de_msec ? ra_msec : de_msec) + Options::ditherSettle() * 1000 + 100, [this]() { - emit newStatus(GUIDE_DITHERING_SUCCESS); - state = GUIDE_IDLE; + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_SUCCESS); + state = Ekos::GuideState::GUIDE_IDLE; }); } else { qCWarning(KSTARS_EKOS_GUIDE) << "Non-guiding dither failed."; - emit newStatus(GUIDE_DITHERING_ERROR); - state = GUIDE_IDLE; + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); + state = Ekos::GuideState::GUIDE_IDLE; } } Index: kstars/ekos/guide/guideinterface.h =================================================================== --- kstars/ekos/guide/guideinterface.h +++ kstars/ekos/guide/guideinterface.h @@ -70,7 +70,7 @@ void frameCaptureRequested(); protected: - Ekos::GuideState state { GUIDE_IDLE }; + Ekos::GuideState state { Ekos::GuideState::GUIDE_IDLE }; double ccdPixelSizeX { 0 }; double ccdPixelSizeY { 0 }; double mountAperture { 0 }; Index: kstars/ekos/guide/internalguide/internalguider.cpp =================================================================== --- kstars/ekos/guide/internalguide/internalguider.cpp +++ kstars/ekos/guide/internalguide/internalguider.cpp @@ -33,15 +33,15 @@ pmath.reset(new cgmath()); connect(pmath.get(), SIGNAL(newStarPosition(QVector3D,bool)), this, SIGNAL(newStarPosition(QVector3D,bool))); - state = GUIDE_IDLE; + state = Ekos::GuideState::GUIDE_IDLE; } bool InternalGuider::guide() { - if (state == GUIDE_SUSPENDED) + if (state == Ekos::GuideState::GUIDE_SUSPENDED) return true; - if (state >= GUIDE_GUIDING) + if (state >= Ekos::GuideState::GUIDE_GUIDING) { if (imageGuideEnabled) return processImageGuiding(); @@ -78,7 +78,7 @@ isFirstFrame = true; - state = GUIDE_GUIDING; + state = Ekos::GuideState::GUIDE_GUIDING; emit newStatus(state); emit frameCaptureRequested(); @@ -92,17 +92,18 @@ logFile.close(); - if (state == GUIDE_CALIBRATING || state == GUIDE_GUIDING || state == GUIDE_DITHERING) + if (state == Ekos::GuideState::GUIDE_CALIBRATING || state == Ekos::GuideState::GUIDE_GUIDING || + state == Ekos::GuideState::GUIDE_DITHERING) { - if (state == GUIDE_DITHERING) - emit newStatus(GUIDE_DITHERING_ERROR); - emit newStatus(GUIDE_ABORTED); + if (state == Ekos::GuideState::GUIDE_DITHERING) + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_ABORTED); qCDebug(KSTARS_EKOS_GUIDE) << "Aborting" << getGuideStatusString(state); } else { - emit newStatus(GUIDE_IDLE); + emit newStatus(Ekos::GuideState::GUIDE_IDLE); qCDebug(KSTARS_EKOS_GUIDE) << "Stopping internal guider."; } @@ -110,14 +111,14 @@ m_highPulseCounter=0; pmath->suspend(false); - state = GUIDE_IDLE; + state = Ekos::GuideState::GUIDE_IDLE; return true; } bool InternalGuider::suspend() { - state = GUIDE_SUSPENDED; + state = Ekos::GuideState::GUIDE_SUSPENDED; emit newStatus(state); pmath->suspend(true); @@ -127,7 +128,7 @@ bool InternalGuider::resume() { - state = GUIDE_GUIDING; + state = Ekos::GuideState::GUIDE_GUIDING; emit newStatus(state); pmath->suspend(false); @@ -152,7 +153,7 @@ //qDebug() << "Star Pos X " << cur_x << " Y " << cur_y; - if (state != GUIDE_DITHERING) + if (state != Ekos::GuideState::GUIDE_DITHERING) { retries = 0; @@ -176,7 +177,7 @@ pmath->setReticleParameters(target_pos.x, target_pos.y, ret_angle); - state = GUIDE_DITHERING; + state = Ekos::GuideState::GUIDE_DITHERING; emit newStatus(state); processGuiding(); @@ -197,7 +198,7 @@ if (Options::ditherSettle() > 0) { - state = GUIDE_DITHERING_SETTLE; + state = Ekos::GuideState::GUIDE_DITHERING_SETTLE; emit newStatus(state); } @@ -209,7 +210,7 @@ { if (Options::ditherFailAbortsAutoGuide()) { - emit newStatus(Ekos::GUIDE_DITHERING_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_ERROR); abort(); return false; } @@ -220,7 +221,7 @@ if (Options::ditherSettle() > 0) { - state = GUIDE_DITHERING_SETTLE; + state = Ekos::GuideState::GUIDE_DITHERING_SETTLE; emit newStatus(state); } @@ -237,10 +238,10 @@ void InternalGuider::setDitherSettled() { - emit newStatus(Ekos::GUIDE_DITHERING_SUCCESS); + emit newStatus(Ekos::GuideState::GUIDE_DITHERING_SUCCESS); // Back to guiding - state = GUIDE_GUIDING; + state = Ekos::GuideState::GUIDE_GUIDING; } bool InternalGuider::calibrate() @@ -270,11 +271,11 @@ return false; } - if (state != GUIDE_CALIBRATING) + if (state != Ekos::GuideState::GUIDE_CALIBRATING) { calibrationStage = CAL_IDLE; - state = GUIDE_CALIBRATING; - emit newStatus(GUIDE_CALIBRATING); + state = Ekos::GuideState::GUIDE_CALIBRATING; + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATING); } if (calibrationStage > CAL_START) @@ -313,7 +314,7 @@ reset(); calibrationStage = CAL_ERROR; - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); return; } @@ -342,7 +343,7 @@ void InternalGuider::reset() { - state = GUIDE_IDLE; + state = Ekos::GuideState::GUIDE_IDLE; //calibrationStage = CAL_IDLE; connect(guideFrame, SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int,int)), Qt::UniqueConnection); @@ -433,7 +434,7 @@ calibrationStage = CAL_ERROR; - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); KNotification::event(QLatin1String("CalibrationFailed"), i18n("Guiding calibration failed with errors")); @@ -513,7 +514,7 @@ calibrationStage = CAL_ERROR; - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); emit newLog(i18np("Guide RA: Scope cannot reach the start point after %1 iteration. Possible mount or " "backlash problems...", @@ -549,7 +550,7 @@ { calibrationStage = CAL_IDLE; - emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_SUCESS); KNotification::event(QLatin1String("CalibrationSuccessful"), i18n("Guiding calibration completed successfully")); @@ -560,7 +561,7 @@ calibrationStage = CAL_ERROR; - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); KNotification::event(QLatin1String("CalibrationFailed"), i18n("Guiding calibration failed with errors")); @@ -606,7 +607,7 @@ { calibrationStage = CAL_ERROR; - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); emit newLog(i18np("Guide DEC: Scope cannot reach the start point after %1 iteration.\nPossible mount " "or backlash problems...", @@ -687,7 +688,7 @@ calibrationStage = CAL_ERROR; - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); emit newLog(i18np("Guide DEC: Scope cannot reach the start point after %1 iteration.\nPossible mount " "or backlash problems...", @@ -713,7 +714,7 @@ else emit newLog(i18n("DEC swap disabled.")); - emit newStatus(Ekos::GUIDE_CALIBRATION_SUCESS); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_SUCESS); emit DESwapChanged(swap_dec); @@ -727,7 +728,7 @@ { emit newLog(i18n("Calibration rejected. Star drift is too short. Check for mount, cable, or backlash problems.")); - emit newStatus(Ekos::GUIDE_CALIBRATION_ERROR); + emit newStatus(Ekos::GuideState::GUIDE_CALIBRATION_ERROR); //ui.startCalibrationLED->setColor(alertColor); calibrationStage = CAL_ERROR; @@ -835,7 +836,7 @@ // unnecessary guiding pulses. if (isFirstFrame) { - if (state == GUIDE_GUIDING) + if (state == Ekos::GuideState::GUIDE_GUIDING) { Vector star_pos = pmath->findLocalStarPosition(); pmath->setReticleParameters(star_pos.x, star_pos.y, -1); @@ -871,7 +872,7 @@ emit newLog(i18n("Lost track of the guide star. Searching for guide stars...")); reacquireTimer.start(); - state = GUIDE_REACQUIRE; + state = Ekos::GuideState::GUIDE_REACQUIRE; emit newStatus(state); return true; } @@ -882,7 +883,7 @@ emit frameCaptureRequested(); - if (state == GUIDE_DITHERING) + if (state == Ekos::GuideState::GUIDE_DITHERING) return true; tick = pmath->getTicks(); @@ -960,7 +961,7 @@ emit frameCaptureRequested(); - if (state == GUIDE_DITHERING) + if (state == Ekos::GuideState::GUIDE_DITHERING) return true; tick = pmath->getTicks(); @@ -1134,7 +1135,7 @@ { m_highPulseCounter=m_starLostCounter=0; isFirstFrame = true; - state = GUIDE_GUIDING; + state = Ekos::GuideState::GUIDE_GUIDING; emit newStatus(state); } else if (reacquireTimer.elapsed() > static_cast(Options::guideLostStarTimeout()*1000)) Index: kstars/ekos/scheduler/scheduler.cpp =================================================================== --- kstars/ekos/scheduler/scheduler.cpp +++ kstars/ekos/scheduler/scheduler.cpp @@ -26,6 +26,7 @@ #include "ekos/ekosmanager.h" #include "ekos/capture/sequencejob.h" #include "skyobjects/starobject.h" +#include "../ekos.h" #include @@ -2981,7 +2982,7 @@ Ekos::FocusState focusStatus = static_cast(focusReply.value()); // Is focus complete? - if (focusStatus == Ekos::FOCUS_COMPLETE) + if (focusStatus == Ekos::FocusState::FOCUS_COMPLETE) { appendLogText(i18n("Job '%1' focusing is complete.", currentJob->getName())); @@ -2991,7 +2992,7 @@ getNextAction(); } - else if (focusStatus == Ekos::FOCUS_FAILED || focusStatus == Ekos::FOCUS_ABORTED) + else if (focusStatus == Ekos::FocusState::FOCUS_FAILED || focusStatus == Ekos::FocusState::FOCUS_ABORTED) { appendLogText(i18n("Warning! Job '%1' focusing failed.", currentJob->getName())); @@ -3039,7 +3040,7 @@ Ekos::AlignState alignStatus = static_cast(alignReply.value()); // Is solver complete? - if (alignStatus == Ekos::ALIGN_COMPLETE) + if (alignStatus == Ekos::AlignState::ALIGN_COMPLETE) { appendLogText(i18n("Job '%1' alignment is complete.", currentJob->getName())); alignFailureCount = 0; @@ -3047,7 +3048,7 @@ currentJob->setStage(SchedulerJob::STAGE_ALIGN_COMPLETE); getNextAction(); } - else if (alignStatus == Ekos::ALIGN_FAILED || alignStatus == Ekos::ALIGN_ABORTED) + else if (alignStatus == Ekos::AlignState::ALIGN_FAILED || alignStatus == Ekos::AlignState::ALIGN_ABORTED) { appendLogText(i18n("Warning! Job '%1' alignment failed.", currentJob->getName())); @@ -3132,7 +3133,7 @@ Ekos::GuideState guideStatus = static_cast(guideReply.value()); // If calibration stage complete? - if (guideStatus == Ekos::GUIDE_GUIDING) + if (guideStatus == Ekos::GuideState::GUIDE_GUIDING) { appendLogText(i18n("Job '%1' guiding is in progress.", currentJob->getName())); guideFailureCount = 0; @@ -3140,9 +3141,10 @@ currentJob->setStage(SchedulerJob::STAGE_GUIDING_COMPLETE); getNextAction(); } - else if (guideStatus == Ekos::GUIDE_CALIBRATION_ERROR || guideStatus == Ekos::GUIDE_ABORTED) + else if (guideStatus == Ekos::GuideState::GUIDE_CALIBRATION_ERROR || + guideStatus == Ekos::GuideState::GUIDE_ABORTED) { - if (guideStatus == Ekos::GUIDE_ABORTED) + if (guideStatus == Ekos::GuideState::GUIDE_ABORTED) appendLogText(i18n("Warning! Job '%1' guiding failed.", currentJob->getName())); else appendLogText(i18n("Warning! Job '%1' calibration failed.", currentJob->getName())); @@ -3184,9 +3186,9 @@ { // Check if it is guiding related. QDBusReply guideReply = guideInterface->call(QDBus::AutoDetect, "getStatus"); - if (guideReply.value() == Ekos::GUIDE_ABORTED || - guideReply.value() == Ekos::GUIDE_CALIBRATION_ERROR || - guideReply.value() == GUIDE_DITHERING_ERROR) + if (guideReply.value() == KStarsEnum::toType(Ekos::GuideState::GUIDE_ABORTED) || + guideReply.value() == KStarsEnum::toType(Ekos::GuideState::GUIDE_CALIBRATION_ERROR) || + guideReply.value() == KStarsEnum::toType(Ekos::GuideState::GUIDE_DITHERING_ERROR)) // If guiding failed, let's restart it //if(guideReply.value() == false) { Index: kstars/fitsviewer/fitshistogram.cpp =================================================================== --- kstars/fitsviewer/fitshistogram.cpp +++ kstars/fitsviewer/fitshistogram.cpp @@ -316,6 +316,8 @@ if (image_data->getNumOfChannels() == 1) { +#pragma omp parallel +#pragma omp for for (uint32_t i = 0; i < samples; i += 4) { r_id = round((buffer[i] - fits_min) / binWidth); @@ -329,6 +331,8 @@ int g_offset = samples; int b_offset = samples * 2; +#pragma omp parallel +#pragma omp for for (uint32_t i = 0; i < samples; i += 4) { uint16_t g_id = 0, b_id = 0; Index: kstars/kstars.h =================================================================== --- kstars/kstars.h +++ kstars/kstars.h @@ -1,11 +1,11 @@ -/** ************************************************************************* +/*************************************************************************** kstars.h - K Desktop Planetarium ------------------- begin : Mon Feb 5 01:11:45 PST 2001 copyright : (C) 2001 by Jason Harris email : jharris@30doradus.org ***************************************************************************/ -/** ************************************************************************* +/*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -20,8 +20,8 @@ #include #include -#include +#include #include #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) #include Index: kstars/kstarsactions.cpp =================================================================== --- kstars/kstarsactions.cpp +++ kstars/kstarsactions.cpp @@ -21,6 +21,7 @@ #include "imageexporter.h" #include "kstarsdata.h" +#include "kstarsenum.h" #include "kstars_debug.h" #include "kswizard.h" #include "Options.h" @@ -1574,17 +1575,17 @@ void KStars::slotMapProjection() { if (sender() == actionCollection()->action("project_lambert")) - Options::setProjection(Projector::Lambert); + Options::setProjection(KStarsEnum::toType(Projector::Projection::Lambert)); if (sender() == actionCollection()->action("project_azequidistant")) - Options::setProjection(Projector::AzimuthalEquidistant); + Options::setProjection(KStarsEnum::toType(Projector::Projection::AzimuthalEquidistant)); if (sender() == actionCollection()->action("project_orthographic")) - Options::setProjection(Projector::Orthographic); + Options::setProjection(KStarsEnum::toType(Projector::Projection::Orthographic)); if (sender() == actionCollection()->action("project_equirectangular")) - Options::setProjection(Projector::Equirectangular); + Options::setProjection(KStarsEnum::toType(Projector::Projection::Equirectangular)); if (sender() == actionCollection()->action("project_stereographic")) - Options::setProjection(Projector::Stereographic); + Options::setProjection(KStarsEnum::toType(Projector::Projection::Stereographic)); if (sender() == actionCollection()->action("project_gnomonic")) - Options::setProjection(Projector::Gnomonic); + Options::setProjection(KStarsEnum::toType(Projector::Projection::Gnomonic)); //DEBUG qCDebug(KSTARS) << "Projection system: " << Options::projection(); Index: kstars/kstarsenum.h =================================================================== --- /dev/null +++ kstars/kstarsenum.h @@ -0,0 +1,28 @@ +/*************************************************************************** + kstarsenum.h - K Desktop Planetarium + ------------------- + begin : Tue Jun 12 19:26:33 GMT+3 + copyright : (C) 2018 by Csaba Kertesz + email : csaba.kertesz@gmail.com + ***************************************************************************/ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#pragma once + +#include + +namespace KStarsEnum +{ +template +constexpr auto toType(E e) -> typename std::underlying_type::type +{ + return static_cast::type>(e); +} +} \ No newline at end of file Index: kstars/kstarsinit.cpp =================================================================== --- kstars/kstarsinit.cpp +++ kstars/kstarsinit.cpp @@ -20,6 +20,7 @@ #include "fov.h" #include "kspaths.h" #include "kstarsdata.h" +#include "kstarsenum.h" #include "kstars_debug.h" #include "Options.h" #include "skymap.h" @@ -255,22 +256,22 @@ actionCollection()->addAction("project_lambert", this, SLOT(slotMapProjection())) << i18n("&Lambert Azimuthal Equal-area") << QKeySequence("F5") << AddToGroup(projectionGroup) - << Checked(Options::projection() == Projector::Lambert); + << Checked(Options::projection() == KStarsEnum::toType(Projector::Projection::Lambert)); actionCollection()->addAction("project_azequidistant", this, SLOT(slotMapProjection())) << i18n("&Azimuthal Equidistant") << QKeySequence("F6") << AddToGroup(projectionGroup) - << Checked(Options::projection() == Projector::AzimuthalEquidistant); + << Checked(Options::projection() == KStarsEnum::toType(Projector::Projection::AzimuthalEquidistant)); actionCollection()->addAction("project_orthographic", this, SLOT(slotMapProjection())) << i18n("&Orthographic") << QKeySequence("F7") << AddToGroup(projectionGroup) - << Checked(Options::projection() == Projector::Orthographic); + << Checked(Options::projection() == KStarsEnum::toType(Projector::Projection::Orthographic)); actionCollection()->addAction("project_equirectangular", this, SLOT(slotMapProjection())) << i18n("&Equirectangular") << QKeySequence("F8") << AddToGroup(projectionGroup) - << Checked(Options::projection() == Projector::Equirectangular); + << Checked(Options::projection() == KStarsEnum::toType(Projector::Projection::Equirectangular)); actionCollection()->addAction("project_stereographic", this, SLOT(slotMapProjection())) << i18n("&Stereographic") << QKeySequence("F9") << AddToGroup(projectionGroup) - << Checked(Options::projection() == Projector::Stereographic); + << Checked(Options::projection() == KStarsEnum::toType(Projector::Projection::Stereographic)); actionCollection()->addAction("project_gnomonic", this, SLOT(slotMapProjection())) << i18n("&Gnomonic") << QKeySequence("F10") << AddToGroup(projectionGroup) - << Checked(Options::projection() == Projector::Gnomonic); + << Checked(Options::projection() == KStarsEnum::toType(Projector::Projection::Gnomonic)); //Settings Menu: //Info Boxes option actions Index: kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp =================================================================== --- kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp +++ kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp @@ -109,7 +109,7 @@ bool pointsVisible = false; //Temporary solution to avoid random lines in Gnomonic projection and draw lines up to horizon - if (SkyMapLite::Instance()->projector()->type() == Projector::Gnomonic) + if (SkyMapLite::Instance()->projector()->type() == Projector::Projection::Gnomonic) { if (isVisible && isVisibleLast) pointsVisible = true; Index: kstars/projections/azimuthalequidistantprojector.h =================================================================== --- kstars/projections/azimuthalequidistantprojector.h +++ kstars/projections/azimuthalequidistantprojector.h @@ -17,25 +17,24 @@ */ -#ifndef AZIMUTHALEQUIDISTANTPROJECTOR_H -#define AZIMUTHALEQUIDISTANTPROJECTOR_H +#pragma once #include "projector.h" /** * @class AzimuthalEquidistantProjector * - * Implememntation of Azimuthal equidistant projection + * Implementation of + * Azimuthal equidistant projection * */ class AzimuthalEquidistantProjector : public Projector { public: explicit AzimuthalEquidistantProjector(const ViewParams &p); + Projection type() const override; double radius() const override; double projectionK(double x) const override; double projectionL(double x) const override; }; - -#endif // AZIMUTHALEQUIDISTANTPROJECTOR_H Index: kstars/projections/azimuthalequidistantprojector.cpp =================================================================== --- kstars/projections/azimuthalequidistantprojector.cpp +++ kstars/projections/azimuthalequidistantprojector.cpp @@ -30,7 +30,7 @@ Projector::Projection AzimuthalEquidistantProjector::type() const { - return AzimuthalEquidistant; + return Projection::AzimuthalEquidistant; } double AzimuthalEquidistantProjector::radius() const @@ -41,6 +41,7 @@ double AzimuthalEquidistantProjector::projectionK(double x) const { double crad = acos(x); + return ((crad != 0) ? crad / sin(crad) : 1); // This handles the 0/0 case. The limit of x / sin(x) is 1 as x -> 0. } Index: kstars/projections/equirectangularprojector.h =================================================================== --- kstars/projections/equirectangularprojector.h +++ kstars/projections/equirectangularprojector.h @@ -17,8 +17,7 @@ */ -#ifndef EQUIRECTANGULARPROJECTOR_H -#define EQUIRECTANGULARPROJECTOR_H +#pragma once #include "projector.h" @@ -32,6 +31,7 @@ { public: explicit EquirectangularProjector(const ViewParams &p); + Projection type() const override; double radius() const override; bool unusablePoint(const QPointF &p) const override; @@ -40,5 +40,3 @@ QVector groundPoly(SkyPoint *labelpoint = nullptr, bool *drawLabel = nullptr) const override; void updateClipPoly() override; }; - -#endif // EQUIRECTANGULARPROJECTOR_H Index: kstars/projections/equirectangularprojector.cpp =================================================================== --- kstars/projections/equirectangularprojector.cpp +++ kstars/projections/equirectangularprojector.cpp @@ -30,7 +30,7 @@ Projector::Projection EquirectangularProjector::type() const { - return Equirectangular; + return Projection::Equirectangular; } double EquirectangularProjector::radius() const Index: kstars/projections/gnomonicprojector.h =================================================================== --- kstars/projections/gnomonicprojector.h +++ kstars/projections/gnomonicprojector.h @@ -17,26 +17,24 @@ */ -#ifndef GNOMONICPROJECTOR_H -#define GNOMONICPROJECTOR_H +#pragma once #include "projector.h" /** * @class GnomonicProjector * - * Implememntation of Gnomonic projection + * Implementation of Gnomonic projection * */ class GnomonicProjector : public Projector { public: explicit GnomonicProjector(const ViewParams &p); + Projection type() const override; double radius() const override; double projectionK(double x) const override; double projectionL(double x) const override; double cosMaxFieldAngle() const override; }; - -#endif // GNOMONICPROJECTOR_H Index: kstars/projections/gnomonicprojector.cpp =================================================================== --- kstars/projections/gnomonicprojector.cpp +++ kstars/projections/gnomonicprojector.cpp @@ -26,7 +26,7 @@ Projector::Projection GnomonicProjector::type() const { - return Gnomonic; + return Projection::Gnomonic; } double GnomonicProjector::radius() const Index: kstars/projections/lambertprojector.h =================================================================== --- kstars/projections/lambertprojector.h +++ kstars/projections/lambertprojector.h @@ -17,15 +17,15 @@ */ -#ifndef LAMBERTPROJECTOR_H -#define LAMBERTPROJECTOR_H +#pragma once #include "projector.h" /** * @class LambertProjector * - * Implememntation of Lambert azimuthal equal-area projection + * Implementation of + * Lambert azimuthal equal-area projection * */ class LambertProjector : public Projector @@ -33,10 +33,9 @@ public: explicit LambertProjector(const ViewParams &p); ~LambertProjector() override = default; + Projection type() const override; double radius() const override; double projectionK(double x) const override; double projectionL(double x) const override; }; - -#endif // LAMBERTPROJECTOR_H Index: kstars/projections/lambertprojector.cpp =================================================================== --- kstars/projections/lambertprojector.cpp +++ kstars/projections/lambertprojector.cpp @@ -26,7 +26,7 @@ Projector::Projection LambertProjector::type() const { - return Lambert; + return Projection::Lambert; } double LambertProjector::radius() const Index: kstars/projections/orthographicprojector.h =================================================================== --- kstars/projections/orthographicprojector.h +++ kstars/projections/orthographicprojector.h @@ -17,25 +17,23 @@ */ -#ifndef ORTHOGRAPHICPROJECTOR_H -#define ORTHOGRAPHICPROJECTOR_H +#pragma once #include "projector.h" /** * @class OrthographicProjector * - * Implememntation of Orthographic projection + * Implementation of Orthographic projection * */ class OrthographicProjector : public Projector { public: explicit OrthographicProjector(const ViewParams &p); + Projection type() const override; double radius() const override; double projectionK(double x) const override; double projectionL(double x) const override; }; - -#endif // ORTHOGRAPHICPROJECTOR_H Index: kstars/projections/orthographicprojector.cpp =================================================================== --- kstars/projections/orthographicprojector.cpp +++ kstars/projections/orthographicprojector.cpp @@ -26,7 +26,7 @@ Projector::Projection OrthographicProjector::type() const { - return Orthographic; + return Projection::Orthographic; } double OrthographicProjector::radius() const Index: kstars/projections/projector.h =================================================================== --- kstars/projections/projector.h +++ kstars/projections/projector.h @@ -80,9 +80,9 @@ /** Update cached values for projector */ void setViewParams(const ViewParams &p); - enum Projection + enum class Projection : int { - Lambert, + Lambert = 0, AzimuthalEquidistant, Orthographic, Equirectangular, Index: kstars/projections/projector.cpp =================================================================== --- kstars/projections/projector.cpp +++ kstars/projections/projector.cpp @@ -290,7 +290,7 @@ if (m_vp.useAltAz) { daz = 0.5 * m_vp.width * 57.3 / m_vp.zoomFactor; //center to edge, in degrees - if (type() == Projector::Orthographic) + if (type() == Projector::Projection::Orthographic) { daz = daz * 1.4; } @@ -347,7 +347,7 @@ //In Gnomonic projection, or if sufficiently zoomed in, we can complete //the ground polygon by simply adding offscreen points //FIXME: not just gnomonic - if (daz < 25.0 || type() == Projector::Gnomonic) + if (daz < 25.0 || type() == Projector::Projection::Gnomonic) { ground.append(Vector2f(m_vp.width + 10.f, ground.last().y())); ground.append(Vector2f(m_vp.width + 10.f, m_vp.height + 10.f)); Index: kstars/projections/stereographicprojector.h =================================================================== --- kstars/projections/stereographicprojector.h +++ kstars/projections/stereographicprojector.h @@ -17,25 +17,23 @@ */ -#ifndef STEREOGRAPHICPROJECTOR_H -#define STEREOGRAPHICPROJECTOR_H +#pragma once #include "projector.h" /** * @class StereographicProjector * - * Implememntation of Stereographic projection + * Implementation of Stereographic projection * */ class StereographicProjector : public Projector { public: explicit StereographicProjector(const ViewParams &p); + Projection type() const override; double radius() const override; double projectionK(double x) const override; double projectionL(double x) const override; }; - -#endif // STEREOGRAPHICPROJECTOR_H Index: kstars/projections/stereographicprojector.cpp =================================================================== --- kstars/projections/stereographicprojector.cpp +++ kstars/projections/stereographicprojector.cpp @@ -26,7 +26,7 @@ Projector::Projection StereographicProjector::type() const { - return Stereographic; + return Projection::Stereographic; } double StereographicProjector::radius() const Index: kstars/skymap.h =================================================================== --- kstars/skymap.h +++ kstars/skymap.h @@ -68,9 +68,9 @@ protected: /** - *Constructor. Read stored settings from KConfig object (focus position, - *zoom factor, sky color, etc.). Run initPopupMenus(). - */ + * Constructor. Read stored settings from KConfig object (focus position, + * zoom factor, sky color, etc.). Run initPopupMenus(). + */ SkyMap(); public: @@ -80,12 +80,11 @@ static bool IsSlewing() { return pinstance->isSlewing(); } - /** Destructor (empty) */ - ~SkyMap() override; + virtual ~SkyMap() override; - enum Projection + enum class Projection : int { - Lambert, + Lambert = 0, AzimuthalEquidistant, Orthographic, Equirectangular, @@ -94,10 +93,11 @@ UnknownProjection }; - /** @return the angular field of view of the sky map, in degrees. - *@note it must use either the height or the width of the window to calculate the - *FOV angle. It chooses whichever is larger. - */ + /** + * @return the angular field of view of the sky map, in degrees. + * @note it must use either the height or the width of the window to calculate the + * FOV angle. It chooses whichever is larger. + */ float fov(); /** @short Update object name and coordinates in the Focus InfoBox */ @@ -106,94 +106,105 @@ /** @short Update the focus position according to current options. */ void updateFocus(); - /** @short Retrieve the Focus point; the position on the sky at the - *center of the skymap. - *@return a pointer to the central focus point of the sky map - */ + /** + * @short Retrieve the Focus point; the position on the sky at the center of the skymap. + * @return a pointer to the central focus point of the sky map + */ SkyPoint *focus() { return &Focus; } - /** @short retrieve the Destination position. - * - *The Destination is the point on the sky to which the focus will - *be moved. - * - *@return a pointer to the destination point of the sky map - */ + /** + * @short retrieve the Destination position. + * + * The Destination is the point on the sky to which the focus will be moved. + * + * @return a pointer to the destination point of the sky map + */ SkyPoint *destination() { return &Destination; } - /** @short retrieve the FocusPoint position. - * - *The FocusPoint stores the position on the sky that is to be - *focused next. This is not exactly the same as the Destination - *point, because when the Destination is set, it will begin slewing - *immediately. - * - *@return a pointer to the sky point which is to be focused next. - */ + /** + * @short retrieve the FocusPoint position. + * + * The FocusPoint stores the position on the sky that is to be focused next. + * This is not exactly the same as the Destination point, because when the + * Destination is set, it will begin slewing immediately. + * + * @return a pointer to the sky point which is to be focused next. + */ SkyPoint *focusPoint() { return &FocusPoint; } - /** @short sets the central focus point of the sky map. - *@param f a pointer to the SkyPoint the map should be centered on - */ + /** + * @short sets the central focus point of the sky map. + * @param f a pointer to the SkyPoint the map should be centered on + */ void setFocus(SkyPoint *f); - /** @short sets the focus point of the skymap, using ra/dec coordinates - * - *@note This function behaves essentially like the above function. - *It differs only in the data types of its arguments. - * - *@param ra the new right ascension - *@param dec the new declination - */ + /** + * @short sets the focus point of the skymap, using ra/dec coordinates + * + * @note This function behaves essentially like the above function. + * It differs only in the data types of its arguments. + * + * @param ra the new right ascension + * @param dec the new declination + */ void setFocus(const dms &ra, const dms &dec); - /** @short sets the focus point of the sky map, using its alt/az coordinates - *@param alt the new altitude - *@param az the new azimuth - */ + /** + * @short sets the focus point of the sky map, using its alt/az coordinates + * + * @param alt the new altitude + * @param az the new azimuth + */ void setFocusAltAz(const dms &alt, const dms &az); - /** @short sets the destination point of the sky map. - *@note setDestination() emits the destinationChanged() SIGNAL, - *which triggers the SLOT function SkyMap::slewFocus(). This - *function iteratively steps the Focus point toward Destination, - *repainting the sky at each step (if Options::useAnimatedSlewing()==true). - *@param f a pointer to the SkyPoint the map should slew to - */ + /** + * @short sets the destination point of the sky map. + * + * @note setDestination() emits the destinationChanged() SIGNAL, + * which triggers the SLOT function SkyMap::slewFocus(). This + * function iteratively steps the Focus point toward Destination, + * repainting the sky at each step (if Options::useAnimatedSlewing()==true). + * @param f a pointer to the SkyPoint the map should slew to + */ void setDestination(const SkyPoint &f); - /** @short sets the destination point of the skymap, using ra/dec coordinates. - * - *@note This function behaves essentially like the above function. - *It differs only in the data types of its arguments. - * - *@param ra the new right ascension - *@param dec the new declination - */ + /** + * @short sets the destination point of the skymap, using ra/dec coordinates. + * + * @note This function behaves essentially like the above function. + * It differs only in the data types of its arguments. + * + * @param ra the new right ascension + * @param dec the new declination + */ void setDestination(const dms &ra, const dms &dec); - /** @short sets the destination point of the sky map, using its alt/az coordinates. - *@param alt the new altitude - *@param az the new azimuth - */ + /** + * @short sets the destination point of the sky map, using its alt/az coordinates. + * + * @param alt the new altitude + * @param az the new azimuth + */ void setDestinationAltAz(const dms &alt, const dms &az); - /** @short set the FocusPoint; the position that is to be the next Destination. - *@param f a pointer to the FocusPoint SkyPoint. - */ + /** + * @short set the FocusPoint; the position that is to be the next Destination. + * @param f a pointer to the FocusPoint SkyPoint. + */ void setFocusPoint(SkyPoint *f) { if (f) FocusPoint = *f; } - /** @short Retrieve the ClickedPoint position. - * - *When the user clicks on a point in the sky map, the sky coordinates of the mouse - *cursor are stored in the private member ClickedPoint. This function retrieves - *a pointer to ClickedPoint. - *@return a pointer to ClickedPoint, the sky coordinates where the user clicked. - */ + /** + * @short Retrieve the ClickedPoint position. + * + * When the user clicks on a point in the sky map, the sky coordinates of the mouse + * cursor are stored in the private member ClickedPoint. This function retrieves + * a pointer to ClickedPoint. + * @return a pointer to ClickedPoint, the sky coordinates where the user clicked. + */ SkyPoint *clickedPoint() { return &ClickedPoint; } /** @@ -203,46 +214,52 @@ */ SkyPoint *mousePoint() { return &m_MousePoint; } - /** @short Set the ClickedPoint to the skypoint given as an argument. - *@param f pointer to the new ClickedPoint. - */ + /** + * @short Set the ClickedPoint to the skypoint given as an argument. + * @param f pointer to the new ClickedPoint. + */ void setClickedPoint(SkyPoint *f); - /** @short Retrieve the object nearest to a mouse click event. - * - *If the user clicks on the sky map, a pointer to the nearest SkyObject is stored in - *the private member ClickedObject. This function returns the ClickedObject pointer, - *or nullptr if there is no CLickedObject. - *@return a pointer to the object nearest to a user mouse click. - */ + /** + * @short Retrieve the object nearest to a mouse click event. + * + * If the user clicks on the sky map, a pointer to the nearest SkyObject is stored in + * the private member ClickedObject. This function returns the ClickedObject pointer, + * or nullptr if there is no CLickedObject. + * @return a pointer to the object nearest to a user mouse click. + */ SkyObject *clickedObject() const { return ClickedObject; } - /** @short Set the ClickedObject pointer to the argument. - *@param o pointer to the SkyObject to be assigned as the ClickedObject - */ + /** + * @short Set the ClickedObject pointer to the argument. + * @param o pointer to the SkyObject to be assigned as the ClickedObject + */ void setClickedObject(SkyObject *o); - /** @short Retrieve the object which is centered in the sky map. - * - *If the user centers the sky map on an object (by double-clicking or using the - *Find Object dialog), a pointer to the "focused" object is stored in - *the private member FocusObject. This function returns a pointer to the - *FocusObject, or nullptr if there is not FocusObject. - *@return a pointer to the object at the center of the sky map. - */ + /** + * @short Retrieve the object which is centered in the sky map. + * + * If the user centers the sky map on an object (by double-clicking or using the + * Find Object dialog), a pointer to the "focused" object is stored in + * the private member FocusObject. This function returns a pointer to the + * FocusObject, or nullptr if there is not FocusObject. + * @return a pointer to the object at the center of the sky map. + */ SkyObject *focusObject() const { return FocusObject; } - /** @short Set the FocusObject pointer to the argument. - *@param o pointer to the SkyObject to be assigned as the FocusObject - */ + /** + * @short Set the FocusObject pointer to the argument. + * @param o pointer to the SkyObject to be assigned as the FocusObject + */ void setFocusObject(SkyObject *o); /** @short Call to set up the projector before a draw cycle. */ void setupProjector(); - /** @ Set zoom factor. - *@param factor zoom factor - */ + /** + * Set zoom factor. + * @param factor zoom factor + */ void setZoomFactor(double factor); bool isSlewing() const; @@ -251,26 +268,30 @@ /** @short update the geometry of the angle ruler. */ void updateAngleRuler(); - /** @return true if the object currently has a user label attached. - *@note this function only checks for a label explicitly added to the object - *with the right-click popup menu; other kinds of labels are not detected by - *this function. - *@param o pointer to the sky object to be tested for a User label. - */ + /** + * @return true if the object currently has a user label attached. + * @note this function only checks for a label explicitly added to the object + * with the right-click popup menu; other kinds of labels are not detected by this function. + * @param o pointer to the sky object to be tested for a User label. + */ bool isObjectLabeled(SkyObject *o); - /*@*@short Convenience function for shutting off tracking mode. Just calls KStars::slotTrack(). - */ + /** + * @short Convenience function for shutting off tracking mode. + * + * Just calls KStars::slotTrack(). + */ void stopTracking(); - /** Get the current projector. - @return a pointer to the current projector. */ + /** + * Get the current projector. + * + * @return a pointer to the current projector. + */ inline const Projector *projector() const { return m_proj; } // NOTE: These dynamic casts must not segfault. If they do, it's good because we know that there is a problem. - /** - *@short Proxy method for SkyMapDrawAbstract::exportSkyImage() - */ + /** @short Proxy method for SkyMapDrawAbstract::exportSkyImage() */ inline void exportSkyImage(QPaintDevice *pd, bool scale = false) { dynamic_cast(m_SkyMapDraw)->exportSkyImage(pd, scale); @@ -283,9 +304,7 @@ SkyMapDrawAbstract *getSkyMapDrawAbstract() { return dynamic_cast(m_SkyMapDraw); } - /** - *@short Proxy method for SkyMapDrawAbstract::drawObjectLabels() - */ + /** @short Proxy method for SkyMapDrawAbstract::drawObjectLabels() */ inline void drawObjectLabels(QList &labelObjects) { dynamic_cast(m_SkyMapDraw)->drawObjectLabels(labelObjects); @@ -306,22 +325,24 @@ SkyPoint getCenterPoint(); public slots: - /** Recalculates the positions of objects in the sky, and then repaints the sky map. - * If the positions don't need to be recalculated, use update() instead of forceUpdate(). - * This saves a lot of CPU time. - * @param now if true, paintEvent() is run immediately. Otherwise, it is added to the event queue - */ + /** + * Recalculates the positions of objects in the sky, and then repaints the sky map. + * If the positions don't need to be recalculated, use update() instead of forceUpdate(). + * This saves a lot of CPU time. + * @param now if true, paintEvent() is run immediately. Otherwise, it is added to the event queue + */ void forceUpdate(bool now = false); - /** @short Convenience function; simply calls forceUpdate(true). - * @see forceUpdate() - */ + /** + * @short Convenience function; simply calls forceUpdate(true). + * @see forceUpdate() + */ void forceUpdateNow() { forceUpdate(true); } /** - * @short Update the focus point and call forceUpdate() - * @param now is passed on to forceUpdate() - */ + * @short Update the focus point and call forceUpdate() + * @param now is passed on to forceUpdate() + */ void slotUpdateSky(bool now); /** Toggle visibility of geo infobox */ @@ -336,112 +357,128 @@ /** Toggle visibility of all infoboxes */ void slotToggleInfoboxes(bool); - /** Step the Focus point toward the Destination point. Do this iteratively, redrawing the Sky - * Map after each step, until the Focus point is within 1 step of the Destination point. - * For the final step, snap directly to Destination, and redraw the map. - */ + /** + * Step the Focus point toward the Destination point. Do this iteratively, redrawing the Sky + * Map after each step, until the Focus point is within 1 step of the Destination point. + * For the final step, snap directly to Destination, and redraw the map. + */ void slewFocus(); - /** @short Center the display at the point ClickedPoint. - * - * The essential part of the function is to simply set the Destination point, which will emit - * the destinationChanged() SIGNAL, which triggers the slewFocus() SLOT. Additionally, this - * function performs some bookkeeping tasks, such updating whether we are tracking the new - * object/position, adding a Planet Trail if required, etc. - * - * @see destinationChanged() - * @see slewFocus() - */ + /** + * @short Center the display at the point ClickedPoint. + * + * The essential part of the function is to simply set the Destination point, which will emit + * the destinationChanged() SIGNAL, which triggers the slewFocus() SLOT. Additionally, this + * function performs some bookkeeping tasks, such updating whether we are tracking the new + * object/position, adding a Planet Trail if required, etc. + * + * @see destinationChanged() + * @see slewFocus() + */ void slotCenter(); - /** @short Popup menu function: Display 1st-Generation DSS image with the Image Viewer. - * @note the URL is generated using the coordinates of ClickedPoint. - */ + /** + * @short Popup menu function: Display 1st-Generation DSS image with the Image Viewer. + * @note the URL is generated using the coordinates of ClickedPoint. + */ void slotDSS(); - /** @short Popup menu function: Display Sloan Digital Sky Survey image with the Image Viewer. - * @note the URL is generated using the coordinates of ClickedPoint. - */ + /** + * @short Popup menu function: Display Sloan Digital Sky Survey image with the Image Viewer. + * @note the URL is generated using the coordinates of ClickedPoint. + */ void slotSDSS(); - /** @short Popup menu function: Show webpage about ClickedObject - * (only available for some objects). - */ + /** + * @short Popup menu function: Show webpage about ClickedObject + * (only available for some objects). + */ void slotInfo(); - /** @short Popup menu function: Show image of ClickedObject - * (only available for some objects). - */ + /** + * @short Popup menu function: Show image of ClickedObject + * (only available for some objects). + */ void slotImage(); /** @short Popup menu function: Show the Detailed Information window for ClickedObject. */ void slotDetail(); - /** Add ClickedObject to KStarsData::ObjLabelList, which stores pointers to SkyObjects which - * have User Labels attached. - */ + /** + * Add ClickedObject to KStarsData::ObjLabelList, which stores pointers to SkyObjects which + * have User Labels attached. + */ void slotAddObjectLabel(); - /** Remove ClickedObject from KStarsData::ObjLabelList, which stores pointers to SkyObjects which - * have User Labels attached. - */ + /** + * Remove ClickedObject from KStarsData::ObjLabelList, which stores pointers to SkyObjects which + * have User Labels attached. + */ void slotRemoveObjectLabel(); - /** @short Add a Planet Trail to ClickedObject. - * @note Trails are added simply by calling KSPlanetBase::addToTrail() to add the first point. - * as long as the trail is not empty, new points will be automatically appended to it. - * @note if ClickedObject is not a Solar System body, this function does nothing. - * @see KSPlanetBase::addToTrail() - */ + /** + * @short Add a Planet Trail to ClickedObject. + * @note Trails are added simply by calling KSPlanetBase::addToTrail() to add the first point. + * as long as the trail is not empty, new points will be automatically appended to it. + * @note if ClickedObject is not a Solar System body, this function does nothing. + * @see KSPlanetBase::addToTrail() + */ void slotAddPlanetTrail(); - /** @short Remove the PlanetTrail from ClickedObject. - * @note The Trail is removed by simply calling KSPlanetBase::clearTrail(). As long as - * the trail is empty, no new points will be automatically appended. - * @see KSPlanetBase::clearTrail() - */ + /** + * @short Remove the PlanetTrail from ClickedObject. + * @note The Trail is removed by simply calling KSPlanetBase::clearTrail(). As long as + * the trail is empty, no new points will be automatically appended. + * @see KSPlanetBase::clearTrail() + */ void slotRemovePlanetTrail(); - /** Checks whether the timestep exceeds a threshold value. If so, sets - * ClockSlewing=true and sets the SimClock to ManualMode. - */ + /** + * Checks whether the timestep exceeds a threshold value. If so, sets + * ClockSlewing=true and sets the SimClock to ManualMode. + */ void slotClockSlewing(); - /** Enables the angular distance measuring mode. It saves the first - * position of the ruler in a SkyPoint. It makes difference between - * having clicked on the skymap and not having done so - * \note This method is draw-backend independent. - */ + /** + * Enables the angular distance measuring mode. It saves the first + * position of the ruler in a SkyPoint. It makes difference between + * having clicked on the skymap and not having done so + * \note This method is draw-backend independent. + */ void slotBeginAngularDistance(); void slotBeginStarHop(); // TODO: Add docs - /** Computes the angular distance, prints the result in the status - * bar and disables the angular distance measuring mode - * If the user has clicked on the map the status bar shows the - * name of the clicked object plus the angular distance. If - * the user did not clicked on the map, just pressed ], only - * the angular distance is printed - * \note This method is draw-backend independent. - */ + /** + * Computes the angular distance, prints the result in the status + * bar and disables the angular distance measuring mode + * If the user has clicked on the map the status bar shows the + * name of the clicked object plus the angular distance. If + * the user did not clicked on the map, just pressed ], only + * the angular distance is printed + * \note This method is draw-backend independent. + */ void slotEndRulerMode(); - /** Disables the angular distance measuring mode. Nothing is printed - * in the status bar */ + /** + * Disables the angular distance measuring mode. Nothing is printed + * in the status bar + */ void slotCancelRulerMode(); - /** @short Open Flag Manager window with clickedObject() RA and Dec entered. - */ + /** @short Open Flag Manager window with clickedObject() RA and Dec entered. */ void slotAddFlag(); - /** @short Open Flag Manager window with selected flag focused and ready to edit. - *@param flagIdx index of flag to be edited. - */ + /** + * @short Open Flag Manager window with selected flag focused and ready to edit. + * @param flagIdx index of flag to be edited. + */ void slotEditFlag(int flagIdx); - /** @short Delete selected flag. - *@param flagIdx index of flag to be deleted. - */ + /** + * @short Delete selected flag. + * @param flagIdx index of flag to be deleted. + */ void slotDeleteFlag(int flagIdx); #ifdef HAVE_OPENGL @@ -476,12 +513,13 @@ void slotCaptureFov(); signals: - /** Emitted by setDestination(), and connected to slewFocus(). Whenever the Destination - * point is changed, slewFocus() will iteratively step the Focus toward Destination - * until it is reached. - * @see SkyMap::setDestination() - * @see SkyMap::slewFocus() - */ + /** + * Emitted by setDestination(), and connected to slewFocus(). Whenever the Destination + * point is changed, slewFocus() will iteratively step the Focus toward Destination + * until it is reached. + * @see SkyMap::setDestination() + * @see SkyMap::slewFocus() + */ void destinationChanged(); /** Emitted when zoom level is changed. */ @@ -503,61 +541,68 @@ void objectClicked(SkyObject *); protected: - /** Process keystrokes: - * @li arrow keys Slew the map - * @li +/- keys Zoom in and out - * @li Space Toggle between Horizontal and Equatorial coordinate systems - * @li 0-9 Go to a major Solar System body (0=Sun; 1-9 are the major planets, except 3=Moon) - * @li [ Place starting point for measuring an angular distance - * @li ] End point for Angular Distance; display measurement. - * @li Escape Cancel Angular measurement - * @li ,/< Step backward one time step - * @li ./> Step forward one time step - */ + /** + * Process keystrokes: + * @li arrow keys Slew the map + * @li +/- keys Zoom in and out + * @li Space Toggle between Horizontal and Equatorial coordinate systems + * @li 0-9 Go to a major Solar System body (0=Sun; 1-9 are the major planets, except 3=Moon) + * @li [ Place starting point for measuring an angular distance + * @li ] End point for Angular Distance; display measurement. + * @li Escape Cancel Angular measurement + * @li ,/< Step backward one time step + * @li ./> Step forward one time step + */ void keyPressEvent(QKeyEvent *e) override; - /** When keyRelease is triggered, just set the "slewing" flag to false, - * and update the display (to draw objects that are hidden when slewing==true). */ + /** + * When keyRelease is triggered, just set the "slewing" flag to false, + * and update the display (to draw objects that are hidden when slewing==true). + */ void keyReleaseEvent(QKeyEvent *e) override; - /** Determine RA, Dec coordinates of clicked location. Find the SkyObject - * which is nearest to the clicked location. - * - * If left-clicked: Set set mouseButtonDown==true, slewing==true; display - * nearest object name in status bar. - * If right-clicked: display popup menu appropriate for nearest object. - */ + /** + * Determine RA, Dec coordinates of clicked location. Find the SkyObject + * which is nearest to the clicked location. + * + * If left-clicked: Set set mouseButtonDown==true, slewing==true; display + * nearest object name in status bar. + * If right-clicked: display popup menu appropriate for nearest object. + */ void mousePressEvent(QMouseEvent *e) override; - /** set mouseButtonDown==false, slewing==false */ + /** Set mouseButtonDown==false, slewing==false */ void mouseReleaseEvent(QMouseEvent *e) override; /** Center SkyMap at double-clicked location */ void mouseDoubleClickEvent(QMouseEvent *e) override; - /** This function does several different things depending on the state of the program: - * @li If Angle-measurement mode is active, update the end-ruler point to the mouse cursor, - * and continue this function. - * @li If we are defining a ZoomBox, update the ZoomBox rectangle, redraw the screen, - * and return. - * @li If dragging the mouse in the map, update focus such that RA, Dec under the mouse - * cursor remains constant. - * @li If just moving the mouse, simply update the curso coordinates in the status bar. - */ + /** + * This function does several different things depending on the state of the program: + * @li If Angle-measurement mode is active, update the end-ruler point to the mouse cursor, + * and continue this function. + * @li If we are defining a ZoomBox, update the ZoomBox rectangle, redraw the screen, + * and return. + * @li If dragging the mouse in the map, update focus such that RA, Dec under the mouse + * cursor remains constant. + * @li If just moving the mouse, simply update the curso coordinates in the status bar. + */ void mouseMoveEvent(QMouseEvent *e) override; /** Zoom in and out with the mouse wheel. */ void wheelEvent(QWheelEvent *e) override; - /** If the skymap will be resized, the sky must be new computed. So this - * function calls explicitly new computing of the skymap. - */ + /** + * If the skymap will be resized, the sky must be new computed. So this + * function calls explicitly new computing of the skymap. + */ void resizeEvent(QResizeEvent *) override; private slots: - /** @short display tooltip for object under cursor. It's called by m_HoverTimer. - * if mouse didn't moved for last HOVER_INTERVAL milliseconds. - */ + /** + * @short display tooltip for object under cursor. It's called by m_HoverTimer. + * if mouse didn't moved for last HOVER_INTERVAL milliseconds. + */ void slotTransientLabel(); /** Set the shape of mouse cursor to a cross with 4 arrows. */ @@ -570,39 +615,42 @@ /** @short Sets the shape of the mouse cursor to a magnifying glass. */ void setZoomMouseCursor(); - /** Calculate the zoom factor for the given keyboard modifier - */ + /** Calculate the zoom factor for the given keyboard modifier */ double zoomFactor(const int modifier); - /** calculate the magnitude factor (1, .5, .2, or .1) for the given - * keyboard modifier. - */ + /** + * Calculate the magnitude factor (1, .5, .2, or .1) for the given keyboard modifier. + */ double magFactor(const int modifier); - /** Decrease the magnitude limit by a step size determined by the - * keyboard modifier. - * @param modifier - */ + /** + * Decrease the magnitude limit by a step size determined by the keyboard modifier. + * + * @param modifier + */ void decMagLimit(const int modifier); - /** Increase the magnitude limit by a step size determined by the - * keyboard modifier. - * @param modifier - */ + /** + * Increase the magnitude limit by a step size determined by the keyboard modifier. + * + * @param modifier + */ void incMagLimit(const int modifier); - /** Convenience routine to either zoom in or incraase mag limit - * depending on the Alt modifier. The Shift and Control modiifers - * will adjust the size of the zoom or the mag step. - * @param modifier - */ + /** + * Convenience routine to either zoom in or incraase mag limit + * depending on the Alt modifier. The Shift and Control modiifers + * will adjust the size of the zoom or the mag step. + * @param modifier + */ void zoomInOrMagStep(const int modifier); - /** Convenience routine to either zoom out or decraase mag limit - * depending on the Alt modifier. The Shift and Control modiifers - * will adjust the size of the zoom or the mag step. - * @param modifier - */ + /** + * Convenience routine to either zoom out or decraase mag limit + * depending on the Alt modifier. The Shift and Control modiifers + * will adjust the size of the zoom or the mag step. + * @param modifier + */ void zoomOutOrMagStep(const int modifier); void beginRulerMode(bool starHopRuler); // TODO: Add docs Index: kstars/skymap.cpp =================================================================== --- kstars/skymap.cpp +++ kstars/skymap.cpp @@ -20,9 +20,10 @@ #endif #include "skymap.h" -#include "ksasteroid.h" +#include "ksasteroid.h" #include "kstars_debug.h" +#include "kstarsenum.h" #include "fov.h" #include "imageviewer.h" #include "ksdssdownloader.h" @@ -61,7 +62,6 @@ #include #include #include - #include #include @@ -1148,29 +1148,29 @@ p.zoomFactor = Options::zoomFactor(); p.fillGround = Options::showGround(); //Check if we need a new projector - if (m_proj && Options::projection() == m_proj->type()) + if (m_proj && Options::projection() == (uint)KStarsEnum::toType(m_proj->type())) m_proj->setViewParams(p); else { delete m_proj; switch (Options::projection()) { - case Gnomonic: + case KStarsEnum::toType(Projection::Gnomonic): m_proj = new GnomonicProjector(p); break; - case Stereographic: + case KStarsEnum::toType(Projection::Stereographic): m_proj = new StereographicProjector(p); break; - case Orthographic: + case KStarsEnum::toType(Projection::Orthographic): m_proj = new OrthographicProjector(p); break; - case AzimuthalEquidistant: + case KStarsEnum::toType(Projection::AzimuthalEquidistant): m_proj = new AzimuthalEquidistantProjector(p); break; - case Equirectangular: + case KStarsEnum::toType(Projection::Equirectangular): m_proj = new EquirectangularProjector(p); break; - case Lambert: + case KStarsEnum::toType(Projection::Lambert): default: //TODO: implement other projection classes m_proj = new LambertProjector(p); Index: kstars/skymapdrawabstract.h =================================================================== --- kstars/skymapdrawabstract.h +++ kstars/skymapdrawabstract.h @@ -15,10 +15,10 @@ * * ***************************************************************************/ -#ifndef SKYMAPDRAWABSTRACT_H_ -#define SKYMAPDRAWABSTRACT_H_ +#pragma once #include "kstarsdata.h" + #include #include #include @@ -27,104 +27,101 @@ class SkyQPainter; /** - *@short This class defines the methods that both rendering engines + * @short This class defines the methods that both rendering engines * (GLPainter and QPainter) must implement. This also allows us to add * more rendering engines if required. - *@version 1.0 - *@author Akarsh Simha + * + * @version 1.0 + * @author Akarsh Simha */ - -// In summary, this is a class created by stealing all the -// drawing-related methods from the old SkyMap class - class SkyMapDrawAbstract { protected: - /** - *@short Virtual Destructor - */ virtual ~SkyMapDrawAbstract() = default; public: - /** - *@short Constructor that sets data and m_SkyMap, and initializes - * the FPS counters. - */ + /** @short Constructor that sets data and m_SkyMap, and initializes the FPS counters. */ explicit SkyMapDrawAbstract(SkyMap *sm); // *********************** "IMPURE" VIRTUAL METHODS ******************* // // NOTE: The following methods are implemented using native // QPainter in both cases. So it's virtual, but not pure virtual - /**Draw the overlays on top of the sky map. These include the infoboxes, - *field-of-view indicator, telescope symbols, zoom box and any other - *user-interaction graphics. - * - *The overlays can be updated rapidly, without having to recompute the entire SkyMap. - *The stored Sky image is simply blitted onto the SkyMap widget, and then we call - *drawOverlays() to refresh the overlays. - *@param pm pointer to the Sky pixmap - */ + /** + * Draw the overlays on top of the sky map. These include the infoboxes, + * field-of-view indicator, telescope symbols, zoom box and any other + * user-interaction graphics. + * + * The overlays can be updated rapidly, without having to recompute the entire SkyMap. + * The stored Sky image is simply blitted onto the SkyMap widget, and then we call + * drawOverlays() to refresh the overlays. + * @param pm pointer to the Sky pixmap + */ void drawOverlays(QPainter &p, bool drawFov = true); - /**Draw symbols at the position of each Telescope currently being controlled by KStars. - *@note The shape of the Telescope symbol is currently a hard-coded bullseye. - *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). - */ + /** + * Draw symbols at the position of each Telescope currently being controlled by KStars. + * + * @note The shape of the Telescope symbol is currently a hard-coded bullseye. + * @param psky reference to the QPainter on which to draw (this should be the Sky pixmap). + */ void drawTelescopeSymbols(QPainter &psky); - /**Draw FOV of solved image in Ekos Alignment Module - *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). - */ + /** + * Draw FOV of solved image in Ekos Alignment Module + * @param psky reference to the QPainter on which to draw (this should be the Sky pixmap). + */ void drawSolverFOV(QPainter &psky); /** - *@short Draw a dotted-line rectangle which traces the potential new field-of-view in ZoomBox mode. - *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). - */ + * @short Draw a dotted-line rectangle which traces the potential new field-of-view in ZoomBox mode. + * @param psky reference to the QPainter on which to draw (this should be the Sky pixmap). + */ void drawZoomBox(QPainter &psky); - /**Draw a dashed line from the Angular-Ruler start point to the current mouse cursor, - *when in Angular-Ruler mode. - *@param psky reference to the QPainter on which to draw (this should be the Sky pixmap). - */ + /** + * Draw a dashed line from the Angular-Ruler start point to the current mouse cursor, + * when in Angular-Ruler mode. + * @param psky reference to the QPainter on which to draw (this should be the Sky pixmap). + */ void drawAngleRuler(QPainter &psky); - /** @short Draw the current Sky map to a pixmap which is to be printed or exported to a file. - * - *@param pd pointer to the QPaintDevice on which to draw. - *@see KStars::slotExportImage() - *@see KStars::slotPrint() - */ + /** + * @short Draw the current Sky map to a pixmap which is to be printed or exported to a file. + * + * @param pd pointer to the QPaintDevice on which to draw. + * @see KStars::slotExportImage() + * @see KStars::slotPrint() + */ void exportSkyImage(QPaintDevice *pd, bool scale = false); - /** @short Draw the current Sky map using passed SkyQPainter instance. Required when - * used QPaintDevice doesn't support drawing using multiple painters (e.g. QSvgGenerator - * which generates broken SVG output when more than one QPainter subclass is used). - * Passed painter should already be initialized to draw on selected QPaintDevice subclass - * using begin() and it won't be ended [end()] by this method. - *@param painter pointer to the SkyQPainter already set up to paint on selected QPaintDevice subclass. - *@param scale should sky image be scaled to fit used QPaintDevice? - */ + /** + * @short Draw the current Sky map using passed SkyQPainter instance. Required when + * used QPaintDevice doesn't support drawing using multiple painters (e.g. QSvgGenerator + * which generates broken SVG output when more than one QPainter subclass is used). + * Passed painter should already be initialized to draw on selected QPaintDevice subclass + * using begin() and it won't be ended [end()] by this method. + * @param painter pointer to the SkyQPainter already set up to paint on selected QPaintDevice subclass. + * @param scale should sky image be scaled to fit used QPaintDevice? + */ void exportSkyImage(SkyQPainter *painter, bool scale = false); - /** @short Draw "user labels". User labels are name labels attached to objects manually with - * the right-click popup menu. Also adds a label to the FocusObject if the Option UseAutoLabel - * is true. - * @param labelObjects QList of pointers to the objects which need labels (excluding the centered object) - * @param psky painter for the sky - * @note the labelObjects list is managed by the SkyMapComponents class - */ + /** + * @short Draw "user labels". User labels are name labels attached to objects manually with + * the right-click popup menu. Also adds a label to the FocusObject if the Option UseAutoLabel + * is true. + * @param labelObjects QList of pointers to the objects which need labels (excluding the centered object) + * @param psky painter for the sky + * @note the labelObjects list is managed by the SkyMapComponents class + */ void drawObjectLabels(QList &labelObjects); /** - *@return true if a draw is in progress or is locked, false otherwise. This is just the value of m_DrawLock - */ + * @return true if a draw is in progress or is locked, false otherwise. This is just the value of m_DrawLock + */ static inline bool drawLock() { return m_DrawLock; } - /** - *@short Acquire / release a draw lock. This prevents other drawing from happening - */ + /** @short Acquire / release a draw lock. This prevents other drawing from happening */ static void setDrawLock(bool state); // *********************** PURE VIRTUAL METHODS ******************* // @@ -133,24 +130,23 @@ protected: /** - *@short Overridden paintEvent method. Must be implemented by - * subclasses to draw the SkyMap. (This method is pure - * virtual) - */ + * @short Overridden paintEvent method. Must be implemented by + * subclasses to draw the SkyMap. (This method is pure virtual) + */ virtual void paintEvent(QPaintEvent *e) = 0; /* - *NOTE: - * Depending on whether the implementation of this class is a - * GL-backend, it may need to implement these methods: - * virtual void resizeGL(int width, int height); - * virtual void initializeGL(); - * So we will not even bother defining them here. - * They must be taken care of in the subclasses - */ - - KStarsData *m_KStarsData; - SkyMap *m_SkyMap; + * NOTE: + * Depending on whether the implementation of this class is a + * GL-backend, it may need to implement these methods: + * virtual void resizeGL(int width, int height); + * virtual void initializeGL(); + * So we will not even bother defining them here. + * They must be taken care of in the subclasses + */ + + KStarsData *m_KStarsData { nullptr }; + SkyMap *m_SkyMap { nullptr }; static bool m_DrawLock; /** Calculate FPS and dump result to stderr using qDebug */ @@ -159,5 +155,3 @@ // int m_framecount; // To count FPS //QTime m_fpstime; }; - -#endif Index: kstars/skymapdrawabstract.cpp =================================================================== --- kstars/skymapdrawabstract.cpp +++ kstars/skymapdrawabstract.cpp @@ -15,34 +15,28 @@ * * ***************************************************************************/ -// This file implements the class SkyMapDrawAbstract, and is almost -// identical to the older skymapdraw.cpp file, written by Jason -// Harris. Essentially, skymapdraw.cpp was renamed and modified. -// -- asimha (2011) - -#include -#include - #include "skymapdrawabstract.h" -#include "skymap.h" -#include "Options.h" + #include "fov.h" #include "kstars.h" #include "kstarsdata.h" +#include "kstarsenum.h" #include "ksnumbers.h" #include "ksutils.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/deepskyobject.h" -#include "skyobjects/starobject.h" -#include "skyobjects/ksplanetbase.h" -#include "simclock.h" #include "observinglist.h" +#include "Options.h" +#include "simclock.h" +#include "skymap.h" +#include "skyqpainter.h" +#include "projections/lambertprojector.h" +#include "projections/projector.h" #include "skycomponents/constellationboundarylines.h" #include "skycomponents/skylabeler.h" #include "skycomponents/skymapcomposite.h" -#include "skyqpainter.h" -#include "projections/projector.h" -#include "projections/lambertprojector.h" +#include "skyobjects/skyobject.h" +#include "skyobjects/deepskyobject.h" +#include "skyobjects/starobject.h" +#include "skyobjects/ksplanetbase.h" #include @@ -55,6 +49,9 @@ #include "ekos/align/align.h" #endif +#include +#include + bool SkyMapDrawAbstract::m_DrawLock = false; SkyMapDrawAbstract::SkyMapDrawAbstract(SkyMap *sm) : m_KStarsData(KStarsData::Instance()), m_SkyMap(sm) @@ -251,7 +248,8 @@ } } - if (align->getStatus() == Ekos::ALIGN_COMPLETE || align->getStatus() == Ekos::ALIGN_PROGRESS) + if (align->getStatus() == KStarsEnum::toType(Ekos::AlignState::ALIGN_COMPLETE) || + align->getStatus() == KStarsEnum::toType(Ekos::AlignState::ALIGN_PROGRESS)) { bool isVisible = false; FOV *fov = align->fov(); Index: kstars/skymaplite.cpp =================================================================== --- kstars/skymaplite.cpp +++ kstars/skymaplite.cpp @@ -1,11 +1,11 @@ -/** ************************************************************************* +/*************************************************************************** skymaplite.cpp - K Desktop Planetarium ------------------- begin : 30/04/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ -/** ************************************************************************* +/*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -15,7 +15,9 @@ ***************************************************************************/ #include "skymaplite.h" + #include "kstarsdata.h" +#include "kstarsenum.h" #include "kstarslite.h" #include "indi/inditelescopelite.h" @@ -742,29 +744,29 @@ p.fillGround = Options::showGround(); //Check if we need a new projector - if (m_proj && Options::projection() == m_proj->type()) + if (m_proj && Options::projection() == (uint)KStarsEnum::toType(m_proj->type())) m_proj->setViewParams(p); else { delete m_proj; switch (Options::projection()) { - case Projector::Gnomonic: + case KStarsEnum::toType(Projector::Projection::Gnomonic): m_proj = new GnomonicProjector(p); break; - case Projector::Stereographic: + case KStarsEnum::toType(Projector::Projection::Stereographic): m_proj = new StereographicProjector(p); break; - case Projector::Orthographic: + case KStarsEnum::toType(Projector::Projection::Orthographic): m_proj = new OrthographicProjector(p); break; - case Projector::AzimuthalEquidistant: + case KStarsEnum::toType(Projector::Projection::AzimuthalEquidistant): m_proj = new AzimuthalEquidistantProjector(p); break; - case Projector::Equirectangular: + case KStarsEnum::toType(Projector::Projection::Equirectangular): m_proj = new EquirectangularProjector(p); break; - case Projector::Lambert: + case KStarsEnum::toType(Projector::Projection::Lambert): default: //TODO: implement other projection classes m_proj = new LambertProjector(p); Index: kstars/skymapliteevents.cpp =================================================================== --- kstars/skymapliteevents.cpp +++ kstars/skymapliteevents.cpp @@ -1,5 +1,8 @@ + #include "skymaplite.h" + #include "kstarsdata.h" +#include "kstarsenum.h" #include "kstarslite.h" #include @@ -518,7 +521,7 @@ uint SkyMapLite::projType() const { - return m_proj->type(); + return (uint)m_proj->type(); } void SkyMapLite::incMagLimit(const int modifier) Index: kstars/skyqpainter.cpp =================================================================== --- kstars/skyqpainter.cpp +++ kstars/skyqpainter.cpp @@ -22,6 +22,7 @@ #include #include "kstarsdata.h" +#include "kstarsenum.h" #include "Options.h" #include "skymap.h" #include "projections/projector.h" @@ -318,7 +319,7 @@ bool pointsVisible = false; //Temporary solution to avoid random lines in Gnomonic projection and draw lines up to horizon - if (SkyMap::Instance()->projector()->type() == Projector::Gnomonic) + if (SkyMap::Instance()->projector()->type() == Projector::Projection::Gnomonic) { if (isVisible && isVisibleLast) pointsVisible = true;