Index: kstars/auxiliary/binfilehelper.cpp =================================================================== --- kstars/auxiliary/binfilehelper.cpp +++ kstars/auxiliary/binfilehelper.cpp @@ -111,7 +111,7 @@ rewind(fileHandle); // Read the first 124 bytes of the binary file which contains a general text about the binary data. - // e.g. "KStars Star Data v1.0. To be read using the 32-bit starData structure only" + // e.g. "KStars Star Data v1.0. To be read using the 32-bit StarData structure only" ret = fread(ASCII_text, 124, 1, fileHandle); // cppcheck-suppress redundantAssignment ASCII_text[124] = '\0'; headerText = ASCII_text; Index: kstars/auxiliary/ksuserdb.cpp =================================================================== --- kstars/auxiliary/ksuserdb.cpp +++ kstars/auxiliary/ksuserdb.cpp @@ -1133,7 +1133,8 @@ void KSUserDB::readScope() { QString model, vendor, type, driver = i18nc("No driver", "None"); - double aperture, focalLength; + double aperture = 0, focalLength = 0; + while (!reader_->atEnd()) { reader_->readNext(); Index: kstars/ekos/align/align.cpp =================================================================== --- kstars/ekos/align/align.cpp +++ kstars/ekos/align/align.cpp @@ -40,6 +40,8 @@ #include #include +#include + #define PAH_CUTOFF_FOV 30 // Minimum FOV width in arcminutes for PAH to work #define MAXIMUM_SOLVER_ITERATIONS 10 @@ -2819,7 +2821,8 @@ // CONTINUE HERE //This block of code along with some sections in the switch below will set the status report in the solution table for this item. - QTableWidgetItem *statusReport = new QTableWidgetItem(); + std::unique_ptr statusReport(new QTableWidgetItem()); + if (loadSlewState == IPS_IDLE) { solutionTable->setCellWidget(currentRow, 3, new QWidget()); @@ -2835,7 +2838,7 @@ if (loadSlewState == IPS_IDLE) { statusReport->setIcon(QIcon(":/icons/AlignSuccess.svg")); - solutionTable->setItem(currentRow, 3, statusReport); + solutionTable->setItem(currentRow, 3, statusReport.release()); } return; @@ -2851,7 +2854,7 @@ if (loadSlewState == IPS_IDLE) { statusReport->setIcon(QIcon(":/icons/AlignFailure.svg")); - solutionTable->setItem(currentRow, 3, statusReport); + solutionTable->setItem(currentRow, 3, statusReport.release()); } solverFailed(); @@ -2865,7 +2868,7 @@ if (loadSlewState == IPS_IDLE) { statusReport->setIcon(QIcon(":/icons/AlignWarning.svg")); - solutionTable->setItem(currentRow, 3, statusReport); + solutionTable->setItem(currentRow, 3, statusReport.release()); } executeGOTO(); @@ -2875,7 +2878,7 @@ if (loadSlewState == IPS_IDLE) { statusReport->setIcon(QIcon(":/icons/AlignSuccess.svg")); - solutionTable->setItem(currentRow, 3, statusReport); + solutionTable->setItem(currentRow, 3, statusReport.release()); } appendLogText(i18n("Target is within acceptable range. Astrometric solver is successful.")); @@ -2891,7 +2894,7 @@ if (loadSlewState == IPS_IDLE) { statusReport->setIcon(QIcon(":/icons/AlignSuccess.svg")); - solutionTable->setItem(currentRow, 3, statusReport); + solutionTable->setItem(currentRow, 3, statusReport.release()); } if (mountModelRunning) { Index: kstars/ekos/align/opsastrometryindexfiles.cpp =================================================================== --- kstars/ekos/align/opsastrometryindexfiles.cpp +++ kstars/ekos/align/opsastrometryindexfiles.cpp @@ -230,8 +230,8 @@ QString indexSeriesName = checkBox->text().remove("&"); QProgressBar *indexDownloadProgress = findChild(indexSeriesName.replace("-", "_").left(10) + "_progress"); - if (indexDownloadProgress) - indexDownloadProgress->setValue((int)(currentIndex * 100 / maxIndex)); + if (indexDownloadProgress && maxIndex > 0) + indexDownloadProgress->setValue(currentIndex*100 / maxIndex); QString indexURL = URL; indexURL.replace("*", indexString); Index: kstars/ekos/capture/capture.cpp =================================================================== --- kstars/ekos/capture/capture.cpp +++ kstars/ekos/capture/capture.cpp @@ -1586,7 +1586,7 @@ //qDebug() << "Exposure with value " << value; - if (state == IPS_OK) + if (activeJob != nullptr && state == IPS_OK) { activeJob->setCaptureRetires(0); activeJob->setExposeLeft(0); Index: kstars/ekos/ekosmanager.cpp =================================================================== --- kstars/ekos/ekosmanager.cpp +++ kstars/ekos/ekosmanager.cpp @@ -918,7 +918,7 @@ { ISD::GDInterface *dev = static_cast(sender()); - if (dev) + if (dev != nullptr) { if (dev->getState("CONNECTION") == IPS_ALERT) indiConnectionStatus = EKOS_STATUS_ERROR; @@ -939,7 +939,8 @@ disconnectB->setEnabled(false); processINDIB->setEnabled(true); - if (dev->getBaseDevice() && (dev->getBaseDevice()->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE)) + if (dev != nullptr && dev->getBaseDevice() && + (dev->getBaseDevice()->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE)) { if (mountProcess.get() != nullptr) mountProcess->setEnabled(false); Index: kstars/ekos/guide/guide.cpp =================================================================== --- kstars/ekos/guide/guide.cpp +++ kstars/ekos/guide/guide.cpp @@ -1337,7 +1337,7 @@ void Guide::updateCCDBin(int index) { - if (currentCCD == nullptr && guiderType != GUIDE_INTERNAL) + if (currentCCD == nullptr || guiderType != GUIDE_INTERNAL) return; ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); @@ -1458,7 +1458,7 @@ return false; } - if (guider) + if (guider != nullptr) { // Disconnect from host if (guider->isConnected()) @@ -1562,25 +1562,29 @@ break; } - connect(guider, SIGNAL(frameCaptureRequested()), this, SLOT(capture())); - connect(guider, SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString))); - connect(guider, SIGNAL(newStatus(Ekos::GuideState)), this, SLOT(setStatus(Ekos::GuideState))); - connect(guider, SIGNAL(newStarPosition(QVector3D, bool)), this, SLOT(setStarPosition(QVector3D, bool))); + if (guider != nullptr) + { + connect(guider, SIGNAL(frameCaptureRequested()), this, SLOT(capture())); + connect(guider, SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString))); + connect(guider, SIGNAL(newStatus(Ekos::GuideState)), this, SLOT(setStatus(Ekos::GuideState))); + connect(guider, SIGNAL(newStarPosition(QVector3D, bool)), this, SLOT(setStarPosition(QVector3D, bool))); - connect(guider, SIGNAL(newAxisDelta(double, double)), this, SLOT(setAxisDelta(double, double))); - connect(guider, SIGNAL(newAxisPulse(double, double)), this, SLOT(setAxisPulse(double, double))); - connect(guider, SIGNAL(newAxisSigma(double, double)), this, SLOT(setAxisSigma(double, double))); + connect(guider, SIGNAL(newAxisDelta(double, double)), this, SLOT(setAxisDelta(double, double))); + connect(guider, SIGNAL(newAxisPulse(double, double)), this, SLOT(setAxisPulse(double, double))); + connect(guider, SIGNAL(newAxisSigma(double, double)), this, SLOT(setAxisSigma(double, double))); + } externalConnectB->setEnabled(false); externalDisconnectB->setEnabled(false); - if (guiderType != GUIDE_INTERNAL) + if (guider != nullptr && guiderType != GUIDE_INTERNAL) { externalConnectB->setEnabled(!guider->isConnected()); externalDisconnectB->setEnabled(guider->isConnected()); } - guider->Connect(); + if (guider != nullptr) + guider->Connect(); return true; } Index: kstars/ekos/guide/internalguide/gmath.h =================================================================== --- kstars/ekos/guide/internalguide/gmath.h +++ kstars/ekos/guide/internalguide/gmath.h @@ -9,21 +9,23 @@ version 2 of the License, or (at your option) any later version. */ -#ifndef GMATH_H_ -#define GMATH_H_ +#pragma once #include #include +#include "matr.h" +#include "vect.h" +#include "indi/indicommon.h" + #include -#include #include +#include +#include -#include "fitsviewer/fitsview.h" -#include "indi/indicommon.h" +class QFile; -#include "vect.h" -#include "matr.h" +class FITSView; typedef struct { @@ -51,7 +53,6 @@ #define GUIDE_RA 0 #define GUIDE_DEC 1 #define CHANNEL_CNT 2 -#define DEFAULT_SQR 1 #define MAX_ACCUM_CNT 50 extern const guide_square_t guide_squares[]; @@ -65,7 +66,6 @@ void reset(void); int threshold_alg_idx; - double guiding_rate; bool enabled[CHANNEL_CNT]; bool enabled_axis1[CHANNEL_CNT]; bool enabled_axis2[CHANNEL_CNT]; @@ -179,25 +179,50 @@ // Templated functions template Vector findLocalStarPosition(void) const; - // sys... - uint32_t ticks; // global channel ticker - QPointer guideView; // pointer to image - int video_width, video_height; // video frame dimensions - double ccd_pixel_width, ccd_pixel_height, aperture, focal; + + // Creates a new float image from the guideView image data. The returned image MUST be deleted later or memory will leak. + float *createFloatImage() const; + + void do_ticks(void); + Vector point2arcsec(const Vector &p) const; + void process_axes(void); + void calc_square_err(void); + const char *get_direction_string(GuideDirection dir); + + /// Global channel ticker + uint32_t ticks { 0 }; + /// Pointer to image + QPointer guideView; + /// Video frame width + int video_width { -1 }; + /// Video frame height + int video_height { -1 }; + double ccd_pixel_width { 0 }; + double ccd_pixel_height { 0 }; + double aperture { 0 }; + double focal { 0 }; Matrix ROT_Z; - bool preview_mode, suspended, lost_star, dec_swap; + bool preview_mode { true }; + bool suspended { false }; + bool lost_star { false }; + bool dec_swap { false }; // square variables - int squareSize; // size of analysing square - int square_alg_idx; // index of threshold algorithm - int subBinX, subBinY; + /// Analyzing square size + int squareSize { 0 }; + /// Index of threshold algorithm + int square_alg_idx { SMART_THRESHOLD }; + int subBinX { 1 }; + int subBinY { 1 }; // sky coord. system vars. - Vector star_pos; // position of star in reticle coord. system - Vector scr_star_pos; // sctreen star position + /// Star position in reticle coord. system + Vector star_pos; + /// Star position on the screen + Vector scr_star_pos; Vector reticle_pos; Vector reticle_orts[2]; - double reticle_angle; + double reticle_angle { 0 }; // processing uint32_t channel_ticks[2]; @@ -210,36 +235,25 @@ cproc_out_params out_params; // stat math... - bool do_statistics; - double sum, sqr_sum; - double delta_prev, sigma_prev, sigma; - - // proc - void do_ticks(void); - Vector point2arcsec(const Vector &p) const; - void process_axes(void); - void calc_square_err(void); - const char *get_direction_string(GuideDirection dir); + bool do_statistics { true }; + double sum { 0 }; // rapid guide - bool useRapidGuide = false; - double rapidDX, rapidDY; + bool useRapidGuide { false }; + double rapidDX { 0 }; + double rapidDY { 0 }; // Image Guide - bool imageGuideEnabled = false; - // Creates a new float image from the guideView image data. The returned image MUST be deleted later or memory will leak. - float *createFloatImage() const; + bool imageGuideEnabled { false }; // Partition guideView image into NxN square regions each of size axis*axis. The returned vector contains pointers to // the newly allocated square images. It MUST be deleted later by delete[] or memory will leak. QVector partitionImage() const; - uint32_t regionAxis = 64; + uint32_t regionAxis { 64 }; QVector referenceRegions; // dithering double ditherRate[2]; - QFile *logFile; + QFile *logFile { nullptr }; QTime logTime; }; - -#endif /*GMATH_H_*/ Index: kstars/ekos/guide/internalguide/gmath.cpp =================================================================== --- kstars/ekos/guide/internalguide/gmath.cpp +++ kstars/ekos/guide/internalguide/gmath.cpp @@ -9,19 +9,14 @@ version 2 of the License, or (at your option) any later version. */ -#include "Options.h" - #include "gmath.h" -#include -#include - -#include "vect.h" -#include "matr.h" - +#include "imageautoguiding.h" +#include "Options.h" #include "fitsviewer/fitsdata.h" #include "fitsviewer/fitsview.h" -#include "imageautoguiding.h" + +#include #define DEF_SQR_0 (8 - 0) #define DEF_SQR_1 (16 - 0) @@ -50,24 +45,7 @@ cgmath::cgmath() : QObject() { // sys... - ticks = 0; - video_width = -1; - video_height = -1; - ccd_pixel_width = 0; - ccd_pixel_height = 0; - focal = 0; - aperture = 0; ROT_Z = Matrix(0); - preview_mode = true; - suspended = false; - lost_star = false; - useRapidGuide = false; - dec_swap = false; - - subBinX = subBinY = 1; - - // square variables - square_alg_idx = SMART_THRESHOLD; // sky coord. system vars. star_pos = Vector(0); @@ -89,11 +67,6 @@ memset(drift[GUIDE_RA], 0, sizeof(double) * MAX_ACCUM_CNT); memset(drift[GUIDE_DEC], 0, sizeof(double) * MAX_ACCUM_CNT); drift_integral[GUIDE_RA] = drift_integral[GUIDE_DEC] = 0; - - // statistics - do_statistics = true; - sum = sqr_sum = 0; - delta_prev = sigma_prev = sigma = 0; } cgmath::~cgmath() @@ -490,8 +463,7 @@ memset(drift[GUIDE_DEC], 0, sizeof(double) * MAX_ACCUM_CNT); // cleanup stat vars. - sum = sqr_sum = 0; - delta_prev = sigma_prev = sigma = 0; + sum = 0; preview_mode = false; @@ -542,6 +514,7 @@ // We only process 1st plane if it is a color image uint32_t imgSize = imageData->getSize(); float *imgFloat = new float[imgSize]; + if (imgFloat == nullptr) { qCritical() << "Not enough memory for float image array!"; @@ -615,6 +588,7 @@ break; default: + delete[] imgFloat; return nullptr; } @@ -1426,7 +1400,6 @@ void cproc_in_params::reset(void) { threshold_alg_idx = CENTROID_THRESHOLD; - guiding_rate = 0.5; average = true; for (int k = GUIDE_RA; k <= GUIDE_DEC; k++) Index: kstars/ekos/guide/internalguide/imageautoguiding.h =================================================================== --- kstars/ekos/guide/internalguide/imageautoguiding.h +++ kstars/ekos/guide/internalguide/imageautoguiding.h @@ -7,6 +7,8 @@ version 2 of the License, or (at your option) any later version. */ +#pragma once + // Robert Majewski // ImageAutoGuiding1 is self contained Index: kstars/ekos/guide/internalguide/imageautoguiding.cpp =================================================================== --- kstars/ekos/guide/internalguide/imageautoguiding.cpp +++ kstars/ekos/guide/internalguide/imageautoguiding.cpp @@ -9,12 +9,9 @@ #include "imageautoguiding.h" -#include +#include -#include -#include -#include -#include +#include #define SWAP(a, b) \ tempr = (a); \ @@ -293,7 +290,7 @@ long idim; unsigned long i1, i2rev, i3rev, ip1, ip2, ip3, ifp1, ifp2; unsigned long i2, i3; - unsigned long ibit, k1, k2, n, nprev, nrem, ntot; + unsigned long ibit, k1 = 0, k2, n, nprev, nrem, ntot; float wi, wr, tempi, tempr; double theta, wpi, wpr, wtemp; Index: kstars/ekos/profileeditor.cpp =================================================================== --- kstars/ekos/profileeditor.cpp +++ kstars/ekos/profileeditor.cpp @@ -393,8 +393,8 @@ ui->guiderCombo->addItem(value); row = ui->guiderCombo->count() - 1; } - else - ui->guiderCombo->setCurrentIndex(row); + + ui->guiderCombo->setCurrentIndex(row); } else if (key == "Focuser") { Index: kstars/ekos/scheduler/mosaic.cpp =================================================================== --- kstars/ekos/scheduler/mosaic.cpp +++ kstars/ekos/scheduler/mosaic.cpp @@ -9,13 +9,11 @@ #include "mosaic.h" -#include "skymap.h" -#include "projections/projector.h" - +#include "Options.h" #include "scheduler.h" +#include "skymap.h" #include "ekos/ekosmanager.h" - -#include "Options.h" +#include "projections/projector.h" namespace Ekos { @@ -115,7 +113,7 @@ qDebug() << "FovW " << fovW << " FovH " << fovH; qDebug() << "initX" - << "initX " << initX << " initY " << initY; + << "initX " << x << " initY " << y; qDebug() << "Offset X " << xOffset << " Y " << yOffset; for (int row = 0; row < h; row++) Index: kstars/fitsviewer/fitsdata.cpp =================================================================== --- kstars/fitsviewer/fitsdata.cpp +++ kstars/fitsviewer/fitsdata.cpp @@ -1080,7 +1080,10 @@ // If no stars were detected if (center->width == -1) + { + delete center; return 0; + } // 30% fuzzy //center->width += center->width*0.3 * (running_threshold / threshold); @@ -2137,7 +2140,7 @@ int status = 0; char *header; int nkeyrec, nreject, nwcs, stat[2]; - double imgcrd[2], phi, pixcrd[2], theta, world[2]; + double imgcrd[2], phi = 0, pixcrd[2], theta = 0, world[2]; int width = getWidth(); int height = getHeight(); Index: kstars/fitsviewer/fitshistogram.cpp =================================================================== --- kstars/fitsviewer/fitshistogram.cpp +++ kstars/fitsviewer/fitshistogram.cpp @@ -410,6 +410,7 @@ if (r != Z_OK) { + delete[] raw_delta; /* this should NEVER happen */ qDebug() << "FITSHistogram Error: Failed to compress raw_delta" << endl; return false; Index: kstars/fitsviewer/fitsview.cpp =================================================================== --- kstars/fitsviewer/fitsview.cpp +++ kstars/fitsviewer/fitsview.cpp @@ -11,6 +11,7 @@ #include "fitsview.h" #include "config-kstars.h" + #include "fitsdata.h" #include "fitslabel.h" #include "kspopupmenu.h" Index: kstars/fitsviewer/fitsviewer.cpp =================================================================== --- kstars/fitsviewer/fitsviewer.cpp +++ kstars/fitsviewer/fitsviewer.cpp @@ -19,6 +19,8 @@ #include "fitsviewer.h" +#include "config-kstars.h" + #include "fitsdata.h" #include "fitsdebayer.h" #include "fitstab.h" Index: kstars/indi/indiccd.cpp =================================================================== --- kstars/indi/indiccd.cpp +++ kstars/indi/indiccd.cpp @@ -1025,8 +1025,8 @@ IBLOBVectorProperty *rawBP = baseDevice->getBLOB("CCD1"); if (rawBP) { - int x, y, w, h; - int binx, biny; + int x = 0, y = 0, w = 0, h = 0; + int binx = 0, biny = 0; primaryChip->getFrame(&x, &y, &w, &h); primaryChip->getBinning(&binx, &biny); Index: kstars/indi/indielement.h =================================================================== --- kstars/indi/indielement.h +++ kstars/indi/indielement.h @@ -9,40 +9,35 @@ 2004-01-15 INDI element is the most basic unit of the INDI KStars client. */ -#ifndef INDIELEMENT_H_ -#define INDIELEMENT_H_ +#pragma once -#include -#include -#include -#include +#include "indicommon.h" -#include #include -#include "indicommon.h" +#include +#include /* Forward decleration */ -class KLed; class QLineEdit; class QDoubleSpinBox; class QPushButton; -class KSqueezedTextLabel; -class QLabel; class QHBoxLayout; -class QVBoxLayout; class QSpacerItem; class QCheckBox; class QButtonGroup; class QSlider; +class KLed; +class KSqueezedTextLabel; + class INDI_P; /** * @class INDI_E - * INDI_E represents an INDI GUI element (Number, Text, Switch, Light, or BLOB) within an INDI property. It is the most basic - * GUI representation of property elements. + * INDI_E represents an INDI GUI element (Number, Text, Switch, Light, or BLOB) within an INDI property. + * It is the most basic GUI representation of property elements. * * @author Jasem Mutlaq */ @@ -90,40 +85,50 @@ bool getBLOBDirty() { return blobDirty; } void setBLOBDirty(bool isDirty) { blobDirty = isDirty; } - private: - QString name; /* name */ - QString label; /* label is the name by default, unless specified */ - - INDI::Property *dataProp; /* parent DATA property */ - INDI_P *guiProp; /* parent GUI property */ - - QHBoxLayout *EHBox; /* Horizontal layout */ - - /* GUI widgets, only malloced when needed */ - KSqueezedTextLabel *label_w; // label - QLineEdit *read_w; // read field - QLineEdit *write_w; // write field - KLed *led_w; // light led - QDoubleSpinBox *spin_w; // spinbox - QSlider *slider_w; // Slider - QPushButton *push_w; // push button - QPushButton *browse_w; // browse button - QCheckBox *check_w; // check box - QSpacerItem *hSpacer; // Horizontal spacer - - ISwitch *sp; - INumber *np; - IText *tp; - ILight *lp; - IBLOB *bp; - - bool blobDirty; - QString text; // current text - public slots: void spinChanged(double value); void sliderChanged(int value); void browseBlob(); -}; -#endif +private: + /// Name + QString name; + /// Label is the name by default, unless specified + QString label; + /// Parent DATA property + INDI::Property *dataProp { nullptr }; + /// Parent GUI property + INDI_P *guiProp { nullptr }; + /// Horizontal layout + QHBoxLayout *EHBox { nullptr }; + /// Label widget + KSqueezedTextLabel *label_w { nullptr }; + /// Read field widget + QLineEdit *read_w { nullptr }; + /// Write field widget + QLineEdit *write_w { nullptr }; + /// Light led widget + KLed *led_w { nullptr }; + /// Spinbox widget + QDoubleSpinBox *spin_w { nullptr }; + /// Slider widget + QSlider *slider_w { nullptr }; + /// Push button widget + QPushButton *push_w { nullptr }; + /// Browse button widget + QPushButton *browse_w { nullptr }; + /// Check box widget + QCheckBox *check_w { nullptr }; + /// Horizontal spacer widget + QSpacerItem *hSpacer { nullptr }; + + ISwitch *sp { nullptr }; + INumber *np { nullptr }; + IText *tp { nullptr }; + ILight *lp { nullptr }; + IBLOB *bp { nullptr }; + + bool blobDirty { false }; + /// Current text + QString text; +}; Index: kstars/indi/indielement.cpp =================================================================== --- kstars/indi/indielement.cpp +++ kstars/indi/indielement.cpp @@ -9,34 +9,28 @@ 2004-01-15 INDI element is the most basic unit of the INDI KStars client. */ -#include - #include "indielement.h" + #include "indiproperty.h" #include "indigroup.h" #include "indidevice.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include #include -#include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include + extern const char *libindi_strings_context; /******************************************************************* @@ -49,20 +43,6 @@ EHBox = new QHBoxLayout; EHBox->setMargin(0); - - tp = nullptr; - sp = nullptr; - np = nullptr; - label_w = nullptr; - read_w = nullptr; - write_w = nullptr; - spin_w = nullptr; - slider_w = nullptr; - push_w = nullptr; - browse_w = nullptr; - check_w = nullptr; - led_w = nullptr; - hSpacer = nullptr; } INDI_E::~INDI_E() @@ -656,6 +636,7 @@ { KMessageBox::error(0, i18n("Not enough memory for file %1", filename)); fp.close(); + return; } memcpy(bp->blob, fp.readAll().constData(), bp->size); Index: kstars/ksalmanac.h =================================================================== --- kstars/ksalmanac.h +++ kstars/ksalmanac.h @@ -16,8 +16,7 @@ * * ***************************************************************************/ -#ifndef KSALMANAC_H_ -#define KSALMANAC_H_ +#pragma once #include "skyobjects/kssun.h" #include "skyobjects/ksmoon.h" @@ -131,11 +130,15 @@ KSMoon m_Moon; KStarsDateTime dt; - const GeoLocation *geo; - double SunRise, SunSet, MoonRise, MoonSet, DuskAstronomicalTwilight, DawnAstronomicalTwilight; - double SunMinAlt, SunMaxAlt; - double MoonPhase; + const GeoLocation *geo { nullptr }; + double SunRise { 0 }; + double SunSet { 0 }; + double MoonRise { 0 }; + double MoonSet { 0 }; + double DuskAstronomicalTwilight { 0 }; + double DawnAstronomicalTwilight { 0 }; + double SunMinAlt { 0 }; + double SunMaxAlt { 0 }; + double MoonPhase { 0 }; QTime SunRiseT, SunSetT, MoonRiseT, MoonSetT, DuskAstronomicalTwilightT, DawnAstronomicalTwilightT; }; - -#endif Index: kstars/ksalmanac.cpp =================================================================== --- kstars/ksalmanac.cpp +++ kstars/ksalmanac.cpp @@ -18,18 +18,11 @@ #include "ksalmanac.h" -#include - #include "geolocation.h" -#include "kstarsdata.h" -#include "kstarsdatetime.h" #include "ksnumbers.h" -#include "dms.h" -#include "skyobjects/kssun.h" -#include "skyobjects/ksmoon.h" -#include "skyobjects/skyobject.h" +#include "kstarsdata.h" -KSAlmanac::KSAlmanac() : SunRise(0), SunSet(0), MoonRise(0), MoonSet(0) +KSAlmanac::KSAlmanac() { KStarsData *data = KStarsData::Instance(); @@ -122,7 +115,8 @@ if (!asc && last_alt >= -18.0 && alt <= -18.0) dusk = h; - last_h = h; + // Never used +// last_h = h; last_alt = alt; } Index: kstars/kspopupmenu.h =================================================================== --- kstars/kspopupmenu.h +++ kstars/kspopupmenu.h @@ -15,30 +15,32 @@ * * ***************************************************************************/ -#ifndef KSPOPUPMENU_H_ -#define KSPOPUPMENU_H_ +#pragma once #include -#include #include -class StarObject; -class SkyPoint; -class SkyObject; +class QAction; + class DeepSkyObject; class KSMoon; class Satellite; +class SkyObject; +class SkyPoint; +class StarObject; class Supernova; -/** @class KSPopupMenu - *The KStars Popup Menu. The menu is sensitive to the - *object type of the object which was clicked to invoke the menu. - *Items in the menu include name and type data; rise/transit/set times; - *actions such as Center, Details, Telescope actions, and Label; - *and Image and Information URL links. - *@author Jason Harris - *@version 1.0 - */ +/** + * @class KSPopupMenu + * The KStars Popup Menu. The menu is sensitive to the + * object type of the object which was clicked to invoke the menu. + * Items in the menu include name and type data; rise/transit/set times; + * actions such as Center, Details, Telescope actions, and Label; + * and Image and Information URL links. + * + * @author Jason Harris + * @version 1.0 + */ class KSPopupMenu : public QMenu { Q_OBJECT @@ -49,74 +51,80 @@ /** Destructor (empty)*/ ~KSPopupMenu(); - /** Add an item to the popup menu for each of the URL links associated with - * this object. URL links appear in two categories: images and information pages. - * For some objects, a link to Digitized Sky Survey images will automatically be added - * in addition to the object's normal image links. Also, for some objects, an - * "Add link..." item will be included, which allows the user to add their own custom - * URLs for this object. - * @param obj pointer to the skyobject which the menu describes - * @param showDSS if true, include DSS Image links - */ + /** + * Add an item to the popup menu for each of the URL links associated with + * this object. URL links appear in two categories: images and information pages. + * For some objects, a link to Digitized Sky Survey images will automatically be added + * in addition to the object's normal image links. Also, for some objects, an + * "Add link..." item will be included, which allows the user to add their own custom + * URLs for this object. + * @param obj pointer to the skyobject which the menu describes + * @param showDSS if true, include DSS Image links + */ void addLinksToMenu(SkyObject *obj, bool showDSS = true); - /** @short Create a popup menu for a star. - * - * Stars get the following labels: a primary name and/or a genetive name, - * a spectral type, an object type ("star"), and rise/transit/set times. - * Stars get a "Center & Track" item, an Angular Distance item, and a - * "Detailed Info" item. Named stars get an "Attach Label" item and an - * "Add Link..." item, and may have image/info links; all stars get DSS - * image links. Stars do not get an "Add Trail" item. - * @param star pointer to the star which the menu describes - */ + /** + * @short Create a popup menu for a star. + * + * Stars get the following labels: a primary name and/or a genetive name, + * a spectral type, an object type ("star"), and rise/transit/set times. + * Stars get a "Center & Track" item, an Angular Distance item, and a + * "Detailed Info" item. Named stars get an "Attach Label" item and an + * "Add Link..." item, and may have image/info links; all stars get DSS + * image links. Stars do not get an "Add Trail" item. + * @param star pointer to the star which the menu describes + */ void createStarMenu(StarObject *star); - /** @short Create a popup menu for a deep-sky object. - * - * DSOs get the following labels: - * a common name and/or a catalog name, an object type, and rise/transit/set - * times. DSOs get a "Center & Track" item, an Angular Distance item, an - * "Attach Label" item, and a "Detailed Info" item. - * They may have image/info links, and also get the DSS Image links and the - * "Add Link..." item. They do not get an "Add Trail" item. - * @param obj pointer to the object which the menu describes - */ + /** + * @short Create a popup menu for a deep-sky object. + * + * DSOs get the following labels: + * a common name and/or a catalog name, an object type, and rise/transit/set + * times. DSOs get a "Center & Track" item, an Angular Distance item, an + * "Attach Label" item, and a "Detailed Info" item. + * They may have image/info links, and also get the DSS Image links and the + * "Add Link..." item. They do not get an "Add Trail" item. + * @param obj pointer to the object which the menu describes + */ void createDeepSkyObjectMenu(DeepSkyObject *obj); - /** @short Create a popup menu for a solar system body. - * - * Solar System bodies get a name label, a type label ("solar system object"), - * and rise/set/transit time labels. They also get Center&Track, - * Angular Distance, Detailed Info, Attach Label, and Add Trail items. - * They can have image/info links, and also get the "Add Link..." item. - * @note despite the name "createPlanetMenu", this function is used for - * comets and asteroids as well. - * @param p the solar system object which the menu describes. - */ + /** + * @short Create a popup menu for a solar system body. + * + * Solar System bodies get a name label, a type label ("solar system object"), + * and rise/set/transit time labels. They also get Center&Track, + * Angular Distance, Detailed Info, Attach Label, and Add Trail items. + * They can have image/info links, and also get the "Add Link..." item. + * @note despite the name "createPlanetMenu", this function is used for + * comets and asteroids as well. + * @param p the solar system object which the menu describes. + */ void createPlanetMenu(SkyObject *p); void createMoonMenu(KSMoon *moon); - /** @short Create a popup menu for a satellite. - * @param satellite the satellite which the menu describes. - */ + /** + * @short Create a popup menu for a satellite. + * @param satellite the satellite which the menu describes. + */ void createSatelliteMenu(Satellite *satellite); /** - * @short Create a popup menu for a supernova - * @param supernova the supernova which the menu describes. - */ + * @short Create a popup menu for a supernova + * @param supernova the supernova which the menu describes. + */ void createSupernovaMenu(Supernova *supernova); - /** @short Create a popup menu for empty sky. - * - * The popup menu when right-clicking on nothing is still useful. - * Instead of a name label, it shows "Empty Sky". The rise/set/transit - * times of the clicked point on the sky are also shown. You also get - * the Center & Track and Angular Distance items, and the DSS image links. - * @param nullObj pointer to point on the sky - */ + /** + * @short Create a popup menu for empty sky. + * + * The popup menu when right-clicking on nothing is still useful. + * Instead of a name label, it shows "Empty Sky". The rise/set/transit + * times of the clicked point on the sky are also shown. You also get + * the Center & Track and Angular Distance items, and the DSS image links. + * @param nullObj pointer to point on the sky + */ void createEmptyMenu(SkyPoint *nullObj); private slots: @@ -127,35 +135,36 @@ void slotViewInWI(); private: - /** Initialize the popup menus. Adds name and type labels, and possibly - * Rise/Set/Transit labels, Center/Track item, and Show Details item. - * @short initialize the right-click popup menu - * @param obj pointer to the skyobject which the menu describes - * @param name The object name - * @param type a string identifying the object type - * @param type short information about object - * @param showDetails if true, the Show-Details item is added - * @param showObsList if true, the Add to List/Remove from List item is added. - */ - void initPopupMenu(SkyObject *obj, QString name, QString type, QString info, bool showDetails = true, + /** + * Initialize the popup menus. Adds name and type labels, and possibly + * Rise/Set/Transit labels, Center/Track item, and Show Details item. + * @short initialize the right-click popup menu + * @param obj pointer to the skyobject which the menu describes + * @param name The object name + * @param type a string identifying the object type + * @param type short information about object + * @param showDetails if true, the Show-Details item is added + * @param showObsList if true, the Add to List/Remove from List item is added. + */ + void initPopupMenu(SkyObject *obj, const QString &name, const QString &type, QString info, bool showDetails = true, bool showObsList = true, bool showFlags = true); void initFlagActions(SkyObject *obj); - /** Add a submenu for INDI controls (Slew, Track, Sync, etc). - * @return true if a valid INDI menu was added. - */ + /** + * Add a submenu for INDI controls (Slew, Track, Sync, etc). + * @return true if a valid INDI menu was added. + */ void addINDI(); - /** Add fancy label to menu. - * @param name is content of the label - * @param deltaFontSize is change in font size from default - */ - void addFancyLabel(QString name, int deltaFontSize = 0); - - int m_CurrentFlagIdx; - QHash *m_EditActionMapping; - QHash *m_DeleteActionMapping; + /** + * Add fancy label to menu. + * @param name is content of the label + * @param deltaFontSize is change in font size from default + */ + void addFancyLabel(const QString &name, int deltaFontSize = 0); + + int m_CurrentFlagIdx { 0 }; + QHash *m_EditActionMapping { nullptr }; + QHash *m_DeleteActionMapping { nullptr }; }; - -#endif Index: kstars/kspopupmenu.cpp =================================================================== --- kstars/kspopupmenu.cpp +++ kstars/kspopupmenu.cpp @@ -17,13 +17,11 @@ #include "kspopupmenu.h" -#include -#include - -#include +#include "config-kstars.h" #include "kstars.h" #include "kstarsdata.h" +#include "skymap.h" #include "skyobjects/skyobject.h" #include "skyobjects/starobject.h" #include "skyobjects/trailobject.h" @@ -31,15 +29,13 @@ #include "skyobjects/ksmoon.h" #include "skyobjects/satellite.h" #include "skyobjects/supernova.h" -#include "skycomponents/skymapcomposite.h" +#include "skycomponents/constellationboundarylines.h" #include "skycomponents/flagcomponent.h" -#include "skymap.h" +#include "skycomponents/skymapcomposite.h" #include "tools/whatsinteresting/wiview.h" #include "observinglist.h" -#include - #ifdef HAVE_INDI #include "indi/indilistener.h" #include "indi/guimanager.h" @@ -52,7 +48,10 @@ #include #endif -#include "skycomponents/constellationboundarylines.h" +#include + +#include +#include namespace { @@ -307,18 +306,20 @@ initPopupMenu(supernova, name, i18n("supernova"), info); } -void KSPopupMenu::initPopupMenu(SkyObject *obj, QString name, QString type, QString info, bool showDetails, - bool showObsList, bool showFlags) +void KSPopupMenu::initPopupMenu(SkyObject *obj, const QString &name, const QString &type, QString info, + bool showDetails, bool showObsList, bool showFlags) { KStarsData *data = KStarsData::Instance(); SkyMap *map = SkyMap::Instance(); clear(); - bool showLabel = name != i18n("star") && !name.isEmpty(); - if (name.isEmpty()) - name = i18n("Empty sky"); + bool showLabel = (name != i18n("star") && !name.isEmpty()); + QString Name = name; - addFancyLabel(name); + if (Name.isEmpty()) + Name = i18n("Empty sky"); + + addFancyLabel(Name); addFancyLabel(type); addFancyLabel(info); addFancyLabel(KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName(obj)); @@ -594,10 +595,11 @@ connect(sMapper, SIGNAL(mapped(QObject *)), gd, SLOT(setProperty(QObject *))); - menuDevice->addSeparator(); + if (menuDevice != nullptr) + menuDevice->addSeparator(); } - if (telescope && menuDevice) + if (telescope != nullptr && menuDevice != nullptr) { menuDevice->addSeparator(); @@ -613,7 +615,7 @@ #endif } -void KSPopupMenu::addFancyLabel(QString name, int deltaFontSize) +void KSPopupMenu::addFancyLabel(const QString &name, int deltaFontSize) { if (name.isEmpty()) return; Index: kstars/kstarsinit.cpp =================================================================== --- kstars/kstarsinit.cpp +++ kstars/kstarsinit.cpp @@ -15,42 +15,19 @@ * * ***************************************************************************/ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include "kstars.h" -#include -#include "Options.h" #include "fov.h" -#include "kstars.h" -#include "kstarsdata.h" #include "kspaths.h" +#include "kstarsdata.h" +#include "Options.h" #include "skymap.h" +#include "texturemanager.h" #include "projections/projector.h" -#include "skyobjects/skyobject.h" +#include "skycomponents/skymapcomposite.h" #include "skyobjects/ksplanetbase.h" -#include "simclock.h" #include "widgets/timestepbox.h" -#include "oal/equipmentwriter.h" -#include "oal/observeradd.h" -#include "skycomponents/skymapcomposite.h" -#include "texturemanager.h" -#include "kspaths.h" - -#include -#include #ifdef HAVE_INDI #include "indi/drivermanager.h" @@ -58,6 +35,12 @@ #include "ekos/ekosmanager.h" #endif +#include +#include +#include +#include +#include + //This file contains functions that kstars calls at startup (except constructors). //These functions are declared in kstars.h Index: kstars/printing/shfovexporter.h =================================================================== --- kstars/printing/shfovexporter.h +++ kstars/printing/shfovexporter.h @@ -15,60 +15,56 @@ * * ***************************************************************************/ -#ifndef SHFOVEXPORTER_H -#define SHFOVEXPORTER_H +#pragma once +#include "skypoint.h" #include "starhopper.h" -#include "ksutils.h" -class SkyMap; class PrintingWizard; +class SkyMap; /** - * \class ShFovExporter - * \brief Helper class used as a wrapper for StarHopper when capturing FOV snapshots. - * \author Rafał Kułaga - */ + * \class ShFovExporter + * \brief Helper class used as a wrapper for StarHopper when capturing FOV snapshots. + * + * \author Rafał Kułaga + */ class ShFovExporter { public: - /** - * \brief Constructor. - */ + /** Constructor */ ShFovExporter(PrintingWizard *wizard, SkyMap *map); /** - * \brief Calculate path between source and destination SkyPoints. - * \param src SkyPoint at which StarHopper will begin. - * \param dest SkyPoint at which StarHopper will end. - * \param fov Star hopping field of view angle (in deg). - * \param maglim Magnitude limit. - * \return True if path has been found. - */ + * \brief Calculate path between source and destination SkyPoints. + * \param src SkyPoint at which StarHopper will begin. + * \param dest SkyPoint at which StarHopper will end. + * \param fov Star hopping field of view angle (in deg). + * \param maglim Magnitude limit. + * \return True if path has been found. + */ bool calculatePath(const SkyPoint &src, const SkyPoint &dest, double fov, double maglim); /** - * \brief Export FOV snapshots across calculated path. - * \return False if path is empty. - * \note You should call ShFovExporter::calculatePath() before calling this method. - */ + * \brief Export FOV snapshots across calculated path. + * \return False if path is empty. + * \note You should call ShFovExporter::calculatePath() before calling this method. + */ bool exportPath(); private: /** - * \brief Private method: center SkyMap between two SkyPoints and capture FOV snapshot. - * \param ptA Beginning point. - * \param ptB Ending point. - */ + * \brief Private method: center SkyMap between two SkyPoints and capture FOV snapshot. + * \param ptA Beginning point. + * \param ptB Ending point. + */ void centerBetweenAndCapture(const SkyPoint &ptA, const SkyPoint &ptB); - SkyMap *m_Map; + SkyMap *m_Map { nullptr }; StarHopper m_StarHopper; SkyPoint m_Src; SkyPoint m_Dest; - PrintingWizard *m_ParentWizard; + PrintingWizard *m_ParentWizard { nullptr }; QList m_Path; - QList *m_skyObjList; + QList *m_skyObjList { nullptr }; }; - -#endif // SHFOVEXPORTER_H Index: kstars/printing/shfovexporter.cpp =================================================================== --- kstars/printing/shfovexporter.cpp +++ kstars/printing/shfovexporter.cpp @@ -23,7 +23,6 @@ #include "kstarsdata.h" #include "skymapcomposite.h" #include "skymap.h" -#include "skypoint.h" #include "printingwizard.h" ShFovExporter::ShFovExporter(PrintingWizard *wizard, SkyMap *map) : m_Map(map), m_ParentWizard(wizard) Index: kstars/skycomponents/deepstarcomponent.h =================================================================== --- kstars/skycomponents/deepstarcomponent.h +++ kstars/skycomponents/deepstarcomponent.h @@ -107,8 +107,8 @@ bool starsInAperture(QList &list, const SkyPoint ¢er, float radius, float maglim = -29); // TODO: Find the right place for this method - static void byteSwap(deepStarData *stardata); - static void byteSwap(starData *stardata); + static void byteSwap(DeepStarData *stardata); + static void byteSwap(StarData *stardata); static StarBlockFactory m_StarBlockFactory; @@ -135,8 +135,8 @@ bool staticStars { false }; // Stuff required for reading data - deepStarData deepstardata; - starData stardata; + DeepStarData deepstardata; + StarData stardata; BinFileHelper starReader; QString dataFileName; }; Index: kstars/skycomponents/deepstarcomponent.cpp =================================================================== --- kstars/skycomponents/deepstarcomponent.cpp +++ kstars/skycomponents/deepstarcomponent.cpp @@ -125,11 +125,11 @@ for (quint64 j = 0; j < records; ++j) { - bool fread_success = fread(&stardata, sizeof(starData), 1, dataFile); + bool fread_success = fread(&stardata, sizeof(StarData), 1, dataFile); if (!fread_success) { - qDebug() << "ERROR: Could not read starData structure for star #" << j << " under trixel #" + qDebug() << "ERROR: Could not read StarData structure for star #" << j << " under trixel #" << trixel << endl; } @@ -177,11 +177,11 @@ for (quint64 j = 0; j < records; ++j) { bool fread_success = false; - fread_success = fread(&deepstardata, sizeof(deepStarData), 1, dataFile); + fread_success = fread(&deepstardata, sizeof(DeepStarData), 1, dataFile); if (!fread_success) { - qDebug() << "ERROR: Could not read starData structure for star #" << j << " under trixel #" + qDebug() << "ERROR: Could not read StarData structure for star #" << j << " under trixel #" << trixel << endl; } @@ -601,7 +601,7 @@ return true; } -void DeepStarComponent::byteSwap(deepStarData *stardata) +void DeepStarComponent::byteSwap(DeepStarData *stardata) { stardata->RA = bswap_32(stardata->RA); stardata->Dec = bswap_32(stardata->Dec); @@ -611,7 +611,7 @@ stardata->V = bswap_16(stardata->V); } -void DeepStarComponent::byteSwap(starData *stardata) +void DeepStarComponent::byteSwap(StarData *stardata) { stardata->RA = bswap_32(stardata->RA); stardata->Dec = bswap_32(stardata->Dec); Index: kstars/skycomponents/linelistindex.h =================================================================== --- kstars/skycomponents/linelistindex.h +++ kstars/skycomponents/linelistindex.h @@ -114,27 +114,21 @@ /** * @short Typically called from within a subclasses constructors. * Adds the trixels covering the outline of lineList to the lineIndex. - * - * @param debug if greater than zero causes the number of trixels found - * to be printed. */ - void appendLine(const std::shared_ptr &lineList, int debug = 0); + void appendLine(const std::shared_ptr &lineList); void removeLine(const std::shared_ptr &lineList); /** * @short Typically called from within a subclasses constructors. * Adds the trixels covering the full lineList to the polyIndex. - * - * @param debug if greater than zero causes the number of trixels found - * to be printed. */ - void appendPoly(const std::shared_ptr &lineList, int debug = 0); + void appendPoly(const std::shared_ptr &lineList); /** * @short a convenience method that adds a lineList to both the lineIndex and the polyIndex. */ - void appendBoth(const std::shared_ptr &lineList, int debug = 0); + void appendBoth(const std::shared_ptr &lineList); /** * @short Draws all the lines in m_listList as simple lines in float mode. Index: kstars/skycomponents/linelistindex.cpp =================================================================== --- kstars/skycomponents/linelistindex.cpp +++ kstars/skycomponents/linelistindex.cpp @@ -75,11 +75,8 @@ m_listList.removeOne(lineList); } -void LineListIndex::appendLine(const std::shared_ptr &lineList, int debug) +void LineListIndex::appendLine(const std::shared_ptr &lineList) { - if (debug < skyMesh()->debug()) - debug = skyMesh()->debug(); - const IndexHash &indexHash = getIndexHash(lineList.get()); IndexHash::const_iterator iter = indexHash.constBegin(); @@ -97,11 +94,8 @@ m_listList.append(lineList); } -void LineListIndex::appendPoly(const std::shared_ptr &lineList, int debug) +void LineListIndex::appendPoly(const std::shared_ptr &lineList) { - if (debug < skyMesh()->debug()) - debug = skyMesh()->debug(); - const IndexHash &indexHash = skyMesh()->indexPoly(lineList->points()); IndexHash::const_iterator iter = indexHash.constBegin(); @@ -118,12 +112,12 @@ } } -void LineListIndex::appendBoth(const std::shared_ptr &lineList, int debug) +void LineListIndex::appendBoth(const std::shared_ptr &lineList) { QMutexLocker m1(&mutex); - appendLine(lineList, debug); - appendPoly(lineList, debug); + appendLine(lineList); + appendPoly(lineList); } void LineListIndex::reindexLines() Index: kstars/skycomponents/planetmoonscomponent.h =================================================================== --- kstars/skycomponents/planetmoonscomponent.h +++ kstars/skycomponents/planetmoonscomponent.h @@ -15,41 +15,36 @@ * * ***************************************************************************/ -#ifndef PLANETMOONSCOMPONENT_H -#define PLANETMOONSCOMPONENT_H +#pragma once #include "skycomponent.h" #include "skyobjects/ksplanetbase.h" -#include "skyobjects/planetmoons.h" +#include + +class KSNumbers; +class PlanetMoons; class SkyComposite; class SolarSystemSingleComponent; -class SkyMap; -class KSNumbers; -class JupiterMoons; -class SaturnMoons; -class SkyLabeler; /** - *@class PlanetMoonsComponent - *Represents the planetmoons on the sky map. - - *@author Vipul Kumar Singh - *@author Médéric boquien - *@version 0.1 - */ + * @class PlanetMoonsComponent + * Represents the planetmoons on the sky map. + * + * @author Vipul Kumar Singh + * @author Médéric boquien + * @version 0.1 + */ class PlanetMoonsComponent : public SkyComponent { public: /** - *@short Constructor - *@p parent pointer to the parent SkyComposite - */ - PlanetMoonsComponent(SkyComposite *parent, SolarSystemSingleComponent *pla, KSPlanetBase::Planets planet); + * @short Constructor + * @p parent pointer to the parent SkyComposite + */ + PlanetMoonsComponent(SkyComposite *parent, SolarSystemSingleComponent *pla, KSPlanetBase::Planets& planet); - /** - *@short Destructor - */ + /** @short Destructor */ ~PlanetMoonsComponent(); bool selected() Q_DECL_OVERRIDE; @@ -61,27 +56,26 @@ SkyObject *objectNearest(SkyPoint *p, double &maxrad) Q_DECL_OVERRIDE; - /** @return a pointer to a moon if its name matches the argument - * - * @p name the name to be matched - * @return a SkyObject pointer to the moon whose name matches - * the argument, or a nullptr pointer if no match was found. - */ + /** + * @return a pointer to a moon if its name matches the argument + * + * @p name the name to be matched + * @return a SkyObject pointer to the moon whose name matches + * the argument, or a nullptr pointer if no match was found. + */ SkyObject *findByName(const QString &name) Q_DECL_OVERRIDE; /** Return pointer to stored planet object. */ KSPlanetBase *getPlanet() const; /** Return pointer to stored moons object. */ - inline PlanetMoons *getMoons() const { return pmoons; } + inline PlanetMoons *getMoons() const { return pmoons.get(); } protected: void drawTrails(SkyPainter *skyp) Q_DECL_OVERRIDE; private: KSPlanetBase::Planets planet; - PlanetMoons *pmoons; - SolarSystemSingleComponent *m_Planet; + std::unique_ptr pmoons; + SolarSystemSingleComponent *m_Planet { nullptr }; }; - -#endif Index: kstars/skycomponents/planetmoonscomponent.cpp =================================================================== --- kstars/skycomponents/planetmoonscomponent.cpp +++ kstars/skycomponents/planetmoonscomponent.cpp @@ -17,32 +17,18 @@ #include "planetmoonscomponent.h" -#include -#include - -#include "skyobjects/jupitermoons.h" -#include "skyobjects/ksplanetbase.h" -#include "kstarsdata.h" -#ifdef KSTARS_LITE -#include "skymaplite.h" -#include "kstarslite/skyitems/planetsitem.h" -#else -#include "skymap.h" -#endif -#include "skyobjects/skypoint.h" -#include "skyobjects/trailobject.h" -#include "dms.h" #include "Options.h" -#include "solarsystemsinglecomponent.h" -#include "solarsystemcomposite.h" +#include "kstarsdata.h" #include "skylabeler.h" #include "skypainter.h" - +#include "solarsystemcomposite.h" +#include "solarsystemsinglecomponent.h" #include "projections/projector.h" +#include "skyobjects/jupitermoons.h" PlanetMoonsComponent::PlanetMoonsComponent(SkyComposite *p, SolarSystemSingleComponent *planetComponent, - KSPlanetBase::Planets _planet) - : SkyComponent(p), planet(_planet), pmoons(0), m_Planet(planetComponent) + KSPlanetBase::Planets& _planet) + : SkyComponent(p), planet(_planet), m_Planet(planetComponent) { /* if (planet == KSPlanetBase::JUPITER) @@ -51,19 +37,19 @@ pmoons = new SaturnMoons(); */ Q_ASSERT(planet == KSPlanetBase::JUPITER); - delete pmoons; +// delete pmoons; // pmoons = new JupiterMoons(); - int nmoons = pmoons->nMoons(); - for (int i = 0; i < nmoons; ++i) - { +// int nmoons = pmoons->nMoons(); + +// for (int i = 0; i < nmoons; ++i) +// { // objectNames(SkyObject::MOON).append( pmoons->name(i) ); // objectLists(SkyObject::MOON).append( QPair(pmoons->name(i),pmoons->moon(i)) ); - } +// } } PlanetMoonsComponent::~PlanetMoonsComponent() { - delete pmoons; } bool PlanetMoonsComponent::selected() Index: kstars/skycomponents/starblock.h =================================================================== --- kstars/skycomponents/starblock.h +++ kstars/skycomponents/starblock.h @@ -26,8 +26,8 @@ class StarObject; class StarBlockList; class PointSourceNode; -struct starData; -struct deepStarData; +struct StarData; +struct DeepStarData; #ifdef KSTARS_LITE #include "starobject.h" @@ -81,8 +81,8 @@ *@param data data to initialize star with. *@return pointer to star initialized with data. nullptr if block is full. */ - StarBlockEntry *addStar(const starData &data); - StarBlockEntry *addStar(const deepStarData &data); + StarBlockEntry *addStar(const StarData &data); + StarBlockEntry *addStar(const DeepStarData &data); /** *@short Returns true if the StarBlock is full Index: kstars/skycomponents/starblock.cpp =================================================================== --- kstars/skycomponents/starblock.cpp +++ kstars/skycomponents/starblock.cpp @@ -67,7 +67,7 @@ } #ifdef KSTARS_LITE -StarNode *StarBlock::addStar(const starData &data) +StarNode *StarBlock::addStar(const StarData &data) { if (isFull()) return 0; @@ -82,7 +82,7 @@ return &node; } -StarNode *StarBlock::addStar(const deepStarData &data) +StarNode *StarBlock::addStar(const DeepStarData &data) { if (isFull()) return 0; @@ -97,7 +97,7 @@ return &node; } #else -StarObject *StarBlock::addStar(const starData &data) +StarObject *StarBlock::addStar(const StarData &data) { if (isFull()) return 0; @@ -111,7 +111,7 @@ return ☆ } -StarObject *StarBlock::addStar(const deepStarData &data) +StarObject *StarBlock::addStar(const DeepStarData &data) { if (isFull()) return 0; Index: kstars/skycomponents/starblocklist.cpp =================================================================== --- kstars/skycomponents/starblocklist.cpp +++ kstars/skycomponents/starblocklist.cpp @@ -83,8 +83,8 @@ // TODO: Remove staticity of BinFileHelper BinFileHelper *dSReader; StarBlockFactory *SBFactory; - starData stardata; - deepStarData deepstardata; + StarData stardata; + DeepStarData deepstardata; FILE *dataFile; dSReader = parent->getStarReader(); @@ -145,18 +145,18 @@ // TODO: Make this more general if (dSReader->guessRecordSize() == 32) { - ret = fread(&stardata, sizeof(starData), 1, dataFile); + ret = fread(&stardata, sizeof(StarData), 1, dataFile); if (dSReader->getByteSwap()) DeepStarComponent::byteSwap(&stardata); - readOffset += sizeof(starData); + readOffset += sizeof(StarData); blocks[nBlocks - 1]->addStar(stardata); } else { - ret = fread(&deepstardata, sizeof(deepStarData), 1, dataFile); + ret = fread(&deepstardata, sizeof(DeepStarData), 1, dataFile); if (dSReader->getByteSwap()) DeepStarComponent::byteSwap(&deepstardata); - readOffset += sizeof(deepStarData); + readOffset += sizeof(DeepStarData); blocks[nBlocks - 1]->addStar(deepstardata); } Index: kstars/skycomponents/starcomponent.h =================================================================== --- kstars/skycomponents/starcomponent.h +++ kstars/skycomponents/starcomponent.h @@ -35,6 +35,7 @@ #include "ksnumbers.h" #include "listcomponent.h" #include "skylabel.h" +#include "stardata.h" #include "skyobjects/starobject.h" #include @@ -136,9 +137,9 @@ void starsInAperture(QList &list, const SkyPoint ¢er, float radius, float maglim = -29); // TODO: Make byteSwap a template method and put it in byteorder.h - // It should ideally handle 32-bit, 16-bit fields and starData and - // deepStarData fields - static void byteSwap(starData *stardata); + // It should ideally handle 32-bit, 16-bit fields and StarData and + // DeepStarData fields + static void byteSwap(StarData *stardata); private: /** @@ -209,7 +210,7 @@ char longName[32]; } starName; - starData stardata; + StarData stardata; starName starname; static StarComponent *pinstance; Index: kstars/skycomponents/starcomponent.cpp =================================================================== --- kstars/skycomponents/starcomponent.cpp +++ kstars/skycomponents/starcomponent.cpp @@ -471,9 +471,9 @@ Trixel trixel = i; // = ( ( i >= 256 ) ? ( i - 256 ) : ( i + 256 ) ); for (unsigned long j = 0; j < (unsigned long)dataReader.getRecordCount(i); ++j) { - if (!fread(&stardata, sizeof(starData), 1, dataFile)) + if (!fread(&stardata, sizeof(StarData), 1, dataFile)) { - qDebug() << "FILE FORMAT ERROR: Could not read starData structure for star #" << j << " under trixel #" + qDebug() << "FILE FORMAT ERROR: Could not read StarData structure for star #" << j << " under trixel #" << trixel << endl; } @@ -639,7 +639,7 @@ dataFile = m_DeepStarComponents.at(1)->getStarReader()->getFileHandle(); //KDE_fseek( dataFile, offset, SEEK_SET ); QT_FSEEK(dataFile, offset, SEEK_SET); - ret = fread(&stardata, sizeof(starData), 1, dataFile); + ret = fread(&stardata, sizeof(StarData), 1, dataFile); if (m_DeepStarComponents.at(1)->getStarReader()->getByteSwap()) { byteSwap(&stardata); @@ -746,7 +746,7 @@ } } -void StarComponent::byteSwap(starData *stardata) +void StarComponent::byteSwap(StarData *stardata) { stardata->RA = bswap_32(stardata->RA); stardata->Dec = bswap_32(stardata->Dec); Index: kstars/skycomponents/stars.dox =================================================================== --- kstars/skycomponents/stars.dox +++ kstars/skycomponents/stars.dox @@ -9,8 +9,8 @@ + StarBlockList - A list of StarBlocks; machinery to load data dynamically from catalog files + StarBlockFactory - Maintains a cache of recently used StarBlocks + BinFileHelper - A generic helper class used to deal with binary data files (See ../binfilehelper.h) - + starData - holds 32 bits of data describing a star (See ../skyobjects/stardata.h) - + deepStarData - holds 16 bits of data describing a (faint) star (See ../skyobjects/deepstardata.h) + + StarData - holds 32 bits of data describing a star (See ../skyobjects/stardata.h) + + DeepStarData - holds 16 bits of data describing a (faint) star (See ../skyobjects/deepstardata.h) \section Categorization Categorization of Stars Stars could be either named or unnamed. Named stars and unnamed stars @@ -31,9 +31,9 @@ A third categorization is "shallow" and "deep" stars. Shallow stars are the brighter stars, which have enough catalog data to require a - 32-byte data structure (starData) to hold them. Deep stars are the + 32-byte data structure (StarData) to hold them. Deep stars are the fainter ones, data for which can be fit into a 16-byte structure - (deepStarData). All named stars and all static stars are shallow. All + (DeepStarData). All named stars and all static stars are shallow. All deep stars are dynamic and unnamed. StarComponent manages only shallow stars. DeepStarComponent manages both shallow and deep stars. @@ -91,7 +91,7 @@ (32 bytes) and a Bayer designation (8 bytes). Each record in namedstars.dat is 32 bytes long, and holds a direct - memory dump of struct starData, made on a little-endian system. (On + memory dump of struct StarData, made on a little-endian system. (On big endian systems, byte order inversion is done at runtime) Named stars are read off the disk at initialization time by Index: kstars/skymap.h =================================================================== --- kstars/skymap.h +++ kstars/skymap.h @@ -15,59 +15,50 @@ * * ***************************************************************************/ -#ifndef SKYMAP_H_ -#define SKYMAP_H_ +#pragma once -#define USEGL - -#include -#include -#include -#include - -#include "skyobjects/skypoint.h" -#include "skyobjects/skyline.h" +#include "config-kstars.h" #include "skymapdrawabstract.h" -#include "skymapqdraw.h" #include "printing/legend.h" +#include "skyobjects/skypoint.h" +#include "skyobjects/skyline.h" -#include +#include +#include class QPainter; class QPaintDevice; -class QPixmap; class dms; -class KStarsData; -class KSPopupMenu; -class SkyObject; -class InfoBoxWidget; class InfoBoxes; +class InfoBoxWidget; +class KSPopupMenu; +class KStarsData; class Projector; - -class QGraphicsScene; +class SkyObject; #ifdef HAVE_OPENGL class SkyMapGLDraw; class SkyMapQDraw; #endif -/** @class SkyMap - * - *This is the canvas on which the sky is painted. It's the main widget for KStars. - *Contains SkyPoint members for the map's Focus (current central position), Destination - *(requested central position), FocusPoint (next queued position to be focused), - *MousePoint (position of mouse cursor), and ClickedPoint (position of last mouse click). - *Also contains the InfoBoxes for on-screen data display. - * - *SkyMap handles most user interaction events (both mouse and keyboard). - * - *@short Canvas widget for displaying the sky bitmap; also handles user interaction events. - *@author Jason Harris - *@version 1.0 - */ - +/** + * @class SkyMap + * + * This is the canvas on which the sky is painted. It's the main widget for KStars. + * Contains SkyPoint members for the map's Focus (current central position), Destination + * (requested central position), FocusPoint (next queued position to be focused), + * MousePoint (position of mouse cursor), and ClickedPoint (position of last mouse click). + * Also contains the InfoBoxes for on-screen data display. + * + * SkyMap handles most user interaction events (both mouse and keyboard). + * + * @short Canvas widget for displaying the sky bitmap; also handles user interaction events. + * + * @author Jason Harris + * @version 1.0 + */ class SkyMap : public QGraphicsView { Q_OBJECT @@ -80,7 +71,7 @@ *Constructor. Read stored settings from KConfig object (focus position, *zoom factor, sky color, etc.). Run initPopupMenus(). */ - explicit SkyMap(); + SkyMap(); public: static SkyMap *Create(); @@ -613,41 +604,42 @@ #ifdef HAVE_XPLANET /** - * @short Strart xplanet. - * @param outputFile Output file path. - */ + * @short Strart xplanet. + * @param outputFile Output file path. + */ void startXplanet(const QString &outputFile = ""); #endif - bool mouseButtonDown, midMouseButtonDown; - // true if mouseMoveEvent; needed by setMouseMoveCursor - bool mouseMoveCursor; - bool slewing, clockSlewing; + bool mouseButtonDown { false }; + bool midMouseButtonDown { false }; + /// True if mouseMoveEvent; needed by setMouseMoveCursor + bool mouseMoveCursor { false }; + bool slewing { false }; + bool clockSlewing { false }; //if false only old pixmap will repainted with bitBlt(), this // saves a lot of cpu usage - bool computeSkymap; + bool computeSkymap { false }; // True if we are either looking for angular distance or star hopping directions - bool rulerMode; + bool rulerMode { false }; // True only if we are looking for star hopping directions. If // false while rulerMode is true, it means we are measuring angular // distance. FIXME: Find a better way to do this - bool starHopDefineMode; + bool starHopDefineMode { false }; double y0; double m_Scale; - KStarsData *data; - KSPopupMenu *pmenu; + KStarsData *data { nullptr }; + KSPopupMenu *pmenu { nullptr }; - /** @short Coordinates of point under cursor. It's update in - * function mouseMoveEvent - */ + /// Coordinates of point under cursor. It's update in function mouseMoveEvent SkyPoint m_MousePoint; SkyPoint Focus, ClickedPoint, FocusPoint, Destination; - SkyObject *ClickedObject, *FocusObject; + SkyObject *ClickedObject { nullptr }; + SkyObject *FocusObject { nullptr }; - Projector *m_proj; + Projector *m_proj { nullptr }; SkyLine AngularRuler; //The line for measuring angles in the map QRect ZoomRect; //The manual-focus circle. @@ -658,30 +650,27 @@ QTimer m_HoverTimer; // InfoBoxes. Used in desctructor to save state - InfoBoxWidget *m_timeBox; - InfoBoxWidget *m_geoBox; - InfoBoxWidget *m_objBox; - InfoBoxes *m_iboxes; + InfoBoxWidget *m_timeBox { nullptr }; + InfoBoxWidget *m_geoBox { nullptr }; + InfoBoxWidget *m_objBox { nullptr }; + InfoBoxes *m_iboxes { nullptr }; // legend - bool m_previewLegend; + bool m_previewLegend { false }; Legend m_legend; - bool m_objPointingMode; - bool m_fovCaptureMode; + bool m_objPointingMode { false }; + bool m_fovCaptureMode { false }; - QWidget *m_SkyMapDraw; // Can be dynamic_cast<> to SkyMapDrawAbstract + QWidget *m_SkyMapDraw { nullptr }; // Can be dynamic_cast<> to SkyMapDrawAbstract // NOTE: These are pointers to the individual widgets #ifdef HAVE_OPENGL - SkyMapQDraw *m_SkyMapQDraw; - SkyMapGLDraw *m_SkyMapGLDraw; + SkyMapQDraw *m_SkyMapQDraw { nullptr }; + SkyMapGLDraw *m_SkyMapGLDraw { nullptr }; #endif - QGraphicsScene *m_Scene; - static SkyMap *pinstance; - const SkyPoint *m_rulerStartPoint; // Good to keep the original ruler start-point for purposes of dynamic_cast + /// Good to keep the original ruler start-point for purposes of dynamic_cast + const SkyPoint *m_rulerStartPoint { nullptr }; }; - -#endif Index: kstars/skymap.cpp =================================================================== --- kstars/skymap.cpp +++ kstars/skymap.cpp @@ -18,74 +18,51 @@ #ifdef _WIN32 #include #endif -#include "skymap.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include +#include "skymap.h" -#include "Options.h" -#include "kstars.h" -#include "kspaths.h" -#include "kstarsdata.h" -#include "ksutils.h" -#include "ksdssdownloader.h" +#include "fov.h" #include "imageviewer.h" -#include "dialogs/detaildialog.h" +#include "ksdssdownloader.h" +#include "kspaths.h" #include "kspopupmenu.h" +#include "ksutils.h" +#include "Options.h" +#ifdef HAVE_OPENGL +#include "skymapgldraw.h" +#endif +#include "skymapqdraw.h" +#include "starhopperdialog.h" +#include "texturemanager.h" #include "printing/printingwizard.h" -#include "simclock.h" -#include "skyobjects/skyobject.h" +#include "skycomponents/flagcomponent.h" #include "skyobjects/deepskyobject.h" #include "skyobjects/ksplanetbase.h" -#include "skycomponents/skymapcomposite.h" -#include "skycomponents/flagcomponent.h" +#include "tools/flagmanager.h" #include "widgets/infoboxwidget.h" -#include "projections/projector.h" +#include "projections/azimuthalequidistantprojector.h" +#include "projections/equirectangularprojector.h" #include "projections/lambertprojector.h" #include "projections/gnomonicprojector.h" -#include "projections/stereographicprojector.h" #include "projections/orthographicprojector.h" -#include "projections/azimuthalequidistantprojector.h" -#include "projections/equirectangularprojector.h" -#include "fov.h" - -#include "tools/flagmanager.h" - -#include "texturemanager.h" - -#include "skymapqdraw.h" +#include "projections/stereographicprojector.h" -#ifdef HAVE_OPENGL -#include "skymapgldraw.h" -#endif +#include +#include +#include -#include "starhopperdialog.h" +#include +#include +#include +#include #ifdef HAVE_XPLANET #include #include #endif +#include + namespace { // Draw bitmap for zoom cursor. Width is size of pen to draw with. Index: kstars/skyobjects/deepstardata.h =================================================================== --- kstars/skyobjects/deepstardata.h +++ kstars/skyobjects/deepstardata.h @@ -15,24 +15,22 @@ * * ***************************************************************************/ -#ifndef DEEPSTARDATA_H -#define DEEPSTARDATA_H +#pragma once #include /** - *@short A 16-byte structure that holds star data for really faint stars. - *@author Akarsh Simha - *@version 1.0 + * @short A 16-byte structure that holds star data for really faint stars. + * + * @author Akarsh Simha + * @version 1.0 */ -struct deepStarData +struct DeepStarData { - qint32 RA; /**< Raw signed 32-bit RA value. Needs to be multiplied by the scale (1e6) */ - qint32 Dec; /**< Raw signed 32-bit DE value. Needs to be multiplied by the scale (1e6) */ - qint16 dRA; - qint16 dDec; - qint16 B; - qint16 V; + qint32 RA { 0 }; /**< Raw signed 32-bit RA value. Needs to be multiplied by the scale (1e6) */ + qint32 Dec { 0 }; /**< Raw signed 32-bit DE value. Needs to be multiplied by the scale (1e6) */ + qint16 dRA { 0 }; + qint16 dDec { 0 }; + qint16 B { 0 }; + qint16 V { 0 }; }; - -#endif Index: kstars/skyobjects/satellite.h =================================================================== --- kstars/skyobjects/satellite.h +++ kstars/skyobjects/satellite.h @@ -15,159 +15,161 @@ * * ***************************************************************************/ -#ifndef SATELLITE_H -#define SATELLITE_H - -#include +#pragma once #include "skyobject.h" -#include "skypoint.h" + +#include class KSPopupMenu; /** - *@class Satellite - *Represents an artificial satellites. - *@author Jérôme SONRIER - *@version 0.1 - */ + * @class Satellite + * Represents an artificial satellites. + * + * @author Jérôme SONRIER + * @version 0.1 + */ class Satellite : public SkyObject { public: - /** - *@short Constructor - */ - Satellite(QString name, QString line1, QString line2); + /** @short Constructor */ + Satellite(const QString &name, const QString &line1, const QString &line2); /** - *@return a clone of this object - *@note See SkyObject::clone() - */ + * @return a clone of this object + * @note See SkyObject::clone() + */ Satellite *clone() const Q_DECL_OVERRIDE; - /** - *@short Destructor - */ + /** @short Destructor */ ~Satellite(); - /** - *@short Update satellite position - */ + /** @short Update satellite position */ int updatePos(); /** - *@return True if the satellite is visible (above horizon, in the sunlight and sun at least 12° under horizon) - */ + * @return True if the satellite is visible (above horizon, in the sunlight and sun at least 12° under horizon) + */ bool isVisible(); - /** - *@return True if the satellite is selected - */ + /** @return True if the satellite is selected */ bool selected(); - /** - *@short Select or not the satellite - */ + /** @short Select or not the satellite */ void setSelected(bool selected); - /** - *@return Satellite velocity in km/s - */ + /** @return Satellite velocity in km/s */ double velocity(); - /** - *@return Satellite altitude in km - */ + /** @return Satellite altitude in km */ double altitude(); - /** - *@return Satellite range from observer in km - */ + /** @return Satellite range from observer in km */ double range(); - /** - *@return Satellite international designator - */ + /** @return Satellite international designator */ QString id(); /** - * @brief sgp4ErrorString Get error string associated with sgp4 calculation failure - * @param code error code as returned from sgp4() function - * @return error string - */ + * @brief sgp4ErrorString Get error string associated with sgp4 calculation failure + * @param code error code as returned from sgp4() function + * @return error string + */ QString sgp4ErrorString(int code); void initPopupMenu(KSPopupMenu *pmenu) Q_DECL_OVERRIDE; private: - /** - *@short Compute non time dependant parameters - */ + /** @short Compute non time dependant parameters */ void init(); - /** - *@short Compute satellite position - */ + /** @short Compute satellite position */ int sgp4(double tsince); - /** - *@return Arcsine of the argument - */ + /** @return Arcsine of the argument */ double arcSin(double arg); /** - *Provides the difference between UT (approximately the same as UTC) - *and ET (now referred to as TDT). - *This function is based on a least squares fit of data from 1950 - *to 1991 and will need to be updated periodically. - */ + * Provides the difference between UT (approximately the same as UTC) + * and ET (now referred to as TDT). + * This function is based on a least squares fit of data from 1950 + * to 1991 and will need to be updated periodically. + */ double deltaET(double year); - /** - *@return arg1 mod arg2 - */ + /** @return arg1 mod arg2 */ double Modulus(double arg1, double arg2); // TLE - int m_number; // Satellite Number - QChar m_class; // Security Classification - QString m_id; // International Designator - double m_epoch_year; // Epoch Year - double m_epoch; // Epoch (Day of the year and fractional portion of the day) - double m_first_deriv; // First Time Derivative of the Mean Motion - double m_second_deriv; // Second Time Derivative of Mean Motion - double m_bstar; // BSTAR drag term (decimal point assumed) - int m_ephem_type; // Ephemeris type - int m_elem_number; // Element number - double m_inclination; // Inclination [Radians] - double m_ra; // Right Ascension of the Ascending Node [Radians] - double m_eccentricity; // Eccentricity - double m_arg_perigee; // Argument of Perigee [Radians] - double m_mean_anomaly; // Mean Anomaly [Radians] - double m_mean_motion; // Mean Motion [Radians per minutes] - int m_nb_revolution; // Revolution number at epoch [Revs] - double m_tle_jd; // TLE epoch converted to julian date + /// Satellite Number + int m_number { 0 }; + /// Security Classification + QChar m_class; + /// International Designator + QString m_id; + /// Epoch Year + double m_epoch_year { 0 }; + /// Epoch (Day of the year and fractional portion of the day) + double m_epoch { 0 }; + /// First Time Derivative of the Mean Motion + double m_first_deriv { 0 }; + /// Second Time Derivative of Mean Motion + double m_second_deriv { 0 }; + /// BSTAR drag term (decimal point assumed) + double m_bstar { 0 }; + /// Ephemeris type + int m_ephem_type { 0 }; + /// Element number + int m_elem_number { 0 }; + /// Inclination [Radians] + double m_inclination { 0 }; + /// Right Ascension of the Ascending Node [Radians] + double m_ra { 0 }; + /// Eccentricity + double m_eccentricity { 0 }; + /// Argument of Perigee [Radians] + double m_arg_perigee { 0 }; + /// Mean Anomaly [Radians] + double m_mean_anomaly { 0 }; + /// Mean Motion [Radians per minutes] + double m_mean_motion { 0 }; + /// Revolution number at epoch [Revs] + int m_nb_revolution { 0 }; + /// TLE epoch converted to julian date + double m_tle_jd { 0 }; // Satellite - bool m_is_visible; // True if the satellite is visible - bool m_is_eclipsed; // True if the satellite is in the shadow of the earth - bool m_is_selected; // True if the satellite is selected - double m_velocity; // Satellite velocity in km/s - double m_altitude; // Satellite altitude in km - double m_range; // Satellite range from observer in km + /// True if the satellite is visible + bool m_is_visible { false }; + /// True if the satellite is in the shadow of the earth + bool m_is_eclipsed { false }; + /// True if the satellite is selected + bool m_is_selected { false }; + /// Satellite velocity in km/s + double m_velocity { 0 }; + /// Satellite altitude in km + double m_altitude { 0 }; + /// Satellite range from observer in km + double m_range { 0 }; // Near Earth - bool isimp; - double aycof, con41, cc1, cc4, cc5, d2, d3, d4, delmo, eta, argpdot, omgcof, sinmao, t, t2cof, t3cof, t4cof, t5cof, - x1mth2, x7thm1, mdot, nodedot, xlcof, xmcof, nodecf; + bool isimp { false }; + double aycof { 0 }, con41 { 0 }, cc1 { 0 }, cc4 { 0 }, cc5 { 0 }, d2 { 0 }, d3 { 0 }, d4 { 0 }; + double delmo { 0 }, eta { 0 }, argpdot { 0 }, omgcof { 0 }, sinmao { 0 }, t { 0 }, t2cof { 0 }; + double t3cof { 0 }, t4cof { 0 }, t5cof { 0 }, x1mth2 { 0 }, x7thm1 { 0 }, mdot { 0 }; + double nodedot { 0 }, xlcof { 0 }, xmcof { 0 }, nodecf { 0 }; // Deep Space - int irez; - double d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433, dedt, del1, del2, del3, didt, dmdt, - dnodt, domdt, e3, ee2, peo, pgho, pho, pinco, plo, se2, se3, sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, - sl4, gsto, xfact, xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4, xlamo, zmol, zmos, atime, xli, xni; + int irez { 0 }; + double d2201 { 0 }, d2211 { 0 }, d3210 { 0 }, d3222 { 0 }, d4410 { 0 }, d4422 { 0 }, d5220 { 0 }; + double d5232 { 0 }, d5421 { 0 }, d5433 { 0 }, dedt { 0 }, del1 { 0 }, del2 { 0 }, del3 { 0 }; + double didt { 0 }, dmdt { 0 }, dnodt { 0 }, domdt { 0 }, e3 { 0 }, ee2 { 0 }, peo { 0 }; + double pgho { 0 }, pho { 0 }, pinco { 0 }, plo { 0 }, se2 { 0 }, se3 { 0 }, sgh2 { 0 }; + double sgh3 { 0 }, sgh4 { 0 }, sh2 { 0 }, sh3 { 0 }, si2 { 0 }, si3 { 0 }, sl2 { 0 }, sl3 { 0 }; + double sl4 { 0 }, gsto { 0 }, xfact { 0 }, xgh2 { 0 }, xgh3 { 0 }, xgh4 { 0 }, xh2 { 0 }; + double xh3 { 0 }, xi2 { 0 }, xi3 { 0 }, xl2 { 0 }, xl3 { 0 }, xl4 { 0 }, xlamo { 0 }, zmol { 0 }; + double zmos { 0 }, atime { 0 }, xli { 0 }, xni { 0 }; char method; }; - -#endif Index: kstars/skyobjects/satellite.cpp =================================================================== --- kstars/skyobjects/satellite.cpp +++ kstars/skyobjects/satellite.cpp @@ -56,7 +56,7 @@ #define F 3.35281066474748e-3 // Flattening factor #define MFACTOR 7.292115e-5 -Satellite::Satellite(const QString name, const QString line1, const QString line2) +Satellite::Satellite(const QString &name, const QString &line1, const QString &line2) { //m_name = name; m_number = line1.midRef(2, 5).toInt(); @@ -116,11 +116,12 @@ void Satellite::init() { double ao, cosio, sinio, cosio2, omeosq, posq, rp, rteosq, eccsq, con42, cnodm, snodm, cosim, sinim, cosomm, sinomm, - cc1sq, cc2, cc3, coef, coef1, cosio4, day, dndt, em, emsq, eeta, etasq, gam, inclm, nm, perige, pinvsq, psisq, + cc1sq, cc2, cc3, coef, coef1, cosio4, day, em, emsq, eeta, etasq, gam, inclm, nm, perige, pinvsq, psisq, qzms24, rtemsq, s1, s2, s3, s4, s5, s6, s7, sfour, ss1(0), ss2(0), ss3(0), ss4(0), ss5(0), ss6(0), ss7(0), sz1(0), sz2(0), sz3(0), sz11(0), sz12(0), sz13(0), sz21(0), sz22(0), sz23(0), sz31(0), sz32(0), sz33(0), tc, temp, temp1, temp2, temp3, tsi, xpidot, xhdot1, z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33, ak, d1, del, adel, po, ds70, ts70, tfrac, c1, thgr70, fk5r, c1p2p; +// double dndt; // Init near earth variables isimp = false; @@ -498,36 +499,39 @@ xh3 = -2.0 * s2 * (z23 - z21); // Apply deep space long period periodic contributions to the mean elements - double f2, f3, ses, sghl, sghs, shll, shs, sinzf, sis, sls, zf, zm; +// double f2, f3, sinzf, zf, zm; + double ses, sghl, sghs, shll, shs, sis, sls; // Define some constants const double zns = 1.19459e-5; const double znl = 1.5835218e-4; // Calculate time varying periodics - zm = zmos; - zf = zm + 2.0 * zes * sin(zm); - sinzf = sin(zf); - f2 = 0.5 * sinzf * sinzf - 0.25; - f3 = -0.5 * sinzf * cos(zf); - ses = se2 * f2 + se3 * f3; - sis = si2 * f2 + si3 * f3; - sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf; - sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf; - shs = sh2 * f2 + sh3 * f3; - zm = zmol; - - zf = zm + 2.0 * zel * sin(zm); - sinzf = sin(zf); - f2 = 0.5 * sinzf * sinzf - 0.25; - f3 = -0.5 * sinzf * cos(zf); - sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf; - shll = xh2 * f2 + xh3 * f3; + // These results are never used, should we remove them? +// zm = zmos; +// zf = zm + 2.0 * zes * sin(zm); +// sinzf = sin(zf); +// f2 = 0.5 * sinzf * sinzf - 0.25; +// f3 = -0.5 * sinzf * cos(zf); +// ses = se2 * f2 + se3 * f3; +// sis = si2 * f2 + si3 * f3; +// sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf; +// sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf; +// shs = sh2 * f2 + sh3 * f3; +// zm = zmol; + +// zf = zm + 2.0 * zel * sin(zm); +// sinzf = sin(zf); +// f2 = 0.5 * sinzf * sinzf - 0.25; +// f3 = -0.5 * sinzf * cos(zf); +// sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf; +// shll = xh2 * f2 + xh3 * f3; // Deep space contributions to mean motion dot due to geopotential resonance with half day and one day orbits double ainv2, aonv = 0.0, cosisq, eoc, f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543, g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533, sgs, sini2, - temp, temp1, theta, xno2, emo, emsqo; + temp, temp1, theta, xno2, emsqo; +// double emo; // Define some constant const double q22 = 1.7891679e-6; @@ -576,7 +580,8 @@ } // Calculate deep space resonance effects - dndt = 0.0; + // Value never used +// dndt = 0.0; theta = fmod(gsto + tc * rptim, TWOPI); // Initialize the resonance terms @@ -588,7 +593,8 @@ if (irez == 2) { cosisq = cosim * cosim; - emo = em; + // Value never used +// emo = em; em = m_eccentricity; emsqo = emsq; emsq = eccsq; @@ -666,7 +672,8 @@ d5433 = temp * f543 * g533; xlamo = fmod(m_mean_anomaly + m_ra + m_ra - theta - theta, TWOPI); xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - m_mean_motion; - em = emo; + // Value never used +// em = emo; emsq = emsqo; } @@ -690,7 +697,8 @@ xli = xlamo; xni = m_mean_motion; atime = 0.0; - nm = m_mean_motion + dndt; + // Value never used +// nm = m_mean_motion + dndt; } } @@ -720,13 +728,14 @@ KStarsData *data = KStarsData::Instance(); int ktr; - double am, axnl, aynl, betal, cosim, cnod, cos2u, coseo1, cosi, cosip, cosisq, cossu, cosu, delm, delomg, em, emsq, + double am, axnl, aynl, betal, cosim, cnod, cos2u, coseo1 = 0, cosi, cosip, cosisq, cossu, cosu, delm, delomg, em, ecose, el2, eo1, ep, esine, argpm, argpp, argpdf, pl, - mrt = 0.0, mvt, rdotl, rl, rvdot, rvdotl, sinim, dndt, sin2u, sineo1, sini, sinip, sinsu, sinu, snod, su, t2, + mrt = 0.0, mvt, rdotl, rl, rvdot, rvdotl, sinim, dndt, sin2u, sineo1 = 0, sini, sinip, sinsu, sinu, snod, su, t2, t3, t4, tem5, temp, temp1, temp2, tempa, tempe, templ, u, ux, uy, uz, vx, vy, vz, inclm, mm, nm, nodem, xinc, xincp, xl, xlm, mp, xmdf, xmx, xmy, nodedf, xnode, nodep, tc, sat_posx, sat_posy, sat_posz, sat_posw, sat_velx, sat_vely, sat_velz, sinlat, obs_posx, obs_posy, obs_posz, obs_posw, /*obs_velx, obs_vely, obs_velz,*/ coslat, thetageo, sintheta, costheta, c, sq, achcp, vkmpersec; +// double emsq; const double temp4 = 1.5e-12; @@ -785,7 +794,8 @@ const double step2 = step * step / 2; // Calculate deep space resonance effects - dndt = 0.0; + // Value never used +// dndt = 0.0; theta = fmod(gsto + tc * rptim, TWOPI); em = em + dedt * tsince; @@ -899,8 +909,10 @@ mm = mm + m_mean_motion * templ; xlm = mm + argpm + nodem; - emsq = em * em; - temp = 1.0 - emsq; + // Value never used +// emsq = em * em; + // Value never used +// temp = 1.0 - emsq; nodem = fmod(nodem, TWOPI); argpm = fmod(argpm, TWOPI); Index: kstars/skyobjects/skypoint.cpp =================================================================== --- kstars/skyobjects/skypoint.cpp +++ kstars/skyobjects/skypoint.cpp @@ -316,7 +316,6 @@ // double dir0 = (dist >= 0 ) ? bearing : bearing + dms::PI; // in radian double dir0 = bearing + std::signbit(dist) * dms::PI; // might be faster? - dist = fabs(dist); // in radian double sinDst = sin(dst), cosDst = cos(dst); lat1.setUsing_asin(dec().sin() * cosDst + dec().cos() * sinDst * cos(dir0)); Index: kstars/skyobjects/stardata.h =================================================================== --- kstars/skyobjects/stardata.h +++ kstars/skyobjects/stardata.h @@ -15,29 +15,27 @@ * * ***************************************************************************/ -#ifndef STARDATA_H -#define STARDATA_H +#pragma once #include /** - *@short A 32-byte Structure that holds star data - *@author Akarsh Simha - *@version 1.0 + * @short A 32-byte Structure that holds star data + * + * @author Akarsh Simha + * @version 1.0 */ -struct starData +struct StarData { - qint32 RA; /**< Raw signed 32-bit RA value. Needs to be multiplied by the scale (1e6) */ - qint32 Dec; /**< Raw signed 32-bit DE value. Needs to be multiplied by the scale (1e6) */ - qint32 dRA; - qint32 dDec; - qint32 parallax; - qint32 HD; /**< unsigned 32-bit Henry Draper Index. No scaling is required. */ - qint16 mag; /**< signed 16-bit raw magnitude. Needs to be divided by the scale (1e2) */ - qint16 bv_index; + qint32 RA { 0 }; /**< Raw signed 32-bit RA value. Needs to be multiplied by the scale (1e6) */ + qint32 Dec { 0 }; /**< Raw signed 32-bit DE value. Needs to be multiplied by the scale (1e6) */ + qint32 dRA { 0 }; + qint32 dDec { 0 }; + qint32 parallax { 0 }; + qint32 HD { 0 }; /**< unsigned 32-bit Henry Draper Index. No scaling is required. */ + qint16 mag { 0 }; /**< signed 16-bit raw magnitude. Needs to be divided by the scale (1e2) */ + qint16 bv_index { 0 }; char spec_type[2]; - char flags; - char unused; + char flags { 0 }; + char unused { 0 }; }; - -#endif Index: kstars/skyobjects/starobject.h =================================================================== --- kstars/skyobjects/starobject.h +++ kstars/skyobjects/starobject.h @@ -17,14 +17,16 @@ #pragma once -#include "deepstardata.h" +//#define PROFILE_UPDATECOORDS + #include "skyobject.h" -#include "stardata.h" -//#define PROFILE_UPDATECOORDS +#include +struct DeepStarData; class KSNumbers; class KSPopupMenu; +struct StarData; /** @class StarObject *This is a subclass of SkyObject. It adds the Spectral type, and flags @@ -103,7 +105,7 @@ *@param stardata Pointer to starData object containing required data (except name and gname) *@return Nothing */ - void init(const starData *stardata); + void init(const StarData *stardata); /** *@short Initializes a StarObject to given data @@ -111,7 +113,7 @@ *@param stardata Pointer to deepStarData object containing the available data *@return Nothing */ - void init(const deepStarData *stardata); + void init(const DeepStarData *stardata); /** *@short Sets the name, genetive name, and long name @@ -119,7 +121,7 @@ *@param name Common name *@param name2 Genetive name */ - void setNames(QString name, QString name2); + void setNames(const QString &name, const QString &name2); /** @return true if the star has a name ("star" doesn't count) */ inline bool hasName() const { return (!Name.isEmpty() && Name != starString); } @@ -273,6 +275,8 @@ */ inline float getBVIndex() const { return ((B < 30.0 && V < 30.0) ? B - V : 99.9); } + void initPopupMenu(KSPopupMenu *pmenu) Q_DECL_OVERRIDE; + quint64 updateID; quint64 updateNumID; @@ -281,8 +285,6 @@ static unsigned int starsUpdated; #endif - void initPopupMenu(KSPopupMenu *pmenu) Q_DECL_OVERRIDE; - protected: // DEBUG EDIT. For testing proper motion, uncomment this, and related blocks // See starobject.cpp for further info. @@ -291,10 +293,15 @@ // END DEBUG private: - double PM_RA, PM_Dec, Parallax; //, VRange, VPeriod; - bool Multiplicity, Variability; + double PM_RA { 0 }; + double PM_Dec { 0 }; + double Parallax { 0 }; + bool Multiplicity { false }; + bool Variability { false }; char SpType[2]; - int HD; - float B, - V; // B and V magnitudes, separately. NOTE 1) This is kept separate from mag for a reason. See init( const deepStarData *); 2) This applies only to deep stars at the moment + int HD { 0 }; + // B and V magnitudes, separately. NOTE 1) This is kept separate from mag for a reason. + // See init( const DeepStarData *); 2) This applies only to deep stars at the moment + float B { 0 }; + float V { 0 }; }; Index: kstars/skyobjects/starobject.cpp =================================================================== --- kstars/skyobjects/starobject.cpp +++ kstars/skyobjects/starobject.cpp @@ -17,24 +17,18 @@ #include "starobject.h" -#include - -#include -#include -#include -#include -#include -#include - +#include "deepstardata.h" +#include "ksnumbers.h" #ifndef KSTARS_LITE #include "kspopupmenu.h" #endif -#include "ksnumbers.h" #include "kstarsdata.h" -#include "kstarsdatetime.h" +#include "ksutils.h" #include "Options.h" #include "skymap.h" -#include "ksutils.h" +#include "stardata.h" + +#include #ifdef PROFILE_UPDATECOORDS double StarObject::updateCoordsCpuTime = 0.; @@ -144,7 +138,7 @@ return new StarObject(*this); } -void StarObject::init(const starData *stardata) +void StarObject::init(const StarData *stardata) { double ra, dec; ra = stardata->RA / 1000000.0; @@ -193,7 +187,7 @@ lastPrecessJD = J2000; } -void StarObject::init(const deepStarData *stardata) +void StarObject::init(const DeepStarData *stardata) { double ra, dec, BV_Index; @@ -215,7 +209,8 @@ SpType[0] = 'B'; if (stardata->B == 30000 || stardata->V == 30000) { - BV_Index = -100; + // Unused value +// BV_Index = -100; SpType[0] = '?'; } else @@ -239,7 +234,7 @@ lastPrecessJD = J2000; } -void StarObject::setNames(QString name, QString name2) +void StarObject::setNames(const QString &name, const QString &name2) { QString lname; Index: kstars/skyqpainter.cpp =================================================================== --- kstars/skyqpainter.cpp +++ kstars/skyqpainter.cpp @@ -774,8 +774,6 @@ case 5: //Gaseous Nebula case 15: // Dark Nebula - if (size < 2.) - size = 2.; save(); translate(x, y); rotate(positionAngle); //rotate the coordinate system @@ -801,8 +799,6 @@ restore(); //reset coordinate system break; case 7: //Supernova remnant // FIXME: Why is SNR drawn different from a gaseous nebula? - if (size < 2) - size = 2; save(); translate(x, y); rotate(positionAngle); //rotate the coordinate system @@ -837,9 +833,6 @@ { tempBrush = brush(); setBrush(QBrush()); - psize = 1.; - if (size > 50.) - psize *= 2.; color = pen().color().name(); save(); translate(x, y); Index: kstars/tools/adddeepskyobject.h =================================================================== --- kstars/tools/adddeepskyobject.h +++ kstars/tools/adddeepskyobject.h @@ -15,60 +15,46 @@ * * ***************************************************************************/ -#ifndef ADDDEEPSKYOBJECT_H -#define ADDDEEPSKYOBJECT_H +#pragma once #include "ui_adddeepskyobject.h" -#include "syncedcatalogcomponent.h" -#include -#include + +class QString; + +class SyncedCatalogComponent; /** * @class AddDeepSkyObject * @short Allows the user to add an object to a @sa SyncedCatalogComponent + * * @author Akarsh Simha */ - class AddDeepSkyObject : public QDialog, public Ui::AddDeepSkyObject { Q_OBJECT; public: - /** - * @short Constructor - */ + /** @short Constructor */ AddDeepSkyObject(QWidget *parent, SyncedCatalogComponent *catalog); - /** - * @short Destructor - */ + /** @short Destructor */ ~AddDeepSkyObject(); - /** - * @short Fills the dialog from a text by trying to guess fields - */ + /** @short Fills the dialog from a text by trying to guess fields */ void fillFromText(const QString &text); public slots: - /** - * @short Accept the dialog and add the entry to the catalog - */ + /** @short Accept the dialog and add the entry to the catalog */ bool slotOk(); - /** - * @short Resets the entries in the dialog - */ + /** @short Resets the entries in the dialog */ void resetView(); - /** - * @short Gathers the text and calls fillFromText() to parse the text - */ + /** @short Gathers the text and calls fillFromText() to parse the text */ void slotFillFromText(); private: - SyncedCatalogComponent *m_catalog; - Ui::AddDeepSkyObject *ui; + SyncedCatalogComponent *m_catalog { nullptr }; + Ui::AddDeepSkyObject *ui { nullptr }; }; - -#endif Index: kstars/tools/adddeepskyobject.cpp =================================================================== --- kstars/tools/adddeepskyobject.cpp +++ kstars/tools/adddeepskyobject.cpp @@ -15,15 +15,15 @@ * * ***************************************************************************/ -/* Project Includes */ #include "adddeepskyobject.h" + +#include "syncedcatalogcomponent.h" #include "skyobjects/skyobject.h" -/* KDE Includes */ #include -/* Qt Includes */ #include +#include AddDeepSkyObject::AddDeepSkyObject(QWidget *parent, SyncedCatalogComponent *catalog) : QDialog(parent), m_catalog(catalog), ui(new Ui::AddDeepSkyObject) @@ -174,11 +174,11 @@ } if (!coordText.isEmpty()) { - int coord1 = indexOf(coordText, matchCoords, 0, &rmatch); - Q_ASSERT(coord1 >= 0); +// int coord1 = indexOf(coordText, matchCoords, 0, &rmatch); +// Q_ASSERT(coord1 >= 0); RA = dms(rmatch.captured(1) + ' ' + rmatch.captured(2) + ' ' + rmatch.captured(3), false); - int coord2 = indexOf(coordText, matchCoords, coord1 + rmatch.captured(0).length(), &rmatch); - Q_ASSERT(coord2 >= 0); +// int coord2 = indexOf(coordText, matchCoords, coord1 + rmatch.captured(0).length(), &rmatch); +// Q_ASSERT(coord2 >= 0); Dec = dms(rmatch.captured(1) + ' ' + rmatch.captured(2) + ' ' + rmatch.captured(3), true); qDebug() << "Extracted coordinates: " << RA.toHMSString() << " " << Dec.toDMSString(); coordsFound = true; Index: kstars/tools/modcalcplanets.cpp =================================================================== --- kstars/tools/modcalcplanets.cpp +++ kstars/tools/modcalcplanets.cpp @@ -70,7 +70,7 @@ delete ld; } -void modCalcPlanets::slotComputePosition(void) +void modCalcPlanets::slotComputePosition() { KStarsDateTime dt = DateTimeBox->dateTime(); long double julianDay = dt.djd(); @@ -91,48 +91,48 @@ // Pointer to hold planet data. Pointer is used since it has to // hold objects of different type. It's safe to use new/delete // because exceptions are disallowed. - KSPlanetBase *p = 0; + std::unique_ptr p; switch (PlanetComboBox->currentIndex()) { case 0: - p = new KSPlanet(KSPlanetBase::MERCURY); + p.reset(new KSPlanet(KSPlanetBase::MERCURY)); break; case 1: - p = new KSPlanet(KSPlanetBase::VENUS); + p.reset(new KSPlanet(KSPlanetBase::VENUS)); break; case 3: - p = new KSPlanet(KSPlanetBase::MARS); + p.reset(new KSPlanet(KSPlanetBase::MARS)); break; case 4: - p = new KSPlanet(KSPlanetBase::JUPITER); + p.reset(new KSPlanet(KSPlanetBase::JUPITER)); break; case 5: - p = new KSPlanet(KSPlanetBase::SATURN); + p.reset(new KSPlanet(KSPlanetBase::SATURN)); break; case 6: - p = new KSPlanet(KSPlanetBase::URANUS); + p.reset(new KSPlanet(KSPlanetBase::URANUS)); break; case 7: - p = new KSPlanet(KSPlanetBase::NEPTUNE); + p.reset(new KSPlanet(KSPlanetBase::NEPTUNE)); break; /*case 8: - p = new KSPluto(); break;*/ + p.reset(new KSPluto(); break;*/ case 8: - p = new KSMoon(); + p.reset(new KSMoon()); break; case 9: - p = new KSSun(); + p.reset(new KSSun()); p->setRsun(0.0); break; } + if (p.get() == nullptr) + return; // Show data. p->findPosition(&num, geoPlace->lat(), &LST, &Earth); p->EquatorialToHorizontal(&LST, geoPlace->lat()); showCoordinates(*p); - // Cleanup. - delete p; } void modCalcPlanets::showCoordinates(const KSPlanetBase &ksp) Index: kstars/tools/modcalcvizequinox.cpp =================================================================== --- kstars/tools/modcalcvizequinox.cpp +++ kstars/tools/modcalcvizequinox.cpp @@ -328,7 +328,8 @@ } while (y3 * sgn > y2 * sgn); //Ok, now y2 is larger(smaller) than both y3 and y1. - jd2 = jd3 - 1.0; + // Never read back +// jd2 = jd3 - 1.0; jd1 = jd3 - 2.0; //Choose a new starting jd2 that follows the golden ratio: @@ -357,7 +358,8 @@ else { jd3 = jd2; - y3 = y2; + // Never read back +// y3 = y2; jd2 = jd4; y2 = y4; } @@ -367,7 +369,8 @@ if (jd4 > jd2) { jd3 = jd4; - y3 = y4; + // Never read back +// y3 = y4; } else { Index: kstars/tools/obslistwizard.h =================================================================== --- kstars/tools/obslistwizard.h +++ kstars/tools/obslistwizard.h @@ -14,14 +14,16 @@ * * ***************************************************************************/ -#ifndef OBSLISTWIZARD_H_ -#define OBSLISTWIZARD_H_ +#pragma once #include #include "ui_obslistwizard.h" #include "skyobjects/skypoint.h" +class QListWidget; +class QPushButton; + class SkyObject; class GeoLocation; @@ -32,9 +34,11 @@ ObsListWizardUI(QWidget *p); }; -/** @class ObsListWizard - *@short Wizard for constructing observing lists - *@author Jason Harris +/** + * @class ObsListWizard + * @short Wizard for constructing observing lists + * + * @author Jason Harris */ class ObsListWizard : public QDialog { @@ -61,8 +65,7 @@ void slotParseRegion(); - /** @short Construct the observing list by applying the selected filters - */ + /** @short Construct the observing list by applying the selected filters */ void slotObjectCountDirty(); void slotUpdateObjectCount(); void slotApplyFilters() { applyFilters(true); } @@ -70,37 +73,49 @@ private: void initialize(); void applyFilters(bool doBuildList); + /** @return true if the object passes the filter region constraints, false otherwise.*/ bool applyRegionFilter(SkyObject *o, bool doBuildList, bool doAdjustCount = true); bool applyObservableFilter(SkyObject *o, bool doBuildList, bool doAdjustCount = true); /** - *Convenience function for safely getting the selected state of a QListWidget item by name. - *QListWidget has no method for easily selecting a single item based on its text. - *@return true if the named QListWidget item is selected. - *@param name the QListWidget item to be queried is the one whose text matches this string - *@param listWidget pointer to the QListWidget whose item is to be queried - *@param ok pointer to a bool, which if present will return true if a matching list item was found - */ - bool isItemSelected(const QString &name, QListWidget *listWidget, bool *ok = 0); + * Convenience function for safely getting the selected state of a QListWidget item by name. + * QListWidget has no method for easily selecting a single item based on its text. + * @return true if the named QListWidget item is selected. + * @param name the QListWidget item to be queried is the one whose text matches this string + * @param listWidget pointer to the QListWidget whose item is to be queried + * @param ok pointer to a bool, which if present will return true if a matching list item was found + */ + bool isItemSelected(const QString &name, QListWidget *listWidget, bool *ok = nullptr); /** - *Convenience function for safely setting the selected state of a QListWidget item by name. - *QListWidget has no method for easily selecting a single item based on its text. - *@param name the QListWidget item to be (de)selected is the one whose text matches this string - *@param listWidget pointer to the QListWidget whose item is to be (de)selected - *@param value set the item's selected state to this bool value - *@param ok pointer to a bool, which if present will return true if a matching list item was found - */ - void setItemSelected(const QString &name, QListWidget *listWidget, bool value, bool *ok = 0); + * Convenience function for safely setting the selected state of a QListWidget item by name. + * QListWidget has no method for easily selecting a single item based on its text. + * @param name the QListWidget item to be (de)selected is the one whose text matches this string + * @param listWidget pointer to the QListWidget whose item is to be (de)selected + * @param value set the item's selected state to this bool value + * @param ok pointer to a bool, which if present will return true if a matching list item was found + */ + void setItemSelected(const QString &name, QListWidget *listWidget, bool value, bool *ok = nullptr); QList ObsList; - ObsListWizardUI *olw; - uint ObjectCount, StarCount, PlanetCount, CometCount, AsteroidCount; - uint GalaxyCount, OpenClusterCount, GlobClusterCount, GasNebCount, PlanNebCount; - double xRect1, xRect2, yRect1, yRect2, rCirc; + ObsListWizardUI *olw { nullptr }; + uint ObjectCount { 0 }; + uint StarCount { 0 }; + uint PlanetCount { 0 }; + uint CometCount { 0 }; + uint AsteroidCount { 0 }; + uint GalaxyCount { 0 }; + uint OpenClusterCount { 0 }; + uint GlobClusterCount { 0 }; + uint GasNebCount { 0 }; + uint PlanNebCount { 0 }; + double xRect1 { 0 }; + double xRect2 { 0 }; + double yRect1 { 0 }; + double yRect2 { 0 }; + double rCirc { 0 }; SkyPoint pCirc; - GeoLocation *geo; - QPushButton *nextB, *backB; + GeoLocation *geo { nullptr }; + QPushButton *nextB { nullptr }; + QPushButton *backB { nullptr }; }; - -#endif Index: kstars/tools/obslistwizard.cpp =================================================================== --- kstars/tools/obslistwizard.cpp +++ kstars/tools/obslistwizard.cpp @@ -16,23 +16,12 @@ #include "obslistwizard.h" -#include -#include - -#include -#include -#include - -#include "kstarsdata.h" #include "geolocation.h" +#include "kstarsdata.h" #include "dialogs/locationdialog.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/deepskyobject.h" -#include "skyobjects/starobject.h" -#include "widgets/dmsbox.h" -#include "widgets/magnitudespinbox.h" #include "skycomponents/constellationboundarylines.h" #include "skycomponents/skymapcomposite.h" +#include "skyobjects/deepskyobject.h" ObsListWizardUI::ObsListWizardUI(QWidget *p) : QFrame(p) { @@ -829,10 +818,8 @@ //select by constellation if (isItemSelected(i18n("by constellation"), olw->RegionList)) { - int i=0; - if (o->name() == "M 66") - i=1; QString c = KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName(o); + if (isItemSelected(c, olw->ConstellationList)) { if (doBuildList) Index: kstars/tools/starhopper.h =================================================================== --- kstars/tools/starhopper.h +++ kstars/tools/starhopper.h @@ -15,70 +15,68 @@ * * ***************************************************************************/ -#ifndef _STARHOPPER_H_ -#define _STARHOPPER_H_ +#pragma once -/** - *@class StarHopper - *@short Helps planning star hopping - *@version 1.0 - *@author Akarsh Simha - */ +#include +#include + +class QStringList; -#include "skypoint.h" -#include "skyobject.h" -#include "starobject.h" +class SkyPoint; +class StarObject; +/** + * @class StarHopper + * @short Helps planning star hopping + * + * @version 1.0 + * @author Akarsh Simha + */ class StarHopper { public: /** - *@short Computes path for Star Hop - *@param src SkyPoint to source of the Star Hop - *@param dest SkyPoint to destination of the Star Hop - *@param fov__ Field of view within which stars are considered - *@param maglim__ Magnitude limit of stars to consider - *@param metadata_ Directions for starhopping - *@return QList of StarObject pointers which are the resultant path to Star Hop - *@note The StarObjects in the list returned are mutable and not constant - */ + * @short Computes path for Star Hop + * @param src SkyPoint to source of the Star Hop + * @param dest SkyPoint to destination of the Star Hop + * @param fov__ Field of view within which stars are considered + * @param maglim__ Magnitude limit of stars to consider + * @param metadata_ Directions for starhopping + * @return QList of StarObject pointers which are the resultant path to Star Hop + * @note The StarObjects in the list returned are mutable and not constant + */ QList *computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__, - QStringList *metadata_ = 0); + QStringList *metadata_ = nullptr); - private: - float fov; - float maglim; - QString starHopDirections; - - // Useful for internal computations - SkyPoint const *start; - SkyPoint const *end; - QHash came_from; // Used by the A* search algorithm - QList result_path; + protected: + // Returns a list of constant StarObject pointers which form the resultant path of Star Hop + QList computePath_const(const SkyPoint &src, const SkyPoint &dest, float fov_, float maglim_, + QStringList *metadata = nullptr); + private: /** - *@short The cost function for hopping from current position to the a given star, in view of the final destination - *@param curr Source SkyPoint - *@param next Next point in the hop. - *@note If 'next' is neither the starting point of the hop, nor - * the ending point, it _has_ to be a StarObject. A dynamic cast - * followed by a Q_ASSERT will ensure this. - */ + * @short The cost function for hopping from current position to the a given star, in view of the final destination + * @param curr Source SkyPoint + * @param next Next point in the hop. + * @note If 'next' is neither the starting point of the hop, nor + * the ending point, it _has_ to be a StarObject. A dynamic cast + * followed by a Q_ASSERT will ensure this. + */ float cost(const SkyPoint *curr, const SkyPoint *next); /** - *@short For internal use by the A* Search Algorithm. Completes - * the star-hop path. See - * http://en.wikipedia.org/wiki/A*_search_algorithm for details - */ + * @short For internal use by the A* Search Algorithm. Completes + * the star-hop path. See http://en.wikipedia.org/wiki/A*_search_algorithm for details + */ void reconstructPath(SkyPoint const *curr_node); + float fov { 0 }; + float maglim { 0 }; + QString starHopDirections; + // Useful for internal computations + SkyPoint const *start { nullptr }; + SkyPoint const *end { nullptr }; + QHash came_from; // Used by the A* search algorithm + QList result_path; QHash patternNames; // if patterns were identified, they are added to this hash. - - protected: - //Returns a list of constant StarObject pointers which form the resultant path of Star Hop - QList computePath_const(const SkyPoint &src, const SkyPoint &dest, float fov_, float maglim_, - QStringList *metadata = 0); }; - -#endif Index: kstars/tools/starhopper.cpp =================================================================== --- kstars/tools/starhopper.cpp +++ kstars/tools/starhopper.cpp @@ -17,14 +17,10 @@ #include "starhopper.h" -#include "skyobjects/skyobject.h" -#include "skyobjects/starobject.h" -#include "starcomponent.h" - #include "kstarsdata.h" #include "ksutils.h" - -#include +#include "starcomponent.h" +#include "skyobjects/starobject.h" QList *StarHopper::computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__, QStringList *metadata_) @@ -81,6 +77,9 @@ curr_node = sp; } } + if (curr_node == nullptr) + continue; + qDebug() << "Lowest fscore (vertex distance-plus-cost score) is " << lowfscore << " with coords: " << curr_node->ra().toHMSString() << curr_node->dec().toDMSString() << ". Considering this node now."; Index: tools/run_clang_static_code_analyser.sh =================================================================== --- /dev/null +++ tools/run_clang_static_code_analyser.sh @@ -0,0 +1,13 @@ +# Set some environment variables +export CCC_CC=clang-4.0 +export CCC_CXX=clang++-4.0 +CC_ANALYZER=/usr/lib/llvm-4.0/libexec/ccc-analyzer +CXX_ANALYZER=/usr/lib/llvm-4.0/libexec/c++-analyzer +# Create a separate build directory +rm -rf clang_sa_build +mkdir -p clang_sa_build +# Configure CMake +scan-build-4.0 --use-analyzer=$CXX_ANALYZER -disable-checker=deadcode.DeadStores cmake -Bclang_sa_build -H.. -DCMAKE_C_COMPILER=$CC_ANALYZER -DCCACHE_SUPPORT=OFF -DCMAKE_BUILD_TYPE=Debug +# Do a Clang build with static analyzer +make -C clang_sa_build clean +scan-build-4.0 --use-analyzer=$CXX_ANALYZER -o clang-code-analysis-report make -C clang_sa_build -j4