summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCsaba Kertesz <[email protected]>2017-07-10 23:56:45 +0300
committerCsaba Kertesz <[email protected]>2017-07-15 20:49:53 +0300
commitab753adba342d947f63be425faaeef2fd7785e04 (patch)
tree1cf4e50336429e1e10f49ad3d9127b7325279bbd
parent06d855390eb09fdf7cca2792a0aeddfb92342e8b (diff)
Memory management clean-up, valgrind suppression file and other fixes
-rw-r--r--datahandlers/catalogdb.cpp10
-rw-r--r--datahandlers/catalogdb.h292
-rw-r--r--kstars/auxiliary/binfilehelper.cpp4
-rw-r--r--kstars/auxiliary/fov.cpp7
-rw-r--r--kstars/auxiliary/fov.h68
-rw-r--r--kstars/auxiliary/imageviewer.cpp1
-rw-r--r--kstars/indi/drivermanager.cpp47
-rw-r--r--kstars/indi/drivermanager.h20
-rw-r--r--kstars/indi/guimanager.cpp40
-rw-r--r--kstars/indi/guimanager.h37
-rw-r--r--kstars/kstars.cpp92
-rw-r--r--kstars/kstars.h104
-rw-r--r--kstars/kstarsactions.cpp2
-rw-r--r--kstars/kstarsdata.cpp61
-rw-r--r--kstars/kstarsdata.h301
-rw-r--r--kstars/kstarslite/skyitems/deepstaritem.cpp19
-rw-r--r--kstars/kstarslite/skyitems/deepstaritem.h32
-rw-r--r--kstars/kstarslite/skyitems/staritem.cpp25
-rw-r--r--kstars/kstarslite/skyitems/staritem.h46
-rw-r--r--kstars/main.cpp8
-rw-r--r--kstars/oal/log.cpp13
-rw-r--r--kstars/oal/log.h1
-rw-r--r--kstars/printing/foveditordialog.cpp12
-rw-r--r--kstars/printing/foveditordialog.h80
-rw-r--r--kstars/projections/projector.h11
-rw-r--r--kstars/skycomponents/constellationboundarylines.cpp28
-rw-r--r--kstars/skycomponents/constellationboundarylines.h40
-rw-r--r--kstars/skycomponents/constellationlines.cpp20
-rw-r--r--kstars/skycomponents/constellationlines.h49
-rw-r--r--kstars/skycomponents/coordinategrid.h31
-rw-r--r--kstars/skycomponents/culturelist.h14
-rw-r--r--kstars/skycomponents/deepskycomponent.cpp42
-rw-r--r--kstars/skycomponents/deepskycomponent.h145
-rw-r--r--kstars/skycomponents/deepstarcomponent.cpp38
-rw-r--r--kstars/skycomponents/deepstarcomponent.h94
-rw-r--r--kstars/skycomponents/ecliptic.cpp12
-rw-r--r--kstars/skycomponents/ecliptic.h13
-rw-r--r--kstars/skycomponents/equator.cpp10
-rw-r--r--kstars/skycomponents/equator.h15
-rw-r--r--kstars/skycomponents/equatorialcoordinategrid.cpp12
-rw-r--r--kstars/skycomponents/equatorialcoordinategrid.h29
-rw-r--r--kstars/skycomponents/highpmstarlist.cpp6
-rw-r--r--kstars/skycomponents/horizontalcoordinategrid.cpp14
-rw-r--r--kstars/skycomponents/horizontalcoordinategrid.h26
-rw-r--r--kstars/skycomponents/linelist.h10
-rw-r--r--kstars/skycomponents/linelistindex.cpp36
-rw-r--r--kstars/skycomponents/linelistindex.h186
-rw-r--r--kstars/skycomponents/linelistlabel.h44
-rw-r--r--kstars/skycomponents/listcomponent.cpp5
-rw-r--r--kstars/skycomponents/listcomponent.h41
-rw-r--r--kstars/skycomponents/milkyway.cpp27
-rw-r--r--kstars/skycomponents/milkyway.h40
-rw-r--r--kstars/skycomponents/noprecessindex.h22
-rw-r--r--kstars/skycomponents/pointlistcomponent.cpp1
-rw-r--r--kstars/skycomponents/polylist.h2
-rw-r--r--kstars/skycomponents/satellitescomponent.cpp2
-rw-r--r--kstars/skycomponents/skiplist.h30
-rw-r--r--kstars/skycomponents/skycomponent.cpp14
-rw-r--r--kstars/skycomponents/skycomposite.cpp1
-rw-r--r--kstars/skycomponents/skymapcomposite.cpp100
-rw-r--r--kstars/skycomponents/skymapcomposite.h228
-rw-r--r--kstars/skycomponents/solarsystemcomposite.cpp12
-rw-r--r--kstars/skycomponents/solarsystemcomposite.h36
-rw-r--r--kstars/skycomponents/starblockfactory.cpp2
-rw-r--r--kstars/skycomponents/starblocklist.cpp1
-rw-r--r--kstars/skycomponents/starcomponent.cpp17
-rw-r--r--kstars/skycomponents/starcomponent.h19
-rw-r--r--kstars/skycomponents/targetlistcomponent.cpp50
-rw-r--r--kstars/skycomponents/targetlistcomponent.h66
-rw-r--r--kstars/skycomponents/typedef.h6
-rw-r--r--kstars/skyobjects/kscomet.cpp12
-rw-r--r--kstars/skyobjects/kscomet.h228
-rw-r--r--kstars/skyobjects/ksplanetbase.cpp14
-rw-r--r--kstars/skyobjects/ksplanetbase.h185
-rw-r--r--kstars/skyobjects/skypoint.cpp8
-rw-r--r--kstars/skyobjects/skypoint.h1
-rw-r--r--kstars/skypainter.h167
-rw-r--r--kstars/skyqpainter.cpp48
-rw-r--r--kstars/skyqpainter.h49
-rw-r--r--kstars/texturemanager.cpp15
-rw-r--r--kstars/texturemanager.h26
-rw-r--r--kstars/tools/observinglist.cpp61
-rw-r--r--kstars/tools/observinglist.h31
-rw-r--r--kstars/tools/obslistpopupmenu.cpp5
-rw-r--r--kstars/tools/obslistpopupmenu.h19
-rw-r--r--tools/valgrind.supp361
86 files changed, 2144 insertions, 2055 deletions
diff --git a/datahandlers/catalogdb.cpp b/datahandlers/catalogdb.cpp
index d1e7491..1d489ff 100644
--- a/datahandlers/catalogdb.cpp
+++ b/datahandlers/catalogdb.cpp
@@ -16,6 +16,7 @@
***************************************************************************/
#include "catalogdb.h"
+
#include "catalogdata.h"
#include "catalogentrydata.h"
#include "kstars/version.h"
@@ -23,10 +24,7 @@
#include "starobject.h"
#include "deepskyobject.h"
#include "skycomponent.h"
-#include "skyobject.h"
-#include <QVariant>
-#include <QHash>
#include <QSqlTableModel>
#include <QSqlRecord>
#include <QSqlQuery>
@@ -830,8 +828,10 @@ void CatalogDB::GetAllObjects(const QString &catalog, QList<SkyObject *> &sky_li
QList<QPair<int, QString>> &object_names, CatalogComponent *catalog_ptr,
bool includeCatalogDesignation)
{
+ qDeleteAll(sky_list);
sky_list.clear();
QString selected_catalog = QString::number(FindCatalog(catalog));
+
skydb_.open();
QSqlQuery get_query(skydb_);
get_query.prepare("SELECT Epoch, Type, RA, Dec, Magnitude, Prefix, "
@@ -866,8 +866,8 @@ void CatalogDB::GetAllObjects(const QString &catalog, QList<SkyObject *> &sky_li
float b = get_query.value(9).toFloat();
float PA = get_query.value(10).toFloat();
float flux = get_query.value(11).toFloat();
-
QString name;
+
if (!includeCatalogDesignation && !lname.isEmpty())
{
name = lname;
@@ -912,11 +912,13 @@ void CatalogDB::GetAllObjects(const QString &catalog, QList<SkyObject *> &sky_li
if (iType == 0) // Add a star
{
StarObject *o = new StarObject(RA, Dec, mag, lname);
+
sky_list.append(o);
}
else // Add a deep-sky object
{
DeepSkyObject *o = new DeepSkyObject(iType, RA, Dec, mag, name, QString(), lname, catPrefix, a, b, -PA);
+
o->setFlux(flux);
o->setCustomCatalog(catalog_ptr);
diff --git a/datahandlers/catalogdb.h b/datahandlers/catalogdb.h
index ae15fef..7af3bd4 100644
--- a/datahandlers/catalogdb.h
+++ b/datahandlers/catalogdb.h
@@ -15,37 +15,27 @@
* *
***************************************************************************/
-#ifndef CATALOGDB_H
-#define CATALOGDB_H
+#pragma once
-#include <QStandardPaths>
-#include <KLocalizedString>
-#include <QDebug>
-#include <QSqlDatabase>
-#include <QSqlError>
-#include <QFile>
-#include <QDir>
+#include "ksparser.h"
+#include <KLocalizedString>
#ifndef KSTARS_LITE
#include <KMessageBox>
#endif
-#include "ksparser.h"
-
-#include <QString>
-#include <QStringList>
-#include <QList>
-#include <QPair>
-#include <QSqlQuery>
+#include <QSqlDatabase>
+#include <QSqlError>
class SkyObject;
class CatalogComponent;
class CatalogData;
class CatalogEntryData;
-/* Some notes about the database. (skycomponents.sqlite)
+/*
+ * Some notes about the database. (skycomponents.sqlite)
* 1) The uid for Object Designation is the uid being used by objects in KStars
- * hence, the uid is a qint64 i.e. a 64 bit signed integer. Coincidentaly,
+ * hence, the uid is a qint64 i.e. a 64 bit signed integer. Coincidentally,
* this is the max limit of an int in Sqlite3.
* Hence, the db is compatible with the uid, but doesn't use it as of now.
*/
@@ -54,196 +44,196 @@ class CatalogDB
{
public:
/**
- * @brief Initializes the database and sets up pointers to Catalog DB
- * Performs the following actions:
- * 1. Checks if database file exists
- * 2. Checks if database can be opened
- * 3. If DB file is missing, creates new DB
- * 4. Sets up pointer to Catalog DB
- *
- * usage: Call QSqlDatabase::removeDatabase("skydb"); after the object
- * of this class is deallocated
- * @return bool
- **/
+ * @brief Initializes the database and sets up pointers to Catalog DB
+ * Performs the following actions:
+ * 1. Checks if database file exists
+ * 2. Checks if database can be opened
+ * 3. If DB file is missing, creates new DB
+ * 4. Sets up pointer to Catalog DB
+ *
+ * usage: Call QSqlDatabase::removeDatabase("skydb"); after the object
+ * of this class is deallocated
+ * @return bool
+ **/
bool Initialize();
+
/**
- * @brief Attempt to close database and remove reference from the DB List
- *
- **/
+ * @brief Attempt to close database and remove reference from the DB List
+ *
+ **/
~CatalogDB();
+
/**
- * @brief Accessor for list of all available catalogs in db
- *
- * @return QStringList*
- **/
+ * @brief Accessor for list of all available catalogs in db
+ *
+ * @return QStringList*
+ **/
QStringList *Catalogs();
+
/**
- * @brief Rechecks the database and builds the Catalog listing.
- * New listing is directly updated into catalogs (accessed using Catalogs())
- *
- * @return void
- **/
+ * @brief Rechecks the database and builds the Catalog listing.
+ * New listing is directly updated into catalogs (accessed using Catalogs())
+ *
+ * @return void
+ **/
void RefreshCatalogList();
/**
- * @short Parses the catalog header and returns the catalog name
- *
- * @p filename the name of the file containing the data to be read
- * @return Catalog name or empty string if there is an error
- */
+ * @short Parses the catalog header and returns the catalog name
+ *
+ * @p filename the name of the file containing the data to be read
+ * @return Catalog name or empty string if there is an error
+ */
QString GetCatalogName(const QString &filename);
/**
- * @short Add contents of custom catalog to the program database
- *
- * @p filename the name of the file containing the data to be read
- * @return true if catalog was successfully added
- */
+ * @short Add contents of custom catalog to the program database
+ *
+ * @p filename the name of the file containing the data to be read
+ * @return true if catalog was successfully added
+ */
bool AddCatalogContents(const QString &filename);
/**
- * @brief returns the id of the row if it matches with certain fuzz.
- * Else return -1 if none found
- *
- * @param ra Right Ascension of new object to be added
- * @param dec Declination of new object to be added
- * @return int RowUID of the new row
- **/
+ * @brief returns the id of the row if it matches with certain fuzz.
+ * Else return -1 if none found
+ *
+ * @param ra Right Ascension of new object to be added
+ * @param dec Declination of new object to be added
+ * @return int RowUID of the new row
+ **/
int FindFuzzyEntry(const double ra, const double dec, const double magnitude);
/**
- * @brief Removes the catalog from the database and refreshes the listing.
- *
- * @param catalog_name Name of the catalog
- * @return void
- **/
+ * @brief Removes the catalog from the database and refreshes the listing.
+ *
+ * @param catalog_name Name of the catalog
+ * @return void
+ **/
void RemoveCatalog(const QString &catalog_name);
/**
- * @brief Creates objects of type SkyObject and assigns them to references
- *
- * @param catalog Name of the catalog whose objects are needed.
- * @param sky_list List of all skyobjects stored in database (assigns)
- * @param names List of named objects in database (assigns)
- * @param catalog_pointer pointer to the catalogcomponent objects
- * (needed for building skyobjects)
- * @param includeCatalogDesignation This is useful when using 'fake'
- * catalogs to bundle up catalogs. Imagine a "Misc" catalog with a
- * bunch of miscellaneous objects. We don't want the designations
- * "Misc 1", "Misc 2" etc. So the only proper designations are the
- * long name. When this is the case, this flag is set to false,
- * and the catalog designation (cat_prefix + cat_id) will not be
- * included in the object_names returned.
- *
- * @return void
- **/
+ * @brief Creates objects of type SkyObject and assigns them to references
+ *
+ * @param catalog Name of the catalog whose objects are needed.
+ * @param sky_list List of all skyobjects stored in database (assigns)
+ * @param names List of named objects in database (assigns)
+ * @param catalog_pointer pointer to the catalogcomponent objects
+ * (needed for building skyobjects)
+ * @param includeCatalogDesignation This is useful when using 'fake' catalogs to bundle up
+ * catalogs. Imagine a "Misc" catalog with a bunch of miscellaneous objects. We don't want
+ * the designations "Misc 1", "Misc 2" etc. So the only proper designations are the
+ * long name. When this is the case, this flag is set to false, and the catalog designation
+ * (cat_prefix + cat_id) will not be included in the object_names returned.
+ *
+ * @return void
+ **/
void GetAllObjects(const QString &catalog_name, QList<SkyObject *> &sky_list,
QList<QPair<int, QString>> &object_names, CatalogComponent *catalog_pointer,
bool includeCatalogDesignation = true);
/**
- * @brief Get information about the catalog like Prefix etc
- *
- * @param catalog_name Name of catalog whose details are required
- * @param catalog_data Data structure assigned with required data
- * @return void
- **/
+ * @brief Get information about the catalog like Prefix etc
+ *
+ * @param catalog_name Name of catalog whose details are required
+ * @param catalog_data Data structure assigned with required data
+ * @return void
+ **/
void GetCatalogData(const QString &catalog_name, CatalogData &catalog_data);
/**
- * @brief Used to add a cross referenced entry into the database
- *
- * @note This public method opens and closes the database.
- *
- * @param catalog_entry Data structure with entry details
- * @param catid Category ID in the database
- * @return false if adding was unsuccessful
- **/
+ * @brief Used to add a cross referenced entry into the database
+ *
+ * @note This public method opens and closes the database.
+ *
+ * @param catalog_entry Data structure with entry details
+ * @param catid Category ID in the database
+ * @return false if adding was unsuccessful
+ **/
bool AddEntry(const CatalogEntryData &catalog_entry, int catid);
/**
- * @brief Returns database ID of the required catalog.
- * Returns -1 if not found.
- *
- * @param name Name of the class being searched
- * @return int
- **/
+ * @brief Returns database ID of the required catalog.
+ * Returns -1 if not found.
+ *
+ * @param name Name of the class being searched
+ * @return int
+ **/
int FindCatalog(const QString &catalog_name);
/**
- * @brief Add the catalog with given details into the database
- *
- * @param catalog_data CatalogData object encompassing all catalog info
- * @return void
- **/
+ * @brief Add the catalog with given details into the database
+ *
+ * @param catalog_data CatalogData object encompassing all catalog info
+ * @return void
+ **/
void AddCatalog(const CatalogData &catalog_data);
private:
/**
- * @brief Used to add a cross referenced entry into the database
- *
- * @note This private method is useful when calling the method
- * repeatedly on an already-opened DB.
- *
- * @param catalog_entry Data structure with entry details
- * @param catid Category ID in the database
- * @return false if adding was unsuccessful
- **/
+ * @brief Used to add a cross referenced entry into the database
+ *
+ * @note This private method is useful when calling the method
+ * repeatedly on an already-opened DB.
+ *
+ * @param catalog_entry Data structure with entry details
+ * @param catid Category ID in the database
+ * @return false if adding was unsuccessful
+ **/
bool _AddEntry(const CatalogEntryData &catalog_entry, int catid);
/**
- * @brief Database object for the sky object. Assigned and Initialized by
- * Initialize()
- **/
+ * @brief Database object for the sky object. Assigned and Initialized by Initialize()
+ **/
QSqlDatabase skydb_;
/**
- * @brief Returns the last error the database encountered
- *
- * @return QSqlError
- **/
+ * @brief Returns the last error the database encountered
+ *
+ * @return QSqlError
+ **/
QSqlError LastError();
/**
- * @brief List of all the catalogs contained in the database.
- * This variable is accessed through Catalogs()
- **/
+ * @brief List of all the catalogs contained in the database.
+ * This variable is accessed through Catalogs()
+ **/
QStringList catalog_list_;
/**
- * @short Add the catalog name and details to the db.
- * This does not store the contents. It only adds the catalog info
- * to the database. Hence, it is step 1 in AddCatalogContents
- *
- * @param lines List of lines to use for extraction of details
- * @param Columns Stores the read Columns in this list
- * @param catalog_name Name retrieved from file header
- * @param delimiter Delimeter retrieved from file header
- * @return bool
- **/
+ * @short Add the catalog name and details to the db.
+ * This does not store the contents. It only adds the catalog info
+ * to the database. Hence, it is step 1 in AddCatalogContents
+ *
+ * @param lines List of lines to use for extraction of details
+ * @param Columns Stores the read Columns in this list
+ * @param catalog_name Name retrieved from file header
+ * @param delimiter Delimeter retrieved from file header
+ * @return bool
+ **/
bool ParseCatalogInfoToDB(const QStringList &lines, QStringList &columns, QString &catalog_name, char &delimiter);
/**
- * @brief Prepares the sequence required by KSParser according to header.
- * Information on the sequence is stored inside the header
- *
- * @param Columns List of the columns names as strings
- * @return QList of the format usable by KSParser
- **/
+ * @brief Prepares the sequence required by KSParser according to header.
+ * Information on the sequence is stored inside the header
+ *
+ * @param Columns List of the columns names as strings
+ * @return QList of the format usable by KSParser
+ **/
QList<QPair<QString, KSParser::DataTypes>> buildParserSequence(const QStringList &Columns);
+
/**
- * @brief Clears out the DSO table for the given catalog ID
- *
- * @param catalog_id DB generated catalog ID
- * @return void
- **/
+ * @brief Clears out the DSO table for the given catalog ID
+ *
+ * @param catalog_id DB generated catalog ID
+ * @return void
+ **/
void ClearDSOEntries(int catalog_id);
+
/**
- * @brief Contains setup routines to intitialize a database for catalog storage
- *
- * @return void
- **/
+ * @brief Contains setup routines to intitialize a database for catalog storage
+ *
+ * @return void
+ **/
void FirstRun();
};
-
-#endif // CATALOGDB_H
diff --git a/kstars/auxiliary/binfilehelper.cpp b/kstars/auxiliary/binfilehelper.cpp
index f344a40..e5baa87 100644
--- a/kstars/auxiliary/binfilehelper.cpp
+++ b/kstars/auxiliary/binfilehelper.cpp
@@ -18,10 +18,11 @@
#include "binfilehelper.h"
-#include <QStandardPaths>
#include "byteorder.h"
#include "auxiliary/kspaths.h"
+#include <QStandardPaths>
+
class BinFileHelper;
BinFileHelper::BinFileHelper()
@@ -33,6 +34,7 @@ BinFileHelper::BinFileHelper()
BinFileHelper::~BinFileHelper()
{
qDeleteAll(fields);
+ fields.clear();
if (fileHandle)
closeFile();
}
diff --git a/kstars/auxiliary/fov.cpp b/kstars/auxiliary/fov.cpp
index 375237a..b66e8ca 100644
--- a/kstars/auxiliary/fov.cpp
+++ b/kstars/auxiliary/fov.cpp
@@ -152,13 +152,18 @@ const QList<FOV *> &FOVManager::readFOVs()
continue;
}
- //FIXME: This still shows lost blocks in Valgrind despite the fact memory is always cleared?
m_FOVs.append(new FOV(name, sizeX, sizeY, xoffset, yoffset, rot, shape, color));
}
}
return m_FOVs;
}
+void FOVManager::releaseCache()
+{
+ qDeleteAll(m_FOVs);
+ m_FOVs.clear();
+}
+
FOV::Shape FOV::intToShape(int s)
{
return (s >= FOV::UNKNOWN || s < 0) ? FOV::UNKNOWN : static_cast<FOV::Shape>(s);
diff --git a/kstars/auxiliary/fov.h b/kstars/auxiliary/fov.h
index e38e307..07c39f9 100644
--- a/kstars/auxiliary/fov.h
+++ b/kstars/auxiliary/fov.h
@@ -15,24 +15,22 @@
* *
***************************************************************************/
-#ifndef FOV_H_
-#define FOV_H_
+#pragma once
-#include <QList>
+#include "skypoint.h"
#include <QImage>
+#include <QList>
#include <QString>
-#include <KLocalizedString>
-
-#include "skypoint.h"
class QPainter;
-/** @class FOV
- * A simple class encapsulating a Field-of-View symbol
- *@author Jason Harris
- *@version 1.0
-*/
+/**
+ * @class FOV
+ * A simple class encapsulating a Field-of-View symbol
+ * @author Jason Harris
+ * @version 1.0
+ */
class FOV
{
public:
@@ -47,7 +45,7 @@ class FOV
};
static FOV::Shape intToShape(int);
- /**Default constructor*/
+ /** Default constructor */
FOV();
FOV(const QString &name, float a, float b = -1, float xoffset = 0, float yoffset = 0, float rot = 0,
Shape shape = SQUARE, const QString &color = "#FFFFFF");
@@ -82,16 +80,19 @@ class FOV
inline QString color() const { return m_color; }
void setColor(const QString &c) { m_color = c; }
- /** @short draw the FOV symbol on a QPainter
- * @param p reference to the target QPainter. The painter should already be started.
- * @param zoomFactor is zoom factor as in SkyMap.
- */
+ /**
+ * @short draw the FOV symbol on a QPainter
+ * @param p reference to the target QPainter. The painter should already be started.
+ * @param zoomFactor is zoom factor as in SkyMap.
+ */
void draw(QPainter &p, float zoomFactor);
- /** @short draw FOV symbol so it will be inside a rectangle
- * @param p reference to the target QPainter. The painter should already be started.
- * @param x is X size of rectangle
- * @param y is Y size of rectangle
- */
+
+ /**
+ * @short draw FOV symbol so it will be inside a rectangle
+ * @param p reference to the target QPainter. The painter should already be started.
+ * @param x is X size of rectangle
+ * @param y is Y size of rectangle
+ */
void draw(QPainter &p, float x, float y);
SkyPoint center() const;
@@ -107,26 +108,29 @@ class FOV
private:
QString m_name, m_color;
Shape m_shape;
- float m_sizeX, m_sizeY;
- float m_offsetX, m_offsetY;
- float m_rotation;
- float m_northPA;
+ float m_sizeX { 0 }, m_sizeY { 0 };
+ float m_offsetX { 0 }, m_offsetY { 0 };
+ float m_rotation { 0 };
+ float m_northPA { 0 };
SkyPoint m_center;
QImage m_image;
- bool m_imageDisplay;
+ bool m_imageDisplay { false };
};
-/** @class FOVManager
- * A simple class handling FOVs.
+/**
+ * @class FOVManager
+ * A simple class handling FOVs.
* @note Should migrate this from file (fov.dat) to using the user sqlite database
- *@author Jasem Mutlaq
- *@version 1.0
-*/
+ * @author Jasem Mutlaq
+ * @version 1.0
+ */
class FOVManager
{
public:
/** @short Read list of FOVs from "fov.dat" */
static const QList<FOV *> &readFOVs();
+ /** @short Release the FOV cache */
+ static void releaseCache();
static void addFOV(FOV *newFOV)
{
Q_ASSERT(newFOV);
@@ -151,5 +155,3 @@ class FOVManager
static QList<FOV *> m_FOVs;
};
-
-#endif
diff --git a/kstars/auxiliary/imageviewer.cpp b/kstars/auxiliary/imageviewer.cpp
index abf9e2a..a7ddb38 100644
--- a/kstars/auxiliary/imageviewer.cpp
+++ b/kstars/auxiliary/imageviewer.cpp
@@ -33,6 +33,7 @@
#include <QDebug>
#include <QFileDialog>
#include <QStatusBar>
+#include <QTemporaryFile>
#ifndef KSTARS_LITE
#include <KMessageBox>
diff --git a/kstars/indi/drivermanager.cpp b/kstars/indi/drivermanager.cpp
index d0fa0a4..ec87651 100644
--- a/kstars/indi/drivermanager.cpp
+++ b/kstars/indi/drivermanager.cpp
@@ -8,20 +8,22 @@
*/
-#include <basedevice.h>
+#include "drivermanager.h"
-#include <QRadioButton>
-#include <QFile>
-#include <QDir>
-#include <QTextStream>
-#include <QTreeWidget>
-#include <QIcon>
-#include <QDialog>
-#include <QStandardPaths>
-#include <QAction>
-#include <QMenu>
-#include <QPushButton>
-#include <QTcpServer>
+#include "config-kstars.h"
+
+#include "clientmanager.h"
+#include "driverinfo.h"
+#include "guimanager.h"
+#include "indilistener.h"
+#include "kspaths.h"
+#include "kstarsdata.h"
+#include "Options.h"
+#include "servermanager.h"
+#include "ui_indihostconf.h"
+#include "auxiliary/ksnotification.h"
+
+#include <basedevice.h>
#ifndef KSTARS_LITE
#include <KMessageBox>
@@ -29,24 +31,7 @@
#include <KNotifications/KNotification>
#endif
-#include "oal/log.h"
-#include "oal/scope.h"
-
-#include "ui_indihostconf.h"
-#include "servermanager.h"
-#include "guimanager.h"
-#include "Options.h"
-#include "drivermanager.h"
-#include "driverinfo.h"
-
-#include "auxiliary/ksnotification.h"
-#include "kstars.h"
-#include "kstarsdata.h"
-#include "ksutils.h"
-#include "indilistener.h"
-#include "kspaths.h"
-
-#include <config-kstars.h>
+#include <QTcpServer>
#define INDI_MAX_TRIES 2
#define ERRMSG_SIZE 1024
diff --git a/kstars/indi/drivermanager.h b/kstars/indi/drivermanager.h
index 4bd870d..6c8d96e 100644
--- a/kstars/indi/drivermanager.h
+++ b/kstars/indi/drivermanager.h
@@ -8,21 +8,21 @@
*/
-#ifndef DriverManager_H_
-#define DriverManager_H_
+#pragma once
+
+#include "indicommon.h"
+#include "indidbus.h"
+#include "ui_drivermanager.h"
-#include <QFrame>
-#include <QHash>
-#include <QStringList>
#include <QDialog>
+#include <QFrame>
+#include <QIcon>
+#include <QString>
#include <lilxml.h>
-#include "ui_drivermanager.h"
-#include "indidbus.h"
-#include "indicommon.h"
+class QStringList;
class QTreeWidgetItem;
-class QIcon;
class DriverManager;
class ServerManager;
@@ -184,5 +184,3 @@ class DriverManager : public QDialog
void newCCD();
*/
};
-
-#endif
diff --git a/kstars/indi/guimanager.cpp b/kstars/indi/guimanager.cpp
index 88248bf..2fe663c 100644
--- a/kstars/indi/guimanager.cpp
+++ b/kstars/indi/guimanager.cpp
@@ -7,39 +7,21 @@
version 2 of the License, or (at your option) any later version.
*/
-#include <stdlib.h>
-
-#include <QLineEdit>
-#include <QTextEdit>
-#include <QFrame>
-#include <QCheckBox>
-#include <QLabel>
-#include <QPushButton>
-#include <QLayout>
-#include <QSocketNotifier>
-#include <QDateTime>
-#include <QSplitter>
-#include <QLocale>
-#include <KMessageBox>
-#include <QDebug>
-#include <QComboBox>
-#include <QDialog>
-#include <QTabWidget>
-
-#include <KLed>
-#include <KActionCollection>
-
-#include <basedevice.h>
+#include "guimanager.h"
+#include "clientmanager.h"
+#include "deviceinfo.h"
+#include "indidevice.h"
+#include "kstars.h"
+#include "Options.h"
#include "fitsviewer/fitsviewer.h"
-#include "kstars.h"
-#include "indidevice.h"
-#include "guimanager.h"
-#include "driverinfo.h"
-#include "deviceinfo.h"
+#include <KActionCollection>
+#include <KMessageBox>
-#include "Options.h"
+#include <QSplitter>
+#include <QTextEdit>
+#include <QThread>
extern const char *libindi_strings_context;
diff --git a/kstars/indi/guimanager.h b/kstars/indi/guimanager.h
index 17624a0..3697b22 100644
--- a/kstars/indi/guimanager.h
+++ b/kstars/indi/guimanager.h
@@ -7,33 +7,24 @@
version 2 of the License, or (at your option) any later version.
*/
-#ifndef GUIMANAGER_H
-#define GUIMANAGER_H
+#pragma once
-#include <QGridLayout>
-#include <QFrame>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QVBoxLayout>
-#include <QTabWidget>
-#include <QPointer>
+#include <QList>
+#include <QWidget>
-#include <indibase.h>
-
-#include "clientmanager.h"
-
-class QLabel;
-class QHBoxLayout;
-class QVBoxLayout;
-class QFrame;
+class QCloseEvent;
+class QHideEvent;
+class QPushButton;
+class QShowEvent;
class QString;
class QTabWidget;
-class QGridLayout;
-class QPushButton;
-class FITSViewer;
+class QVBoxLayout;
class INDI_D;
+class ClientManager;
+class DeviceInfo;
+
/**
* @class GUIManager
* GUIManager creates the INDI Control Panel upon receiving a new device. Each device is displayed
@@ -66,8 +57,8 @@ class GUIManager : public QWidget
private:
/*****************************************************************
- * GUI stuff
- ******************************************************************/
+ * GUI stuff
+ ******************************************************************/
QVBoxLayout *mainLayout;
QTabWidget *mainTabWidget;
QPushButton *clearB;
@@ -84,5 +75,3 @@ class GUIManager : public QWidget
void buildDevice(DeviceInfo *di);
void removeDevice(DeviceInfo *di);
};
-
-#endif // GUIMANAGER_H
diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index 2f412aa..6ffe3ca 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -17,62 +17,43 @@
#include "kstars.h"
-#include <QApplication>
-#include <QDockWidget>
-#include <QDebug>
-#include <QStatusBar>
-#include <QIcon>
-#include <QMenu>
+#include "config-kstars.h"
+#include "version.h"
-#ifdef Q_OS_WIN
-#include <QProcess>
-#endif
-
-#include <KLocalizedString>
-#include <KActionCollection>
-#include <KToolBar>
-#include <KSharedConfig>
-
-#include "Options.h"
+#include "fov.h"
+#include "kactionmenu.h"
+#include "kstarsadaptor.h"
#include "kstarsdata.h"
#include "kstarssplash.h"
-#include "kactionmenu.h"
+#include "observinglist.h"
+#include "Options.h"
#include "skymap.h"
-#include "ksutils.h"
-#include "simclock.h"
-#include "fov.h"
+#include "skyqpainter.h"
+#include "texturemanager.h"
#include "dialogs/finddialog.h"
#include "dialogs/exportimagedialog.h"
-#include "observinglist.h"
-//#include "whatsinteresting/wiview.h"
-
-// For profiling only
-#include "auxiliary/dms.h"
-#include "skyobjects/skypoint.h"
-
-#include "kstarsadaptor.h"
-
-#include <config-kstars.h>
-#include <version.h>
-
+#include "skycomponents/starblockfactory.h"
#ifdef HAVE_INDI
+#include "ekos/ekosmanager.h"
#include "indi/drivermanager.h"
#include "indi/guimanager.h"
-#include "ekos/ekosmanager.h"
#endif
#ifdef HAVE_CFITSIO
#include "fitsviewer/fitsviewer.h"
#endif
-KStars *KStars::pinstance = 0;
+#include <KActionCollection>
+#include <KToolBar>
+
+#ifdef Q_OS_WIN
+#include <QProcess>
+#endif
+
+KStars *KStars::pinstance = nullptr;
KStars::KStars(bool doSplash, bool clockrun, const QString &startdate)
- : KXmlGuiWindow(), colorActionMenu(0), fovActionMenu(0), m_KStarsData(0), m_SkyMap(0), m_TimeStepBox(0),
- m_ExportImageDialog(0), m_PrintingWizard(0), m_FindDialog(0), m_AstroCalc(0), m_AltVsTime(0), m_SkyCalendar(0),
- m_ScriptBuilder(0), m_PlanetViewer(0), m_WUTDialog(0), /*m_JMoonTool(0),*/ m_MoonPhaseTool(0), m_FlagManager(0),
- m_HorizonManager(0), m_EyepieceView(0), m_addDSODialog(0), m_WIView(0), m_ObsConditions(0), m_wiDock(0),
- DialogIsObsolete(false), StartClockRunning(clockrun), StartDateString(startdate)
+ : KXmlGuiWindow(), StartClockRunning(clockrun), StartDateString(startdate)
{
setWindowTitle(i18n("KStars"));
@@ -250,19 +231,9 @@ KStars *KStars::createInstance(bool doSplash, bool clockrun, const QString &star
KStars::~KStars()
{
+ releaseResources();
Q_ASSERT(pinstance);
-
- delete m_KStarsData;
- pinstance = 0;
-
-#ifdef HAVE_INDI
- delete m_EkosManager;
- GUIManager::Instance()->close();
-#endif
-
- QSqlDatabase::removeDatabase("userdb");
- QSqlDatabase::removeDatabase("skydb");
-
+ pinstance = nullptr;
#ifdef PROFILE_COORDINATE_CONVERSION
qDebug() << "Spent " << SkyPoint::cpuTime_EqToHz << " seconds in " << SkyPoint::eqToHzCalls
<< " calls to SkyPoint::EquatorialToHorizontal, for an average of "
@@ -292,6 +263,25 @@ KStars::~KStars()
#endif
}
+void KStars::releaseResources()
+{
+ delete m_KStarsData;
+ m_KStarsData = nullptr;
+ delete StarBlockFactory::Instance();
+ TextureManager::Release();
+ SkyQPainter::releaseImageCache();
+ FOVManager::releaseCache();
+
+#ifdef HAVE_INDI
+ delete m_EkosManager;
+ m_EkosManager = nullptr;
+// GUIManager::Instance()->close();
+#endif
+
+ QSqlDatabase::removeDatabase("userdb");
+ QSqlDatabase::removeDatabase("skydb");
+}
+
void KStars::clearCachedFindDialog()
{
if (m_FindDialog) // dialog is cached
diff --git a/kstars/kstars.h b/kstars/kstars.h
index e0f662d..78b1ef8 100644
--- a/kstars/kstars.h
+++ b/kstars/kstars.h
@@ -14,19 +14,23 @@
* *
***************************************************************************/
-#ifndef KSTARS_H_
-#define KSTARS_H_
+#pragma once
-#include <QtDBus/QtDBus>
-#include <kxmlguiwindow.h>
-
-#include <config-kstars.h>
-#include <QDockWidget>
+#include "config-kstars.h"
#include "oal/equipmentwriter.h"
#include "oal/observeradd.h"
+#include <kxmlguiwindow.h>
+
+#include <QDockWidget>
+#include <QtDBus/qdbusmacros.h>
+#ifdef HAVE_CFITSIO
+#include <QPointer>
+#endif
+
// forward declaration is enough. We only need pointers
+class QDockWidget;
class QPalette;
class KActionMenu;
@@ -123,9 +127,12 @@ class KStars : public KXmlGuiWindow
/** @return a pointer to the instance of this class */
inline static KStars *Instance() { return pinstance; }
- /** Destructor. Synchs config file. Deletes objects. */
+ /** Destructor. */
virtual ~KStars();
+ /** Syncs config file. Deletes objects. */
+ void releaseResources();
+
/** @return pointer to KStarsData object which contains application data. */
inline KStarsData *data() const { return m_KStarsData; }
@@ -485,7 +492,7 @@ class KStars : public KXmlGuiWindow
/** action slot: open KStars setup wizard */
void slotWizard();
- void updateLocationFromWizard(GeoLocation geo);
+ void updateLocationFromWizard(const GeoLocation& geo);
WIView *wiView() { return m_WIView; }
@@ -674,35 +681,35 @@ class KStars : public KXmlGuiWindow
/** Build the KStars main window */
void buildGUI();
- KActionMenu *colorActionMenu, *fovActionMenu;
+ KActionMenu *colorActionMenu { nullptr };
+ KActionMenu *fovActionMenu { nullptr };
- KStarsData *m_KStarsData;
- SkyMap *m_SkyMap;
+ KStarsData *m_KStarsData { nullptr };
+ SkyMap *m_SkyMap { nullptr };
// Widgets
- TimeStepBox *m_TimeStepBox;
+ TimeStepBox *m_TimeStepBox { nullptr };
// Dialogs & Tools
// File Menu
- ExportImageDialog *m_ExportImageDialog;
- PrintingWizard *m_PrintingWizard;
+ ExportImageDialog *m_ExportImageDialog { nullptr };
+ PrintingWizard *m_PrintingWizard { nullptr };
// Pointing Menu
- FindDialog *m_FindDialog;
+ FindDialog *m_FindDialog { nullptr };
// Tool Menu
- AstroCalc *m_AstroCalc;
- AltVsTime *m_AltVsTime;
- SkyCalendar *m_SkyCalendar;
- ScriptBuilder *m_ScriptBuilder;
- PlanetViewer *m_PlanetViewer;
- WUTDialog *m_WUTDialog;
- // JMoonTool *m_JMoonTool;
- MoonPhaseTool *m_MoonPhaseTool;
- FlagManager *m_FlagManager;
- HorizonManager *m_HorizonManager;
- EyepieceField *m_EyepieceView;
+ AstroCalc *m_AstroCalc { nullptr };
+ AltVsTime *m_AltVsTime { nullptr };
+ SkyCalendar *m_SkyCalendar { nullptr };
+ ScriptBuilder *m_ScriptBuilder { nullptr };
+ PlanetViewer *m_PlanetViewer { nullptr };
+ WUTDialog *m_WUTDialog { nullptr };
+ // JMoonTool *m_JMoonTool { nullptr };
+ FlagManager *m_FlagManager { nullptr };
+ HorizonManager *m_HorizonManager { nullptr };
+ EyepieceField *m_EyepieceView { nullptr };
#ifdef HAVE_CFITSIO
QPointer<FITSViewer> m_GenericFITSViewer;
QList<FITSViewer *> m_FITSViewers;
@@ -712,38 +719,37 @@ class KStars : public KXmlGuiWindow
QPointer<EkosManager> m_EkosManager;
#endif
- AddDeepSkyObject *m_addDSODialog;
+ AddDeepSkyObject *m_addDSODialog { nullptr };
// FIXME Port to QML2
//#if 0
- WIView *m_WIView = nullptr;
- WILPSettings *m_WISettings;
- WIEquipSettings *m_WIEquipmentSettings;
- ObsConditions *m_ObsConditions;
- QDockWidget *m_wiDock;
+ WIView *m_WIView { nullptr };
+ WILPSettings *m_WISettings { nullptr };
+ WIEquipSettings *m_WIEquipmentSettings { nullptr };
+ ObsConditions *m_ObsConditions { nullptr };
+ QDockWidget *m_wiDock { nullptr };
//#endif
- QActionGroup *projectionGroup, *cschemeGroup;
+ QActionGroup *projectionGroup { nullptr };
+ QActionGroup *cschemeGroup { nullptr };
- bool DialogIsObsolete;
- bool StartClockRunning;
+ bool DialogIsObsolete { false };
+ bool StartClockRunning { false };
QString StartDateString;
QLabel AltAzField, RADecField, J2000RADecField;
QPalette OriginalPalette, DarkPalette;
- OpsCatalog *opcatalog;
- OpsGuides *opguides;
- OpsSolarSystem *opsolsys;
- OpsSatellites *opssatellites;
- OpsSupernovae *opssupernovae;
- OpsColors *opcolors;
- OpsAdvanced *opadvanced;
- OpsINDI *opsindi;
- OpsEkos *opsekos;
- OpsFITS *opsfits;
+ OpsCatalog *opcatalog { nullptr };
+ OpsGuides *opguides { nullptr };
+ OpsSolarSystem *opsolsys { nullptr };
+ OpsSatellites *opssatellites { nullptr };
+ OpsSupernovae *opssupernovae { nullptr };
+ OpsColors *opcolors { nullptr };
+ OpsAdvanced *opadvanced { nullptr };
+ OpsINDI *opsindi { nullptr };
+ OpsEkos *opsekos { nullptr };
+ OpsFITS *opsfits { nullptr };
#ifdef HAVE_XPLANET
- OpsXplanet *opsxplanet;
+ OpsXplanet *opsxplanet { nullptr };
#endif
};
-
-#endif
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index dce9e32..74121e1 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -402,7 +402,7 @@ void KStars::slotWizard()
delete wizard;
}
-void KStars::updateLocationFromWizard(GeoLocation geo)
+void KStars::updateLocationFromWizard(const GeoLocation& geo)
{
data()->setLocation(geo);
// adjust local time to keep UT the same.
diff --git a/kstars/kstarsdata.cpp b/kstars/kstarsdata.cpp
index 8cb8989..bd99c67 100644
--- a/kstars/kstarsdata.cpp
+++ b/kstars/kstarsdata.cpp
@@ -17,39 +17,25 @@
#include "kstarsdata.h"
-#include <QApplication>
-#include <QFileInfo>
-#include <QSet>
-#include <QTextStream>
-#include <QDebug>
-#include <QStandardPaths>
-#include <QtConcurrent>
-#ifndef KSTARS_LITE
-#include <KMessageBox>
-#endif
-#include <KLocalizedString>
-
-#include "Options.h"
-#include "dms.h"
#include "fov.h"
#include "ksutils.h"
-#include "ksfilereader.h"
-#include "ksnumbers.h"
+#include "Options.h"
#include "auxiliary/kspaths.h"
-#include "skyobjects/skyobject.h"
#include "skycomponents/supernovaecomponent.h"
#include "skycomponents/skymapcomposite.h"
-#include "simclock.h"
-#include "timezonerule.h"
#ifndef KSTARS_LITE
-#include "skymap.h"
-#include "oal/execute.h"
#include "imageexporter.h"
#include "observinglist.h"
+#include "skymap.h"
#include "dialogs/detaildialog.h"
+#include "oal/execute.h"
+#endif
+
+#ifndef KSTARS_LITE
+#include <KMessageBox>
#endif
-#include <config-kstars.h>
+#include <QtConcurrent>
namespace
{
@@ -117,16 +103,13 @@ KStarsData *KStarsData::Create()
}
KStarsData::KStarsData()
- : m_SkyComposite(0), m_Geo(dms(0), dms(0)), m_ksuserdb(), m_catalogdb(),
-#ifndef KSTARS_LITE
- m_ObservingList(0), m_Execute(0), m_ImageExporter(0),
-#endif
+ : m_Geo(dms(0), dms(0)), m_ksuserdb(), m_catalogdb(),
temporaryTrail(false),
//locale( new KLocale( "kstars" ) ),
m_preUpdateID(0), m_updateID(0), m_preUpdateNumID(0), m_updateNumID(0), m_preUpdateNum(J2000), m_updateNum(J2000)
{
#ifndef KSTARS_LITE
- m_LogObject = new OAL::Log;
+ m_LogObject.reset(new OAL::Log);
#endif
// at startup times run forward
setTimeDirection(0.0);
@@ -137,16 +120,12 @@ KStarsData::~KStarsData()
Q_ASSERT(pinstance);
//delete locale;
-#ifndef KSTARS_LITE
- delete m_LogObject;
- delete m_Execute;
- delete m_ObservingList;
- delete m_ImageExporter;
-#endif
qDeleteAll(geoList);
+ geoList.clear();
qDeleteAll(ADVtreeList);
+ ADVtreeList.clear();
- pinstance = 0;
+ pinstance = nullptr;
}
bool KStarsData::initialize()
@@ -176,7 +155,7 @@ bool KStarsData::initialize()
//Initialize SkyMapComposite//
emit progressText(i18n("Loading sky objects"));
- m_SkyComposite = new SkyMapComposite(0);
+ m_SkyComposite.reset(new SkyMapComposite());
//Load Image URLs//
//#ifndef Q_OS_ANDROID
//On Android these 2 calls produce segfault. WARNING
@@ -1448,18 +1427,18 @@ void KStarsData::syncFOV()
// FIXME: Why does KStarsData store the Execute instance??? -- asimha
Execute *KStarsData::executeSession()
{
- if (!m_Execute)
- m_Execute = new Execute();
+ if (!m_Execute.get())
+ m_Execute.reset(new Execute());
- return m_Execute;
+ return m_Execute.get();
}
// FIXME: Why does KStarsData store the ImageExporer instance??? KStarsData is supposed to work with no reference to KStars -- asimha
ImageExporter *KStarsData::imageExporter()
{
- if (!m_ImageExporter)
- m_ImageExporter = new ImageExporter(KStars::Instance());
+ if (!m_ImageExporter.get())
+ m_ImageExporter.reset(new ImageExporter(KStars::Instance()));
- return m_ImageExporter;
+ return m_ImageExporter.get();
}
#endif
diff --git a/kstars/kstarsdata.h b/kstars/kstarsdata.h
index 042eca5..24a0c16 100644
--- a/kstars/kstarsdata.h
+++ b/kstars/kstarsdata.h
@@ -15,27 +15,27 @@
* *
***************************************************************************/
-#ifndef KSTARSDATA_H_
-#define KSTARSDATA_H_
+#pragma once
-#include <iostream>
-
-#include "ksnumbers.h"
-#include "ksuserdb.h"
#include "catalogdb.h"
-
-#include <QList>
-#include <QMap>
-#include <QKeySequence>
-
-#include "geolocation.h"
#include "colorscheme.h"
+#include "geolocation.h"
+#include "ksnumbers.h"
#include "kstarsdatetime.h"
+#include "ksuserdb.h"
#include "simclock.h"
#ifndef KSTARS_LITE
#include "oal/oal.h"
#include "oal/log.h"
#endif
+
+#include <QList>
+#include <QMap>
+#include <QKeySequence>
+
+#include <iostream>
+#include <memory>
+
#define MINZOOM 250.
#define MAXZOOM 5000000.
#define DEFAULTZOOM 2000.
@@ -44,13 +44,11 @@
class QFile;
-class dms;
+class FOV;
class SkyMap;
class SkyMapComposite;
class SkyObject;
-class FOV;
class ObservingList;
-
class TimeZoneRule;
#ifdef KSTARS_LITE
@@ -65,21 +63,22 @@ struct ADVTreeData
struct ADVTreeData;
#endif
-/** @class KStarsData
- *KStarsData is the backbone of KStars. It contains all the data used by KStars,
- *including the SkyMapComposite that contains all items in the skymap
- *(stars, deep-sky objects, planets, constellations, etc). Other kinds of data
- *are stored here as well: the geographic locations, the timezone rules, etc.
- *
- *@author Heiko Evermann
- *@version 1.0
- */
+/**
+ * @class KStarsData
+ * KStarsData is the backbone of KStars. It contains all the data used by KStars,
+ * including the SkyMapComposite that contains all items in the skymap
+ * (stars, deep-sky objects, planets, constellations, etc). Other kinds of data
+ * are stored here as well: the geographic locations, the timezone rules, etc.
+ *
+ * @author Heiko Evermann
+ * @version 1.0
+ */
class KStarsData : public QObject
{
Q_OBJECT
protected:
- /**Constructor. */
+ /** Constructor. */
KStarsData();
public:
@@ -96,46 +95,52 @@ class KStarsData : public QObject
static inline KStarsData *Instance() { return pinstance; }
- /** Initialize KStarsData while running splash screen.
- * @return true on success.
- */
+ /**
+ * Initialize KStarsData while running splash screen.
+ * @return true on success.
+ */
bool initialize();
- /**Destructor. Delete data objects. */
+ /** Destructor. Delete data objects. */
virtual ~KStarsData();
- /** Set the NextDSTChange member.
- * Need this accessor because I could not make KStars::privatedata a friend
- * class for some reason...:/
- */
+ /**
+ * Set the NextDSTChange member.
+ * Need this accessor because I could not make KStars::privatedata a friend
+ * class for some reason...:/
+ */
void setNextDSTChange(const KStarsDateTime &dt) { NextDSTChange = dt; }
- /** Returns true if time is running forward else false. Used by KStars to prevent
- * double calculations of daylight saving change time.
- */
+ /**
+ * Returns true if time is running forward else false. Used by KStars to prevent
+ * double calculations of daylight saving change time.
+ */
bool isTimeRunningForward() const { return TimeRunsForward; }
/** @return pointer to the localization (KLocale) object */
//KLocale *getLocale() { return locale; }
- /** @short Find object by name.
- * @param name Object name to find
- * @return pointer to SkyObject matching this name
- */
+ /**
+ * @short Find object by name.
+ * @param name Object name to find
+ * @return pointer to SkyObject matching this name
+ */
SkyObject *objectNamed(const QString &name);
- /**The Sky is updated more frequently than the moon, which is updated more frequently
- * than the planets. The date of the last update for each category is recorded so we
- * know when we need to do it again (see KStars::updateTime()).
- * Initializing these to -1000000.0 ensures they will be updated immediately
- * on the first call to KStars::updateTime().
- */
+ /**
+ * The Sky is updated more frequently than the moon, which is updated more frequently
+ * than the planets. The date of the last update for each category is recorded so we
+ * know when we need to do it again (see KStars::updateTime()).
+ * Initializing these to -1000000.0 ensures they will be updated immediately
+ * on the first call to KStars::updateTime().
+ */
void setFullTimeUpdate();
- /**change the current simulation date/time to the KStarsDateTime argument.
- * Specified DateTime is always universal time.
- * @param newDate the DateTime to set.
- */
+ /**
+ * Change the current simulation date/time to the KStarsDateTime argument.
+ * Specified DateTime is always universal time.
+ * @param newDate the DateTime to set.
+ */
void changeDateTime(const KStarsDateTime &newDate);
/** @return pointer to the current simulation local time */
@@ -148,7 +153,7 @@ class KStarsData : public QObject
void syncLST();
/** @return pointer to SkyComposite */
- SkyMapComposite *skyComposite() { return m_SkyComposite; }
+ SkyMapComposite *skyComposite() { return m_SkyComposite.get(); }
/** @return pointer to the ColorScheme object */
ColorScheme *colorScheme() { return &CScheme; }
@@ -177,9 +182,10 @@ class KStarsData : public QObject
GeoLocation *locationNamed(const QString &city, const QString &province = QString(),
const QString &country = QString());
- /**Set the GeoLocation according to the argument.
- * @param l reference to the new GeoLocation
- */
+ /**
+ * Set the GeoLocation according to the argument.
+ * @param l reference to the new GeoLocation
+ */
void setLocation(const GeoLocation &l);
/** Set the GeoLocation according to the values stored in the configuration file. */
@@ -191,41 +197,43 @@ class KStarsData : public QObject
/** @return whether the next Focus change will omit the slewing animation. */
bool snapNextFocus() const { return snapToFocus; }
- /**Disable or re-enable the slewing animation for the next Focus change.
- * @note If the user has turned off all animated slewing, setSnapNextFocus(false)
- * will *NOT* enable animation on the next slew. A false argument would only
- * be used if you have previously called setSnapNextFocus(true), but then decided
- * you didn't want that after all. In other words, it's extremely unlikely you'd
- * ever want to use setSnapNextFocus(false).
- * @param b when true (the default), the next Focus change will omit the slewing
- * animation.
- */
+ /**
+ * Disable or re-enable the slewing animation for the next Focus change.
+ * @note If the user has turned off all animated slewing, setSnapNextFocus(false)
+ * will *NOT* enable animation on the next slew. A false argument would only
+ * be used if you have previously called setSnapNextFocus(true), but then decided
+ * you didn't want that after all. In other words, it's extremely unlikely you'd
+ * ever want to use setSnapNextFocus(false).
+ * @param b when true (the default), the next Focus change will omit the slewing
+ * animation.
+ */
void setSnapNextFocus(bool b = true) { snapToFocus = b; }
- /**Execute a script. This function actually duplicates the DCOP functionality
- * for those cases when invoking DCOP is not practical (i.e., when preparing
- * a sky image in command-line dump mode).
- * @param name the filename of the script to "execute".
- * @param map pointer to the SkyMap object.
- * @return true if the script was successfully parsed.
- */
+ /**
+ * Execute a script. This function actually duplicates the DCOP functionality
+ * for those cases when invoking DCOP is not practical (i.e., when preparing
+ * a sky image in command-line dump mode).
+ * @param name the filename of the script to "execute".
+ * @param map pointer to the SkyMap object.
+ * @return true if the script was successfully parsed.
+ */
bool executeScript(const QString &name, SkyMap *map);
/** Synchronize list of visible FOVs and list of selected FOVs in Options */
void syncFOV();
/**
- *@return the list of visible FOVs
- */
+ * @return the list of visible FOVs
+ */
inline const QList<FOV *> getVisibleFOVs() const { return visibleFOVs; }
/**
- *@return the list of available FOVs
- */
+ * @return the list of available FOVs
+ */
inline const QList<FOV *> getAvailableFOVs() const { return availFOVs; }
#ifndef KSTARS_LITE
/** Return log object */
- OAL::Log *logObject() { return m_LogObject; }
+ OAL::Log *logObject() { return m_LogObject.get(); }
/** Return ADV Tree */
QList<ADVTreeData *> avdTree() { return ADVtreeList; }
@@ -261,92 +269,100 @@ class KStarsData : public QObject
/** @short send a message to the console*/
void slotConsoleMessage(QString s) { std::cout << (const char *)(s.toLocal8Bit()) << std::endl; }
- /**Update the Simulation Clock. Update positions of Planets. Update
- * Alt/Az coordinates of objects. Update precession.
- * emit the skyUpdate() signal so that SkyMap / whatever draws the sky can update itself
- *
- * This is ugly.
- * It _will_ change!
- * (JH:)hey, it's much less ugly now...can we lose the comment yet? :p
- */
+ /**
+ * Update the Simulation Clock. Update positions of Planets. Update
+ * Alt/Az coordinates of objects. Update precession.
+ * emit the skyUpdate() signal so that SkyMap / whatever draws the sky can update itself
+ *
+ * This is ugly.
+ * It _will_ change!
+ * (JH:)hey, it's much less ugly now...can we lose the comment yet? :p
+ */
void updateTime(GeoLocation *geo, const bool automaticDSTchange = true);
- /**Sets the direction of time and stores it in bool TimeRunForwards. If scale >= 0
- * time is running forward else time runs backward. We need this to calculate just
- * one daylight saving change time (previous or next DST change).
- */
+ /**
+ * Sets the direction of time and stores it in bool TimeRunForwards. If scale >= 0
+ * time is running forward else time runs backward. We need this to calculate just
+ * one daylight saving change time (previous or next DST change).
+ */
void setTimeDirection(float scale);
private:
- /**Populate list of geographic locations from "citydb.sqlite" database. Also check for custom
- * locations file "mycitydb.sqlite" database, but don't require it. Each line in the file
- * provides the information required to create one GeoLocation object.
- * @short Fill list of geographic locations from file(s)
- * @return true if at least one city read successfully.
- * @see KStarsData::processCity()
- */
+ /**
+ * Populate list of geographic locations from "citydb.sqlite" database. Also check for custom
+ * locations file "mycitydb.sqlite" database, but don't require it. Each line in the file
+ * provides the information required to create one GeoLocation object.
+ * @short Fill list of geographic locations from file(s)
+ * @return true if at least one city read successfully.
+ * @see KStarsData::processCity()
+ */
bool readCityData();
- /**Read the data file that contains daylight savings time rules. */
+ /** Read the data file that contains daylight savings time rules. */
bool readTimeZoneRulebook();
//TODO JM: ADV tree should use XML instead
- /**Read Advanced interface structure to be used later to construct the list view in
- * the advanced tab in the Detail Dialog.
- * @li KSLABEL designates a top-level parent label
- * @li KSINTERFACE designates a common URL interface for several objects
- * @li END designates the end of a sub tree structure
- * @short read online database lookup structure.
- * @return true if data is successfully read.
- */
+ /**
+ * Read Advanced interface structure to be used later to construct the list view in
+ * the advanced tab in the Detail Dialog.
+ * @li KSLABEL designates a top-level parent label
+ * @li KSINTERFACE designates a common URL interface for several objects
+ * @li END designates the end of a sub tree structure
+ * @short read online database lookup structure.
+ * @return true if data is successfully read.
+ */
bool readADVTreeData();
- /**Read INDI hosts from an XML file*/
+ /** Read INDI hosts from an XML file */
bool readINDIHosts();
//TODO JM: Use XML instead; The logger should have more features
// that allow users to enter details about their observation logs
// objects observed, eye pieces, telescope, conditions, mag..etc
- /** @short read user logs.
- *
- * Read user logs. The log file is formatted as following:
- * @li KSLABEL designates the beginning of a log
- * @li KSLogEnd designates the end of a log.
- *
- * @return true if data is successfully read.
- */
+ /**
+ * @short read user logs.
+ *
+ * Read user logs. The log file is formatted as following:
+ * @li KSLABEL designates the beginning of a log
+ * @li KSLogEnd designates the end of a log.
+ *
+ * @return true if data is successfully read.
+ */
bool readUserLog();
- /**Read in URLs to be attached to a named object's right-click popup menu. At this
- * point, there is no way to attach URLs to unnamed objects. There are two
- * kinds of URLs, each with its own data file: image links and webpage links. In addition,
- * there may be user-specific versions with custom URLs. Each line contains 3 fields
- * separated by colons (":"). Note that the last field is the URL, and as such it will
- * generally contain a colon itself. Only the first two colons encountered are treated
- * as field separators. The fields are:
- *
- * @li Object name. This must be the "primary" name of the object (the name at the top of the popup menu).
- * @li Menu text. The string that should appear in the popup menu to activate the link.
- * @li URL.
- * @short Read in image and information URLs.
- * @return true if data files were successfully read.
- */
+ /**
+ * Read in URLs to be attached to a named object's right-click popup menu. At this
+ * point, there is no way to attach URLs to unnamed objects. There are two
+ * kinds of URLs, each with its own data file: image links and webpage links. In addition,
+ * there may be user-specific versions with custom URLs. Each line contains 3 fields
+ * separated by colons (":"). Note that the last field is the URL, and as such it will
+ * generally contain a colon itself. Only the first two colons encountered are treated
+ * as field separators. The fields are:
+ *
+ * @li Object name. This must be the "primary" name of the object (the name at the top of the popup menu).
+ * @li Menu text. The string that should appear in the popup menu to activate the link.
+ * @li URL.
+ * @short Read in image and information URLs.
+ * @return true if data files were successfully read.
+ */
bool readURLData(const QString &url, int type = 0, bool deepOnly = false);
- /** @short open a file containing URL links.
- * @param urlfile string representation of the filename to open
- * @param file reference to the QFile object which will be opened to this file.
- * @return true if file successfully opened.
- */
+ /**
+ * @short open a file containing URL links.
+ * @param urlfile string representation of the filename to open
+ * @param file reference to the QFile object which will be opened to this file.
+ * @return true if file successfully opened.
+ */
bool openUrlFile(const QString &urlfile, QFile &file);
- /**Reset local time to new daylight saving time. Use this function if DST has changed.
- * Used by updateTime().
- */
+ /**
+ * Reset local time to new daylight saving time. Use this function if DST has changed.
+ * Used by updateTime().
+ */
void resetToNewDST(GeoLocation *geo, const bool automaticDSTchange);
QList<ADVTreeData *> ADVtreeList;
- SkyMapComposite *m_SkyComposite;
+ std::unique_ptr<SkyMapComposite> m_SkyComposite;
GeoLocation m_Geo;
SimClock Clock;
@@ -355,17 +371,18 @@ class KStarsData : public QObject
CatalogDB m_catalogdb;
ColorScheme CScheme;
#ifndef KSTARS_LITE
- ObservingList *m_ObservingList;
- OAL::Log *m_LogObject;
- Execute *m_Execute;
- ImageExporter *m_ImageExporter;
+ ObservingList* m_ObservingList { nullptr };
+ std::unique_ptr<OAL::Log> m_LogObject;
+ std::unique_ptr<Execute> m_Execute;
+ std::unique_ptr<ImageExporter> m_ImageExporter;
#endif
//EquipmentWriter *m_equipmentWriter;
- bool TimeRunsForward, temporaryTrail;
+ bool TimeRunsForward { false };
+ bool temporaryTrail { false };
// FIXME: Used in SkyMap only. Check!
- bool snapToFocus;
+ bool snapToFocus { false };
//KLocale *locale;
@@ -390,5 +407,3 @@ class KStarsData : public QObject
static KStarsData *pinstance;
};
-
-#endif // KSTARSDATA_H_
diff --git a/kstars/kstarslite/skyitems/deepstaritem.cpp b/kstars/kstarslite/skyitems/deepstaritem.cpp
index c92e678..81e18f5 100644
--- a/kstars/kstarslite/skyitems/deepstaritem.cpp
+++ b/kstars/kstarslite/skyitems/deepstaritem.cpp
@@ -14,20 +14,19 @@
* *
***************************************************************************/
-#include "Options.h"
-#include "projections/projector.h"
-
-#include "skynodes/pointsourcenode.h"
-#include "labelsitem.h"
#include "deepstaritem.h"
#include "deepstarcomponent.h"
-#include "starcomponent.h"
-
-#include "starblockfactory.h"
-#include "skymesh.h"
+#include "labelsitem.h"
+#include "Options.h"
#include "rootnode.h"
-
+#include "skymesh.h"
+#include "starblock.h"
+#include "starblockfactory.h"
+#include "starblocklist.h"
+#include "starcomponent.h"
+#include "projections/projector.h"
+#include "skynodes/pointsourcenode.h"
#include "skynodes/trixelnode.h"
DeepStarItem::DeepStarItem(DeepStarComponent *deepStarComp, RootNode *rootNode)
diff --git a/kstars/kstarslite/skyitems/deepstaritem.h b/kstars/kstarslite/skyitems/deepstaritem.h
index 34a4d2b..a3f6196 100644
--- a/kstars/kstarslite/skyitems/deepstaritem.h
+++ b/kstars/kstarslite/skyitems/deepstaritem.h
@@ -13,11 +13,10 @@
* (at your option) any later version. *
* *
***************************************************************************/
-#ifndef DEEPSTARITEM_H_
-#define DEEPSTARITEM_H_
+
+#pragma once
#include "skyitem.h"
-#include "skyopacitynode.h"
/** @class DeepStarItem
*
@@ -35,29 +34,22 @@ class DeepStarItem : public SkyItem
{
public:
/**
- * @short Constructor. Instantiates nodes for static stars
- * @param deepStarComp - pointer to DeepStarComponent that handles data
- * @param rootNode - parent RootNode that instantiated this object
- */
+ * @short Constructor. Instantiates nodes for static stars
+ * @param deepStarComp - pointer to DeepStarComponent that handles data
+ * @param rootNode - parent RootNode that instantiated this object
+ */
DeepStarItem(DeepStarComponent *deepStarComp, RootNode *rootNode);
/**
- * @short Update positions of deep stars in SkyMapLite
- * In this function we perform almost the same thing as in DeepSkyItem::updateDeepSkyNode() to reduce
- * memory consumption.
- * @see DeepSkyItem::updateDeepSkyNode()
- */
- /**
- * @short updates all trixels that contain stars
- */
+ * @short updates all trixels that contain stars
+ */
virtual void update();
private:
- SkyMesh *m_skyMesh;
- StarBlockFactory *m_StarBlockFactory;
+ SkyMesh *m_skyMesh { nullptr };
+ StarBlockFactory *m_StarBlockFactory { nullptr };
- DeepStarComponent *m_deepStarComp;
+ DeepStarComponent *m_deepStarComp { nullptr };
QVector<StarBlockList *> *m_starBlockList;
- bool m_staticStars;
+ bool m_staticStars { false };
};
-#endif
diff --git a/kstars/kstarslite/skyitems/staritem.cpp b/kstars/kstarslite/skyitems/staritem.cpp
index b625b5f..dd838b0 100644
--- a/kstars/kstarslite/skyitems/staritem.cpp
+++ b/kstars/kstarslite/skyitems/staritem.cpp
@@ -14,27 +14,29 @@
* *
***************************************************************************/
+#include "staritem.h"
+
+#include "deepstaritem.h"
+#include "labelsitem.h"
#include "Options.h"
+#include "rootnode.h"
+#include "skymesh.h"
+#include "skyopacitynode.h"
+#include "starblockfactory.h"
+#include "starcomponent.h"
#include "projections/projector.h"
-
#include "skynodes/pointsourcenode.h"
-#include "labelsitem.h"
-#include "staritem.h"
-#include "deepstaritem.h"
+#include "skynodes/trixelnode.h"
-#include "starcomponent.h"
-#include "starblockfactory.h"
-#include "skymesh.h"
-#include "rootnode.h"
#include <QLinkedList>
-#include "skynodes/trixelnode.h"
StarItem::StarItem(StarComponent *starComp, RootNode *rootNode)
: SkyItem(LabelsItem::label_t::STAR_LABEL, rootNode), m_starComp(starComp), m_stars(new SkyOpacityNode),
m_deepStars(new SkyOpacityNode), m_starLabels(rootNode->labelsItem()->getLabelNode(labelType()))
{
- StarIndex *trixels = m_starComp->m_starIndex;
+ StarIndex *trixels = m_starComp->m_starIndex.get();
+
appendChildNode(m_stars);
//Test
@@ -61,6 +63,7 @@ StarItem::StarItem(StarComponent *starComp, RootNode *rootNode)
QVector<DeepStarComponent *> deepStars = m_starComp->m_DeepStarComponents;
int deepSize = deepStars.size();
+
for (int i = 0; i < deepSize; ++i)
{
DeepStarItem *deepStar = new DeepStarItem(deepStars[i], rootNode);
@@ -157,7 +160,7 @@ void StarItem::update()
QSGNode *firstLabel = m_starLabels->firstChild();
TrixelNode *label = static_cast<TrixelNode *>(firstLabel);
- StarIndex *index = m_starComp->m_starIndex;
+ StarIndex *index = m_starComp->m_starIndex.get();
if (reIndex)
rootNode()->labelsItem()->deleteLabels(labelType());
diff --git a/kstars/kstarslite/skyitems/staritem.h b/kstars/kstarslite/skyitems/staritem.h
index e0fece7..083b6d5 100644
--- a/kstars/kstarslite/skyitems/staritem.h
+++ b/kstars/kstarslite/skyitems/staritem.h
@@ -13,47 +13,47 @@
* (at your option) any later version. *
* *
***************************************************************************/
-#ifndef STARITEM_H_
-#define STARITEM_H_
+
+#pragma once
#include "skyitem.h"
-#include "skyopacitynode.h"
-/** @class StarItem
+/**
+ * @class StarItem
*
- *@short Class that handles Stars
- *@author Artem Fedoskin
- *@version 1.0
+ * @short Class that handles Stars
+ * @author Artem Fedoskin
+ * @version 1.0
*/
-class StarComponent;
class SkyMesh;
+class SkyOpacityNode;
class StarBlockFactory;
+class StarComponent;
class StarItem : public SkyItem
{
public:
/**
- * @short Constructor.
- * @param rootNode parent RootNode that instantiated this object
- */
+ * @short Constructor.
+ * @param rootNode parent RootNode that instantiated this object
+ */
StarItem(StarComponent *starComp, RootNode *rootNode);
/**
- * @short Update positions of nodes that represent stars
- * In this function we perform almost the same thing as in DeepSkyItem::updateDeepSkyNode() to reduce
- * memory consumption.
- * @see DeepSkyItem::updateDeepSkyNode()
- */
+ * @short Update positions of nodes that represent stars
+ * In this function we perform almost the same thing as in DeepSkyItem::updateDeepSkyNode() to reduce
+ * memory consumption.
+ * @see DeepSkyItem::updateDeepSkyNode()
+ */
virtual void update();
private:
- StarComponent *m_starComp;
- SkyMesh *m_skyMesh;
- StarBlockFactory *m_StarBlockFactory;
+ StarComponent *m_starComp { nullptr };
+ SkyMesh *m_skyMesh { nullptr };
+ StarBlockFactory *m_StarBlockFactory { nullptr };
- SkyOpacityNode *m_stars;
- SkyOpacityNode *m_deepStars;
- SkyOpacityNode *m_starLabels;
+ SkyOpacityNode *m_stars { nullptr };
+ SkyOpacityNode *m_deepStars { nullptr };
+ SkyOpacityNode *m_starLabels { nullptr };
};
-#endif
diff --git a/kstars/main.cpp b/kstars/main.cpp
index ccc9ae8..e0453ac 100644
--- a/kstars/main.cpp
+++ b/kstars/main.cpp
@@ -294,7 +294,6 @@ int main(int argc, char *argv[])
QDir writableDir;
writableDir.mkdir(KSPaths::writableLocation(QStandardPaths::GenericDataLocation));
#ifndef KSTARS_LITE
-
KStars::createInstance(true, !parser.isSet("paused"), datestring);
// no session.. just start up normally
@@ -306,12 +305,17 @@ int main(int argc, char *argv[])
foreach (const QString &url, urls)
{
const QUrl u = QUrl::fromUserInput(url, QDir::currentPath());
+
KStars::Instance()->openFITS(u);
}
}
QObject::connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));
+
+ app.exec();
#else
KStarsLite::createInstance(true);
+
+ app.exec();
#endif
- return app.exec();
+ return 0;
}
diff --git a/kstars/oal/log.cpp b/kstars/oal/log.cpp
index 65a453f..27f0f49 100644
--- a/kstars/oal/log.cpp
+++ b/kstars/oal/log.cpp
@@ -28,6 +28,19 @@
#include "kstarsdatetime.h"
#include "observinglist.h"
+OAL::Log::~Log()
+{
+ qDeleteAll(m_targetList);
+ qDeleteAll(m_observerList);
+ qDeleteAll(m_eyepieceList);
+ qDeleteAll(m_lensList);
+ qDeleteAll(m_filterList);
+ qDeleteAll(m_siteList);
+ qDeleteAll(m_sessionList);
+ qDeleteAll(m_scopeList);
+ qDeleteAll(m_observationList);
+}
+
void OAL::Log::writeBegin()
{
output = "";
diff --git a/kstars/oal/log.h b/kstars/oal/log.h
index 3cd758b..208a510 100644
--- a/kstars/oal/log.h
+++ b/kstars/oal/log.h
@@ -46,6 +46,7 @@ class KStars;
class OAL::Log
{
public:
+ ~Log();
QString writeLog(bool native = true);
void writeBegin();
void writeGeoDate();
diff --git a/kstars/printing/foveditordialog.cpp b/kstars/printing/foveditordialog.cpp
index c776afb..4334734 100644
--- a/kstars/printing/foveditordialog.cpp
+++ b/kstars/printing/foveditordialog.cpp
@@ -15,16 +15,18 @@
* *
***************************************************************************/
-#include "kstars.h"
#include "foveditordialog.h"
-#include "printingwizard.h"
-#include <QTemporaryFile>
-#include <QFileDialog>
+#include "kstars.h"
+#include "printingwizard.h"
+#include <KJob>
#include <KMessageBox>
#include <KIO/StoredTransferJob>
-#include <KJob>
+
+#include <QDebug>
+#include <QFileDialog>
+#include <QTemporaryFile>
FovEditorDialogUI::FovEditorDialogUI(QWidget *parent) : QFrame(parent)
{
diff --git a/kstars/printing/foveditordialog.h b/kstars/printing/foveditordialog.h
index 4538c2f..641267e 100644
--- a/kstars/printing/foveditordialog.h
+++ b/kstars/printing/foveditordialog.h
@@ -15,105 +15,103 @@
* *
***************************************************************************/
-#ifndef FOVEDITORDIALOG_H
-#define FOVEDITORDIALOG_H
+#pragma once
#include "ui_foveditordialog.h"
#include <QDialog>
+#include <QFrame>
class PrintingWizard;
/**
- * \class FovEditorDialogUI
- * \brief User interface for FOV Editor Dialog.
- * \author Rafał Kułaga
- */
+ * \class FovEditorDialogUI
+ * \brief User interface for FOV Editor Dialog.
+ * \author Rafał Kułaga
+ */
class FovEditorDialogUI : public QFrame, public Ui::FovEditorDialog
{
Q_OBJECT
public:
/**
- * \brief Constructor.
- */
+ * \brief Constructor.
+ */
explicit FovEditorDialogUI(QWidget *parent = 0);
};
/**
- * \class FovEditorDialog
- * \brief Class representing FOV Editor Dialog which enables user to edit FOV snapshots.
- * \author Rafał Kułaga
- */
+ * \class FovEditorDialog
+ * \brief Class representing FOV Editor Dialog which enables user to edit FOV snapshots.
+ * \author Rafał Kułaga
+ */
class FovEditorDialog : public QDialog
{
Q_OBJECT
public:
/**
- * \brief Constructor.
- */
+ * \brief Constructor.
+ */
explicit FovEditorDialog(PrintingWizard *wizard, QWidget *parent = 0);
private slots:
/**
- * \brief Slot: switch to next FOV snapshot.
- */
+ * \brief Slot: switch to next FOV snapshot.
+ */
void slotNextFov();
/**
- * \brief Slot: switch to previous FOV snapshot.
- */
+ * \brief Slot: switch to previous FOV snapshot.
+ */
void slotPreviousFov();
/**
- * \brief Slot: recapture current FOV snapshot.
- */
+ * \brief Slot: recapture current FOV snapshot.
+ */
void slotCaptureAgain();
/**
- * \brief Slot: delete current FOV snapshot.
- */
+ * \brief Slot: delete current FOV snapshot.
+ */
void slotDelete();
/**
- * \brief Slot: save description of the current FOV snapshot.
- */
+ * \brief Slot: save description of the current FOV snapshot.
+ */
void slotSaveDescription();
/**
- * \brief Slot: open "Save file" dialog to choose file name and format to save image.
- */
+ * \brief Slot: open "Save file" dialog to choose file name and format to save image.
+ */
void slotSaveImage();
private:
/**
- * \brief Setup widget properties.
- */
+ * \brief Setup widget properties.
+ */
void setupWidgets();
/**
- * \brief Setup signal-slot connections.
- */
+ * \brief Setup signal-slot connections.
+ */
void setupConnections();
/**
- * \brief Update buttons.
- */
+ * \brief Update buttons.
+ */
void updateButtons();
/**
- * \brief Update image description.
- */
+ * \brief Update image description.
+ */
void updateDescriptions();
/**
- * \brief Update FOV image.
- */
+ * \brief Update FOV image.
+ */
void updateFovImage();
- PrintingWizard *m_ParentWizard;
- FovEditorDialogUI *m_EditorUi;
+ PrintingWizard *m_ParentWizard { nullptr };
+ FovEditorDialogUI *m_EditorUi { nullptr };
- int m_CurrentIndex;
+ int m_CurrentIndex { 0 };
};
-
-#endif // FOVEDITORDIALOG_H
diff --git a/kstars/projections/projector.h b/kstars/projections/projector.h
index 3b8e8b4..2cf4fa6 100644
--- a/kstars/projections/projector.h
+++ b/kstars/projections/projector.h
@@ -282,14 +282,15 @@ class Projector
*/
static SkyPoint pointAt(double az);
- KStarsData *m_data;
+ KStarsData *m_data { nullptr };
ViewParams m_vp;
- double m_sinY0, m_cosY0;
- double m_fov;
+ double m_sinY0 { 0 };
+ double m_cosY0 { 0 };
+ double m_fov { 0 };
QPolygonF m_clipPolygon;
private:
//Used by CheckVisibility
- double m_xrange;
- bool m_isPoleVisible;
+ double m_xrange { 0 };
+ bool m_isPoleVisible { false };
};
diff --git a/kstars/skycomponents/constellationboundarylines.cpp b/kstars/skycomponents/constellationboundarylines.cpp
index 41d332c..33b72bd 100644
--- a/kstars/skycomponents/constellationboundarylines.cpp
+++ b/kstars/skycomponents/constellationboundarylines.cpp
@@ -17,32 +17,18 @@
#include "constellationboundarylines.h"
-#include <cstdio>
-
-#include <QPen>
-
-#include <QDebug>
-#include <KLocalizedString>
-
-#include "Options.h"
+#include "ksfilereader.h"
#include "kstarsdata.h"
+#include "linelist.h"
+#include "Options.h"
+#include "polylist.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
#else
#include "skymap.h"
#endif
-#include "skyobjects/skyobject.h"
-#include "ksfilereader.h"
-
-#include "typedef.h"
-#include "linelist.h"
-#include "polylist.h"
-#include "linelistindex.h"
-#include "skycomponents/skymapcomposite.h"
-
-#include "skymesh.h"
-
#include "skypainter.h"
+#include "skycomponents/skymapcomposite.h"
ConstellationBoundaryLines::ConstellationBoundaryLines(SkyComposite *parent)
: NoPrecessIndex(parent, i18n("Constellation Boundaries"))
@@ -160,6 +146,10 @@ ConstellationBoundaryLines::ConstellationBoundaryLines(SkyComposite *parent)
appendPoly(polyList, idxFile, verbose);
}
+ConstellationBoundaryLines::~ConstellationBoundaryLines()
+{
+}
+
bool ConstellationBoundaryLines::selected()
{
#ifndef KSTARS_LITE
diff --git a/kstars/skycomponents/constellationboundarylines.h b/kstars/skycomponents/constellationboundarylines.h
index e193002..738deea 100644
--- a/kstars/skycomponents/constellationboundarylines.h
+++ b/kstars/skycomponents/constellationboundarylines.h
@@ -15,8 +15,7 @@
* *
***************************************************************************/
-#ifndef CONSTELLATION_BOUNDARY_LINES_H
-#define CONSTELLATION_BOUNDARY_LINES_H
+#pragma once
#include "noprecessindex.h"
@@ -40,18 +39,18 @@ typedef QVector<PolyListList *> PolyIndex;
class ConstellationBoundaryLines : public NoPrecessIndex
{
public:
- /** @short Constructor
- * Simply adds all of the coordinate grid circles
- * (meridians and parallels)
- * @p parent Pointer to the parent SkyComposite object
- *
- * Reads the constellation boundary data from cbounds.dat.
- * The boundary data is defined by a series of RA,Dec coordinate pairs
- * defining the "nodes" of the boundaries. The nodes are organized into
- * "segments", such that each segment represents a continuous series
- * of boundary-line intervals that divide two particular constellations.
- */
+ /**
+ * @short Constructor
+ * Simply adds all of the coordinate grid circles (meridians and parallels)
+ * @p parent Pointer to the parent SkyComposite object
+ *
+ * Reads the constellation boundary data from cbounds.dat. The boundary data is defined by
+ * a series of RA,Dec coordinate pairs defining the "nodes" of the boundaries. The nodes are
+ * organized into "segments", such that each segment represents a continuous series
+ * of boundary-line intervals that divide two particular constellations.
+ */
explicit ConstellationBoundaryLines(SkyComposite *parent);
+ virtual ~ConstellationBoundaryLines();
QString constellationName(SkyPoint *p);
@@ -62,17 +61,16 @@ class ConstellationBoundaryLines : public NoPrecessIndex
private:
void appendPoly(PolyList *polyList, int debug = 0);
- /** @short reads the indices from the KSFileReader instead of using
- * the SkyMesh to create them. If the file pointer is null or if
- * debug == -1 then we fall back to using the index.
- */
+ /**
+ * @short reads the indices from the KSFileReader instead of using
+ * the SkyMesh to create them. If the file pointer is null or if
+ * debug == -1 then we fall back to using the index.
+ */
void appendPoly(PolyList *polyList, KSFileReader *file, int debug);
PolyList *ContainingPoly(SkyPoint *p);
- SkyMesh *m_skyMesh;
+ SkyMesh *m_skyMesh { nullptr };
PolyIndex m_polyIndex;
- int m_polyIndexCnt;
+ int m_polyIndexCnt { 0 };
};
-
-#endif
diff --git a/kstars/skycomponents/constellationlines.cpp b/kstars/skycomponents/constellationlines.cpp
index 09593fc..8b8f312 100644
--- a/kstars/skycomponents/constellationlines.cpp
+++ b/kstars/skycomponents/constellationlines.cpp
@@ -16,28 +16,18 @@
***************************************************************************/
#include "constellationlines.h"
-#include "linelist.h"
-#include <QPen>
-
-#include <QDebug>
-#include <KLocalizedString>
-#include "Options.h"
#include "kstarsdata.h"
-#include "skyobjects/skyobject.h"
-#include "skyobjects/starobject.h"
-#include "skycomponents/starcomponent.h"
-#include "skycomponents/culturelist.h"
-
+#include "linelist.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
#else
#include "skymap.h"
#endif
-
-#include "skymesh.h"
-#include "ksfilereader.h"
+#include "Options.h"
#include "skypainter.h"
+#include "skycomponents/culturelist.h"
+#include "skycomponents/starcomponent.h"
ConstellationLines::ConstellationLines(SkyComposite *parent, CultureList *cultures)
: LineListIndex(parent, i18n("Constellation Lines")), m_reindexNum(J2000)
@@ -62,7 +52,7 @@ ConstellationLines::ConstellationLines(SkyComposite *parent, CultureList *cultur
intro();
bool culture = false;
- LineList *lineList(0);
+ LineList *lineList = nullptr;
double maxPM(0.0);
KSFileReader fileReader;
diff --git a/kstars/skycomponents/constellationlines.h b/kstars/skycomponents/constellationlines.h
index bf73571..fb9a50a 100644
--- a/kstars/skycomponents/constellationlines.h
+++ b/kstars/skycomponents/constellationlines.h
@@ -15,36 +15,34 @@
* *
***************************************************************************/
-#ifndef CONSTELLATIONLINES_H
-#define CONSTELLATIONLINES_H
+#pragma once
-#include <QHash>
-
-#include "linelistindex.h"
#include "ksnumbers.h"
+#include "linelistindex.h"
class CultureList;
/**
-*@class ConstellationLines
-*Collection of lines making the 88 constellations
-
-*@author Jason Harris
-*@version 0.1
-*/
+ * @class ConstellationLines
+ * Collection of lines making the 88 constellations
+ *
+ * @author Jason Harris
+ * @version 0.1
+ */
class ConstellationLines : public LineListIndex
{
public:
- /** @short Constructor
- * @p parent Pointer to the parent SkyComposite object
- *
- * Constellation lines data is read from clines.dat.
- * Each line in the file contains a command character ("M" means move to
- * this position without drawing a line, "D" means draw a line from
- * the previous position to this one), followed by the genetive name of
- * a star, which marks the position of the constellation node.
- */
+ /**
+ * @short Constructor
+ * @p parent Pointer to the parent SkyComposite object
+ *
+ * Constellation lines data is read from clines.dat.
+ * Each line in the file contains a command character ("M" means move to
+ * this position without drawing a line, "D" means draw a line from
+ * the previous position to this one), followed by the genetive name of
+ * a star, which marks the position of the constellation node.
+ */
ConstellationLines(SkyComposite *parent, CultureList *cultures);
void reindex(KSNumbers *num);
@@ -54,9 +52,10 @@ class ConstellationLines : public LineListIndex
protected:
const IndexHash &getIndexHash(LineList *lineList) Q_DECL_OVERRIDE;
- /** @short we need to override the update routine because stars are
- * updated differently from mere SkyPoints.
- */
+ /**
+ * @short we need to override the update routine because stars are
+ * updated differently from mere SkyPoints.
+ */
void JITupdate(LineList *lineList) Q_DECL_OVERRIDE;
/** @short Set the QColor and QPen for drawing. */
@@ -64,7 +63,5 @@ class ConstellationLines : public LineListIndex
private:
KSNumbers m_reindexNum;
- double m_reindexInterval;
+ double m_reindexInterval { 0 };
};
-
-#endif
diff --git a/kstars/skycomponents/coordinategrid.h b/kstars/skycomponents/coordinategrid.h
index 79fd78d..dc70ae3 100644
--- a/kstars/skycomponents/coordinategrid.h
+++ b/kstars/skycomponents/coordinategrid.h
@@ -15,32 +15,33 @@
* *
***************************************************************************/
-#ifndef COORDINATEGRID_H
-#define COORDINATEGRID_H
+#pragma once
#include "noprecessindex.h"
-/**
- *@class CoordinateGrid
- *Collection of all the circles in the coordinate grid
+class QString;
+
+class SkyComposite;
+class SkyPainter;
- *@author Jason Harris
- *@version 0.1
- */
+/**
+ * @class CoordinateGrid
+ * Collection of all the circles in the coordinate grid
+ *
+ * @author Jason Harris
+ * @version 0.1
+ */
class CoordinateGrid : public NoPrecessIndex
{
public:
/**
- *@short Constructor
- *Simply adds all of the coordinate grid circles
- *(meridians and parallels)
- *@p parent Pointer to the parent SkyComposite object
- */
+ * @short Constructor
+ * Simply adds all of the coordinate grid circles (meridians and parallels)
+ * @p parent Pointer to the parent SkyComposite object
+ */
CoordinateGrid(SkyComposite *parent, const QString &name);
void preDraw(SkyPainter *skyp) Q_DECL_OVERRIDE = 0;
bool selected() Q_DECL_OVERRIDE = 0;
};
-
-#endif
diff --git a/kstars/skycomponents/culturelist.h b/kstars/skycomponents/culturelist.h
index 382db16..2bbc4a0 100644
--- a/kstars/skycomponents/culturelist.h
+++ b/kstars/skycomponents/culturelist.h
@@ -15,12 +15,12 @@
* *
***************************************************************************/
-#ifndef CULTURELIST_H
-#define CULTURELIST_H
+#pragma once
#include <QStringList>
-/** @class CultureList
+/**
+ * @class CultureList
* A list of all cultures
* FIXME: Why not use a QStringList?
*/
@@ -39,8 +39,10 @@ class CultureList
/** @short Return a sorted list of cultures */
QStringList getNames() const { return m_CultureList; }
- /** @short Return the name of the culture at index.
- * @return null string if is index is out of range */
+ /**
+ * @short Return the name of the culture at index.
+ * @return null string if is index is out of range
+ * */
QString getName(int index) const;
private:
@@ -48,5 +50,3 @@ class CultureList
// List of all available cultures. It's assumed that list is sorted.
QStringList m_CultureList;
};
-
-#endif
diff --git a/kstars/skycomponents/deepskycomponent.cpp b/kstars/skycomponents/deepskycomponent.cpp
index fb14f3c..5825f5d 100644
--- a/kstars/skycomponents/deepskycomponent.cpp
+++ b/kstars/skycomponents/deepskycomponent.cpp
@@ -17,27 +17,18 @@
#include "deepskycomponent.h"
-#include <QDir>
-#include <QFile>
-
-#include <KLocalizedString>
-#include <QStandardPaths>
-
-#include "skyobjects/deepskyobject.h"
-#include "dms.h"
#include "ksfilereader.h"
+#include "kspaths.h"
#include "kstarsdata.h"
-#include "auxiliary/kspaths.h"
+#include "Options.h"
+#include "skylabeler.h"
#ifndef KSTARS_LITE
#include "skymap.h"
#endif
-#include "skylabel.h"
-#include "skylabeler.h"
-#include "Options.h"
#include "skymesh.h"
#include "skypainter.h"
#include "projections/projector.h"
-#include "kspaths.h"
+#include "skyobjects/deepskyobject.h"
DeepSkyComponent::DeepSkyComponent(SkyComposite *parent) : SkyComponent(parent)
{
@@ -50,7 +41,22 @@ DeepSkyComponent::DeepSkyComponent(SkyComposite *parent) : SkyComponent(parent)
DeepSkyComponent::~DeepSkyComponent()
{
- clear();
+ clearList(m_MessierList);
+ clearList(m_NGCList);
+ clearList(m_ICList);
+ clearList(m_OtherList);
+ qDeleteAll(m_DeepSkyIndex);
+ m_DeepSkyIndex.clear();
+ qDeleteAll(m_MessierIndex);
+ m_MessierIndex.clear();
+ qDeleteAll(m_NGCIndex);
+ m_NGCIndex.clear();
+ qDeleteAll(m_ICIndex);
+ m_ICIndex.clear();
+ qDeleteAll(m_OtherIndex);
+ m_OtherIndex.clear();
+ for (int i = 0; i <= MAX_LINENUMBER_MAG; i++)
+ delete m_labelList[i];
}
bool DeepSkyComponent::selected()
@@ -746,11 +752,3 @@ void DeepSkyComponent::clearList(QList<DeepSkyObject *> &list)
delete o;
}
}
-
-void DeepSkyComponent::clear()
-{
- clearList(m_MessierList);
- clearList(m_NGCList);
- clearList(m_ICList);
- clearList(m_OtherList);
-}
diff --git a/kstars/skycomponents/deepskycomponent.h b/kstars/skycomponents/deepskycomponent.h
index 33d2027..9a8fcdf 100644
--- a/kstars/skycomponents/deepskycomponent.h
+++ b/kstars/skycomponents/deepskycomponent.h
@@ -15,29 +15,21 @@
* *
***************************************************************************/
-#ifndef DEEPSKYCOMPONENT_H
-#define DEEPSKYCOMPONENT_H
+#pragma once
-#include "typedef.h"
-
-#include <QObject>
#include "skycomponent.h"
#include "skylabel.h"
-#include "ksparser.h"
-#define NNGCFILES 14
-
-class QColor;
-class SkyMap;
-class KSNumbers;
-class DeepSkyObject;
-class SkyPoint;
-class SkyMesh;
-class SkyLabeler;
+class QPointF;
#ifdef KSTARS_LITE
class DeepSkyItem;
#endif
+class DeepSkyObject;
+class KSNumbers;
+class SkyMap;
+class SkyMesh;
+class SkyPoint;
// NOTE: Although the following symbol has nothing to do with line
// number in any file, we use this name to keep consistency in naming
@@ -69,82 +61,78 @@ class DeepSkyComponent : public SkyComponent
void draw(SkyPainter *skyp) Q_DECL_OVERRIDE;
- /** @short draw all the labels in the prioritized LabelLists and then
- * clear the LabelLists.
- */
+ /**
+ * @short draw all the labels in the prioritized LabelLists and then
+ * clear the LabelLists.
+ */
void drawLabels();
/**
- * @short Update the sky positions of this component. FIXME -jbb does nothing now
- *
- * This function usually just updates the Horizontal (Azimuth/Altitude)
- * coordinates of the objects in this component. If the KSNumbers*
- * argument is not nullptr, this function also recomputes precession and
- * nutation for the date in KSNumbers.
- * @p num Pointer to the KSNumbers object
- * @note By default, the num parameter is nullptr, indicating that
- * Precession/Nutation computation should be skipped; this computation
- * is only occasionally required.
- */
+ * @short Update the sky positions of this component. FIXME -jbb does nothing now
+ *
+ * This function usually just updates the Horizontal (Azimuth/Altitude) coordinates of the
+ * objects in this component. If the KSNumbers argument is not nullptr, this function also
+ * recomputes precession and nutation for the date in KSNumbers.
+ * @p num Pointer to the KSNumbers object
+ * @note By default, the num parameter is nullptr, indicating that Precession/Nutation
+ * computation should be skipped; this computation is only occasionally required.
+ */
void update(KSNumbers *num = 0) Q_DECL_OVERRIDE;
/**
- * @short Search the children of this SkyComponent for
- * a SkyObject whose name matches the argument
- * @p name the name to be matched
- * @return a pointer to the SkyObject whose name matches
- * the argument, or a nullptr pointer if no match was found.
- */
+ * @short Search the children of this SkyComponent for a SkyObject whose name matches the argument
+ * @p name the name to be matched
+ * @return a pointer to the SkyObject whose name matches the argument, or a nullptr pointer
+ * if no match was found.
+ */
SkyObject *findByName(const QString &name) Q_DECL_OVERRIDE;
/**
- * @short Searches the region(s) and appends the SkyObjects found to the list of sky objects
- *
- * Look for a SkyObject that is in one of the regions
- * If found, then append to the list of sky objects
- * @p list list of SkyObject to which matching list has to be appended to
- * @p region defines the regions in which the search for SkyObject should be done within
- * @return void
- */
+ * @short Searches the region(s) and appends the SkyObjects found to the list of sky objects
+ *
+ * Look for a SkyObject that is in one of the regions
+ * If found, then append to the list of sky objects
+ * @p list list of SkyObject to which matching list has to be appended to
+ * @p region defines the regions in which the search for SkyObject should be done within
+ * @return void
+ */
void objectsInArea(QList<SkyObject *> &list, const SkyRegion &region) Q_DECL_OVERRIDE;
SkyObject *objectNearest(SkyPoint *p, double &maxrad) Q_DECL_OVERRIDE;
const QList<DeepSkyObject *> &objectList() const { return m_DeepSkyList; }
- void clear();
-
bool selected() Q_DECL_OVERRIDE;
private:
/**
- * @short Read the ngcic.dat deep-sky database.
- * Parse all lines from the deep-sky object catalog files. Construct a DeepSkyObject
- * from the data in each line, and add it to the DeepSkyComponent.
- *
- * Each line in the file is parsed according to column position:
- * @li 0 IC indicator [char] If 'I' then IC object; if ' ' then NGC object
- * @li 1-4 Catalog number [int] The NGC/IC catalog ID number
- * @li 6-8 Constellation code (IAU abbreviation)
- * @li 10-11 RA hours [int]
- * @li 13-14 RA minutes [int]
- * @li 16-19 RA seconds [float]
- * @li 21 Dec sign [char; '+' or '-']
- * @li 22-23 Dec degrees [int]
- * @li 25-26 Dec minutes [int]
- * @li 28-29 Dec seconds [int]
- * @li 31 Type ID [int] Indicates object type; see TypeName array in kstars.cpp
- * @li 33-36 Type details [string] (not yet used)
- * @li 38-41 Magnitude [float] can be blank
- * @li 43-48 Major axis length, in arcmin [float] can be blank
- * @li 50-54 Minor axis length, in arcmin [float] can be blank
- * @li 56-58 Position angle, in degrees [int] can be blank
- * @li 60-62 Messier catalog number [int] can be blank
- * @li 64-69 PGC Catalog number [int] can be blank
- * @li 71-75 UGC Catalog number [int] can be blank
- * @li 77-END Common name [string] can be blank
- * @return true if data file is successfully read.
- */
+ * @short Read the ngcic.dat deep-sky database.
+ * Parse all lines from the deep-sky object catalog files. Construct a DeepSkyObject
+ * from the data in each line, and add it to the DeepSkyComponent.
+ *
+ * Each line in the file is parsed according to column position:
+ * @li 0 IC indicator [char] If 'I' then IC object; if ' ' then NGC object
+ * @li 1-4 Catalog number [int] The NGC/IC catalog ID number
+ * @li 6-8 Constellation code (IAU abbreviation)
+ * @li 10-11 RA hours [int]
+ * @li 13-14 RA minutes [int]
+ * @li 16-19 RA seconds [float]
+ * @li 21 Dec sign [char; '+' or '-']
+ * @li 22-23 Dec degrees [int]
+ * @li 25-26 Dec minutes [int]
+ * @li 28-29 Dec seconds [int]
+ * @li 31 Type ID [int] Indicates object type; see TypeName array in kstars.cpp
+ * @li 33-36 Type details [string] (not yet used)
+ * @li 38-41 Magnitude [float] can be blank
+ * @li 43-48 Major axis length, in arcmin [float] can be blank
+ * @li 50-54 Minor axis length, in arcmin [float] can be blank
+ * @li 56-58 Position angle, in degrees [int] can be blank
+ * @li 60-62 Messier catalog number [int] can be blank
+ * @li 64-69 PGC Catalog number [int] can be blank
+ * @li 71-75 UGC Catalog number [int] can be blank
+ * @li 77-END Common name [string] can be blank
+ * @return true if data file is successfully read.
+ */
void loadData();
void clearList(QList<DeepSkyObject *> &list);
@@ -162,10 +150,10 @@ class DeepSkyComponent : public SkyComponent
QList<DeepSkyObject *> m_OtherList;
LabelList *m_labelList[MAX_LINENUMBER_MAG + 1];
- bool m_hideLabels;
- double m_zoomMagLimit;
+ bool m_hideLabels { false };
+ double m_zoomMagLimit { 0 };
- SkyMesh *m_skyMesh;
+ SkyMesh *m_skyMesh { nullptr };
DeepSkyIndex m_DeepSkyIndex;
DeepSkyIndex m_MessierIndex;
DeepSkyIndex m_NGCIndex;
@@ -176,11 +164,6 @@ class DeepSkyComponent : public SkyComponent
QHash<QString, DeepSkyObject *> nameHash;
- /**
- *@short adds a label to the lists of labels to be drawn prioritized
- *by magnitude.
- */
+ /** @short adds a label to the lists of labels to be drawn prioritized by magnitude. */
void addLabel(const QPointF &p, DeepSkyObject *obj);
};
-
-#endif
diff --git a/kstars/skycomponents/deepstarcomponent.cpp b/kstars/skycomponents/deepstarcomponent.cpp
index 6bea129..e942313 100644
--- a/kstars/skycomponents/deepstarcomponent.cpp
+++ b/kstars/skycomponents/deepstarcomponent.cpp
@@ -17,27 +17,20 @@
#include "deepstarcomponent.h"
-#include "binfilehelper.h"
#include "byteorder.h"
#include "kstarsdata.h"
#include "Options.h"
+#include "projections/projector.h"
#ifndef KSTARS_LITE
#include "skymap.h"
#endif
#include "skymesh.h"
-#include "skyobjects/starobject.h"
#include "skypainter.h"
-#include "starblockfactory.h"
+#include "starblock.h"
#include "starcomponent.h"
-#include "projections/projector.h"
-
-#include <QPixmap>
-#include <QRectF>
-#include <QFontMetricsF>
-#include <QtConcurrent>
-//NOTE Added this for QT_FSEEK, should we be including another file?
#include <qplatformdefs.h>
+#include <QtConcurrent>
#ifdef _WIN32
#include <windows.h>
@@ -54,6 +47,15 @@ DeepStarComponent::DeepStarComponent(SkyComposite *parent, QString fileName, flo
qDebug() << "Loaded DSO catalog file: " << dataFileName;
}
+DeepStarComponent::~DeepStarComponent()
+{
+ qDeleteAll(m_starBlockList);
+ m_starBlockList.clear();
+ if (fileOpened)
+ starReader.closeFile();
+ fileOpened = false;
+}
+
bool DeepStarComponent::loadStaticStars()
{
FILE *dataFile;
@@ -74,6 +76,7 @@ bool DeepStarComponent::loadStaticStars()
}
quint8 recordSize = starReader.guessRecordSize();
+
if (recordSize != 16 && recordSize != 32)
{
qDebug() << "Cannot understand catalog file " << dataFileName << endl;
@@ -113,7 +116,7 @@ bool DeepStarComponent::loadStaticStars()
{
Trixel trixel = i;
quint64 records = starReader.getRecordCount(i);
- StarBlock *SB = new StarBlock(records);
+ StarBlock* SB = new StarBlock(records);
if (!SB)
qDebug() << "ERROR: Could not allocate new StarBlock to hold shallow unnamed stars for trixel "
@@ -123,8 +126,7 @@ bool DeepStarComponent::loadStaticStars()
for (quint64 j = 0; j < records; ++j)
{
- bool fread_success = false;
- fread_success = fread(&stardata, sizeof(starData), 1, dataFile);
+ bool fread_success = fread(&stardata, sizeof(starData), 1, dataFile);
if (!fread_success)
{
@@ -215,13 +217,6 @@ bool DeepStarComponent::loadStaticStars()
return true;
}
-DeepStarComponent::~DeepStarComponent()
-{
- if (fileOpened)
- starReader.closeFile();
- fileOpened = false;
-}
-
bool DeepStarComponent::selected()
{
return Options::showStars() && fileOpened;
@@ -300,8 +295,6 @@ void DeepStarComponent::draw(SkyPainter *skyp)
MeshIterator region(m_skyMesh, DRAW_BUF);
- magLim = maglim;
-
// If we are to hide the fainter stars (eg: while slewing), we set the magnitude limit to hideStarsMag.
if (hideFaintStars && maglim > hideStarsMag)
maglim = hideStarsMag;
@@ -465,7 +458,6 @@ bool DeepStarComponent::openDataFile()
return false;
}
}
- meshLevel = htm_level;
ret = fread(&MSpT, 2, 1, starReader.getFileHandle());
if (starReader.getByteSwap())
MSpT = bswap_16(MSpT);
diff --git a/kstars/skycomponents/deepstarcomponent.h b/kstars/skycomponents/deepstarcomponent.h
index d81614f..fc8dbd8 100644
--- a/kstars/skycomponents/deepstarcomponent.h
+++ b/kstars/skycomponents/deepstarcomponent.h
@@ -15,29 +15,23 @@
* *
***************************************************************************/
-#ifndef DEEPSTARCOMPONENT_H
-#define DEEPSTARCOMPONENT_H
+#pragma once
/**
- *@class DeepStarComponent
- *Stores and manages unnamed stars, most of which are dynamically loaded into memory.
+ * @class DeepStarComponent
+ * Stores and manages unnamed stars, most of which are dynamically loaded into memory.
*
- *@author Akarsh Simha
- *@note Much of the code here is copied from class StarComponent authored by Thomas Kabelmann
- *@version 0.1
+ * @author Akarsh Simha
+ * @note Much of the code here is copied from class StarComponent authored by Thomas Kabelmann
+ * @version 0.1
*/
-#include "listcomponent.h"
-#include "kstarsdatetime.h"
-#include "ksnumbers.h"
-#include "starblock.h"
-#include "typedef.h"
-#include "highpmstarlist.h"
-#include "skyobjects/starobject.h"
#include "binfilehelper.h"
+#include "ksnumbers.h"
+#include "listcomponent.h"
#include "starblockfactory.h"
#include "skyobjects/deepstardata.h"
-#include "starblocklist.h"
+#include "skyobjects/stardata.h"
class SkyMesh;
class StarObject;
@@ -70,24 +64,24 @@ class DeepStarComponent : public ListComponent
bool openDataFile();
/**
- *@return true if this DeepStarComponent has static stars (that are not dynamically loaded)
- */
+ * @return true if this DeepStarComponent has static stars (that are not dynamically loaded)
+ */
inline bool hasStaticStars() const { return staticStars; }
/**
- *@return return the estimated faint magnitude limit of this DeepStarComponent
- */
+ * @return return the estimated faint magnitude limit of this DeepStarComponent
+ */
float faintMagnitude() const { return m_FaintMagnitude; }
/**
- *@param HDnum Henry-Draper catalog number of the desired star
- *@return A star matching the given Henry-Draper catalog number
- */
+ * @param HDnum Henry-Draper catalog number of the desired star
+ * @return A star matching the given Henry-Draper catalog number
+ */
StarObject *findByHDIndex(int HDnum);
/**
- *@return Nearest star within maxrad of SkyPoint p, or nullptr if not found
- */
+ * @return Nearest star within maxrad of SkyPoint p, or nullptr if not found
+ */
SkyObject *objectNearest(SkyPoint *p, double &maxrad) Q_DECL_OVERRIDE;
inline bool fileOpen() const { return fileOpened; }
@@ -97,20 +91,20 @@ class DeepStarComponent : public ListComponent
bool verifySBLIntegrity();
/**
- *@short Add to the given list, the stars from this component,
- * that lie within the specified circular aperture, and that are
- * brighter than the limiting magnitude specified.
- *@p center The center point of the aperture
- *@p radius The radius around the center point that defines the
- * aperture
- *@p maglim Optional parameter indicating the limiting magnitude.
- * If magnitude limit is numerically < -28, the limiting magnitude
- * is assumed to be the limiting magnitude of the catalog (i.e. no
- * magnitude limit)
- *@p list The list to operate on
- *@return false if the limiting magnitude is brighter than the
- * trigger magnitude of the DeepStarComponent
- */
+ * @short Add to the given list, the stars from this component,
+ * that lie within the specified circular aperture, and that are
+ * brighter than the limiting magnitude specified.
+ * @p center The center point of the aperture
+ * @p radius The radius around the center point that defines the
+ * aperture
+ * @p maglim Optional parameter indicating the limiting magnitude.
+ * If magnitude limit is numerically < -28, the limiting magnitude
+ * is assumed to be the limiting magnitude of the catalog (i.e. no
+ * magnitude limit)
+ * @p list The list to operate on
+ * @return false if the limiting magnitude is brighter than the
+ * trigger magnitude of the DeepStarComponent
+ */
bool starsInAperture(QList<StarObject *> &list, const SkyPoint &center, float radius, float maglim = -29);
// TODO: Find the right place for this method
@@ -120,28 +114,26 @@ class DeepStarComponent : public ListComponent
static StarBlockFactory m_StarBlockFactory;
private:
- SkyMesh *m_skyMesh;
+ SkyMesh *m_skyMesh { nullptr };
KSNumbers m_reindexNum;
- int meshLevel;
- float m_zoomMagLimit;
- float triggerMag; // Magnitude at which this catalog triggers
+ float m_zoomMagLimit { 0 };
+ float triggerMag { 0 }; // Magnitude at which this catalog triggers
- float m_FaintMagnitude; // Limiting magnitude of the catalog currently loaded
- bool fileOpened; // Indicates whether the file is opened or not
- float magLim; // Current limiting magnitude for visible stars
- unsigned long visibleStarCount;
+ float m_FaintMagnitude { 0 }; // Limiting magnitude of the catalog currently loaded
+ bool fileOpened { false }; // Indicates whether the file is opened or not
+ unsigned long visibleStarCount { 0 };
quint16 MSpT; // Maximum number of stars in any given trixel
// Time keeping variables
- long unsigned t_dynamicLoad;
- long unsigned t_drawUnnamed;
- long unsigned t_updateCache;
+ long unsigned t_dynamicLoad { 0 };
+ long unsigned t_drawUnnamed { 0 };
+ long unsigned t_updateCache { 0 };
QVector<StarBlockList *> m_starBlockList;
QHash<int, StarObject *> m_CatalogNumber;
- bool staticStars;
+ bool staticStars { false };
// Stuff required for reading data
deepStarData deepstardata;
@@ -149,5 +141,3 @@ class DeepStarComponent : public ListComponent
BinFileHelper starReader;
QString dataFileName;
};
-
-#endif
diff --git a/kstars/skycomponents/ecliptic.cpp b/kstars/skycomponents/ecliptic.cpp
index 3da1335..f0b739c 100644
--- a/kstars/skycomponents/ecliptic.cpp
+++ b/kstars/skycomponents/ecliptic.cpp
@@ -17,21 +17,15 @@
#include "ecliptic.h"
-#include "ksnumbers.h"
#include "kstarsdata.h"
-
+#include "linelist.h"
+#include "Options.h"
+#include "skylabeler.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
#else
#include "skymap.h"
#endif
-
-#include "skyobjects/skypoint.h"
-#include "dms.h"
-#include "Options.h"
-#include "linelist.h"
-#include "skylabeler.h"
-
#include "skypainter.h"
#include "projections/projector.h"
diff --git a/kstars/skycomponents/ecliptic.h b/kstars/skycomponents/ecliptic.h
index a99b1a7..fe46f60 100644
--- a/kstars/skycomponents/ecliptic.h
+++ b/kstars/skycomponents/ecliptic.h
@@ -15,8 +15,7 @@
* *
***************************************************************************/
-#ifndef ECLIPTIC_H
-#define ECLIPTIC_H
+#pragma once
#include "linelistindex.h"
#include "linelistlabel.h"
@@ -31,10 +30,10 @@
class Ecliptic : public LineListIndex
{
public:
- /** @short Constructor
- * @p parent pointer to the parent SkyComposite object
- * name is the name of the subclass
- */
+ /**
+ * @short Constructor
+ * @p parent pointer to the parent SkyComposite object name is the name of the subclass
+ */
explicit Ecliptic(SkyComposite *parent);
void draw(SkyPainter *skyp) Q_DECL_OVERRIDE;
@@ -46,5 +45,3 @@ class Ecliptic : public LineListIndex
private:
LineListLabel m_label;
};
-
-#endif
diff --git a/kstars/skycomponents/equator.cpp b/kstars/skycomponents/equator.cpp
index aeafc81..9dc47e5 100644
--- a/kstars/skycomponents/equator.cpp
+++ b/kstars/skycomponents/equator.cpp
@@ -17,19 +17,15 @@
#include "equator.h"
-#include "ksnumbers.h"
#include "kstarsdata.h"
+#include "linelist.h"
+#include "Options.h"
+#include "skylabeler.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
#else
#include "skymap.h"
#endif
-#include "skyobjects/skypoint.h"
-#include "dms.h"
-#include "Options.h"
-#include "linelist.h"
-#include "skylabeler.h"
-
#include "skypainter.h"
#include "projections/projector.h"
diff --git a/kstars/skycomponents/equator.h b/kstars/skycomponents/equator.h
index 6873b5c..ecf13d9 100644
--- a/kstars/skycomponents/equator.h
+++ b/kstars/skycomponents/equator.h
@@ -15,11 +15,10 @@
* *
***************************************************************************/
-#ifndef EQUATOR_H
-#define EQUATOR_H
+#pragma once
-#include "noprecessindex.h"
#include "linelistlabel.h"
+#include "noprecessindex.h"
/**
* @class Equator
@@ -31,10 +30,10 @@
class Equator : public NoPrecessIndex
{
public:
- /** @short Constructor
- * @p parent pointer to the parent SkyComposite object
- * name is the name of the subclass
- */
+ /**
+ * @short Constructor
+ * @p parent pointer to the parent SkyComposite object name is the name of the subclass
+ */
explicit Equator(SkyComposite *parent);
bool selected() Q_DECL_OVERRIDE;
@@ -48,5 +47,3 @@ class Equator : public NoPrecessIndex
private:
LineListLabel m_label;
};
-
-#endif
diff --git a/kstars/skycomponents/equatorialcoordinategrid.cpp b/kstars/skycomponents/equatorialcoordinategrid.cpp
index 596162b..f1f0b34 100644
--- a/kstars/skycomponents/equatorialcoordinategrid.cpp
+++ b/kstars/skycomponents/equatorialcoordinategrid.cpp
@@ -17,22 +17,14 @@
#include "equatorialcoordinategrid.h"
-#include <QPen>
-#include <QBrush>
-#include <QColor>
-
-#include "Options.h"
#include "kstarsdata.h"
-
+#include "linelist.h"
+#include "Options.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
#else
#include "skymap.h"
#endif
-
-#include "linelist.h"
-#include "dms.h"
-
#include "skypainter.h"
EquatorialCoordinateGrid::EquatorialCoordinateGrid(SkyComposite *parent)
diff --git a/kstars/skycomponents/equatorialcoordinategrid.h b/kstars/skycomponents/equatorialcoordinategrid.h
index 0316b27..81da1f0 100644
--- a/kstars/skycomponents/equatorialcoordinategrid.h
+++ b/kstars/skycomponents/equatorialcoordinategrid.h
@@ -15,32 +15,31 @@
* *
***************************************************************************/
-#ifndef EQUATORIALCOORDINATEGRID_H
-#define EQUATORIALCOORDINATEGRID_H
+#pragma once
#include "coordinategrid.h"
-/**
- *@class EquatorialCoordinateGrid
- *Collection of all the circles in the equatorial coordinate grid
+class SkyComposite;
+class SkyPainter;
- *@author Jérôme SONRIER
- *@version 0.1
- */
+/**
+ * @class EquatorialCoordinateGrid
+ * Collection of all the circles in the equatorial coordinate grid
+ *
+ * @author Jérôme SONRIER
+ * @version 0.1
+ */
class EquatorialCoordinateGrid : public CoordinateGrid
{
public:
/**
- *@short Constructor
- *Simply adds all of the equatorial coordinate grid circles
- *(meridians and parallels)
- *@p parent Pointer to the parent SkyComposite object
- */
+ * @short Constructor
+ * Simply adds all of the equatorial coordinate grid circles (meridians and parallels)
+ * @p parent Pointer to the parent SkyComposite object
+ */
explicit EquatorialCoordinateGrid(SkyComposite *parent);
void preDraw(SkyPainter *skyp) Q_DECL_OVERRIDE;
bool selected() Q_DECL_OVERRIDE;
};
-
-#endif
diff --git a/kstars/skycomponents/highpmstarlist.cpp b/kstars/skycomponents/highpmstarlist.cpp
index 6660de8..eb7ae3b 100644
--- a/kstars/skycomponents/highpmstarlist.cpp
+++ b/kstars/skycomponents/highpmstarlist.cpp
@@ -37,10 +37,8 @@ HighPMStarList::HighPMStarList(double threshold) : m_reindexNum(J2000), m_thresh
HighPMStarList::~HighPMStarList()
{
- for (int i = 0; i < size(); i++)
- {
- delete m_stars[i];
- }
+ qDeleteAll(m_stars);
+ m_stars.clear();
}
bool HighPMStarList::append(Trixel trixel, StarObject *star, double pm)
diff --git a/kstars/skycomponents/horizontalcoordinategrid.cpp b/kstars/skycomponents/horizontalcoordinategrid.cpp
index 8983ab9..baafb3c 100644
--- a/kstars/skycomponents/horizontalcoordinategrid.cpp
+++ b/kstars/skycomponents/horizontalcoordinategrid.cpp
@@ -17,22 +17,14 @@
#include "horizontalcoordinategrid.h"
-#include <QPen>
-#include <QBrush>
-#include <QColor>
-
-#include "Options.h"
#include "kstarsdata.h"
-
+#include "Options.h"
+#include "linelist.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
#else
#include "skymap.h"
#endif
-
-#include "linelist.h"
-#include "dms.h"
-
#include "skypainter.h"
HorizontalCoordinateGrid::HorizontalCoordinateGrid(SkyComposite *parent)
@@ -54,7 +46,7 @@ HorizontalCoordinateGrid::HorizontalCoordinateGrid(SkyComposite *parent)
double max, alt, alt2, az, az2;
- LineList *lineList;
+ LineList *lineList = nullptr;
for (az = minAz; az < maxAz; az += dAz)
{
diff --git a/kstars/skycomponents/horizontalcoordinategrid.h b/kstars/skycomponents/horizontalcoordinategrid.h
index 573847c..7d16316 100644
--- a/kstars/skycomponents/horizontalcoordinategrid.h
+++ b/kstars/skycomponents/horizontalcoordinategrid.h
@@ -15,27 +15,25 @@
* *
***************************************************************************/
-#ifndef HORIZONTALCOORDINATEGRID_H
-#define HORIZONTALCOORDINATEGRID_H
+#pragma once
#include "coordinategrid.h"
/**
- *@class HorizontalCoordinateGrid
- *Collection of all the circles in the horizontal coordinate grid
-
- *@author Jérôme SONRIER
- *@version 0.1
- */
+ * @class HorizontalCoordinateGrid
+ * Collection of all the circles in the horizontal coordinate grid
+ *
+ * @author Jérôme SONRIER
+ * @version 0.1
+ */
class HorizontalCoordinateGrid : public CoordinateGrid
{
public:
/**
- *@short Constructor
- *Simply adds all of the coordinate grid circles
- *(meridians and parallels)
- *@p parent Pointer to the parent SkyComposite object
- */
+ * @short Constructor
+ * Simply adds all of the coordinate grid circles (meridians and parallels)
+ * @p parent Pointer to the parent SkyComposite object
+ */
explicit HorizontalCoordinateGrid(SkyComposite *parent);
void preDraw(SkyPainter *skyp) Q_DECL_OVERRIDE;
@@ -44,5 +42,3 @@ class HorizontalCoordinateGrid : public CoordinateGrid
bool selected() Q_DECL_OVERRIDE;
};
-
-#endif
diff --git a/kstars/skycomponents/linelist.h b/kstars/skycomponents/linelist.h
index f24aca2..b57d2cb 100644
--- a/kstars/skycomponents/linelist.h
+++ b/kstars/skycomponents/linelist.h
@@ -15,13 +15,12 @@
* *
***************************************************************************/
-#ifndef LINELIST_H
-#define LINELIST_H
-
-#include <QList>
+#pragma once
#include "typedef.h"
+#include <QList>
+
class SkyPoint;
class KSNumbers;
@@ -36,6 +35,7 @@ class LineList
{
public:
LineList() : drawID(0), updateID(0), updateNumID(0) {}
+ ~LineList() { }
/* A global drawID (in SkyMesh) is updated at the start of each draw
* cycle. Since an extended object is often covered by more than one
@@ -57,5 +57,3 @@ class LineList
private:
SkyList pointList;
};
-
-#endif
diff --git a/kstars/skycomponents/linelistindex.cpp b/kstars/skycomponents/linelistindex.cpp
index 9ab4cf2..fd0b268 100644
--- a/kstars/skycomponents/linelistindex.cpp
+++ b/kstars/skycomponents/linelistindex.cpp
@@ -1,4 +1,4 @@
-/***************************************************************************
+ /***************************************************************************
linelistindex.cpp - K Desktop Planetarium
-------------------
begin : 2007-07-04
@@ -33,35 +33,27 @@
#include "linelistindex.h"
-#include <QBrush>
-#include <QMutexLocker>
-#include <QDebug>
-
-#include <KLocalizedString>
-
#include "Options.h"
#include "kstarsdata.h"
-#include "skyobjects/skyobject.h"
+#include "linelist.h"
#ifndef KSTARS_LITE
#include "skymap.h"
#endif
-
-#include "skymesh.h"
-#include "linelist.h"
-
#include "skypainter.h"
LineListIndex::LineListIndex(SkyComposite *parent, const QString &name) : SkyComponent(parent), m_name(name)
{
m_skyMesh = SkyMesh::Instance();
- m_lineIndex = new LineListHash();
- m_polyIndex = new LineListHash();
+ m_lineIndex.reset(new LineListHash());
+ m_polyIndex.reset(new LineListHash());
}
LineListIndex::~LineListIndex()
{
- delete m_lineIndex;
- delete m_polyIndex;
+ qDeleteAll(m_lineIndex->values());
+ m_lineIndex->clear();
+ qDeleteAll(m_polyIndex->values());
+ m_polyIndex->clear();
}
// This is a callback for the indexLines() function below
@@ -74,6 +66,7 @@ void LineListIndex::removeLine(LineList *lineList)
{
const IndexHash &indexHash = getIndexHash(lineList);
IndexHash::const_iterator iter = indexHash.constBegin();
+
while (iter != indexHash.constEnd())
{
Trixel trixel = iter.key();
@@ -93,18 +86,18 @@ void LineListIndex::appendLine(LineList *lineList, int debug)
const IndexHash &indexHash = getIndexHash(lineList);
IndexHash::const_iterator iter = indexHash.constBegin();
+
while (iter != indexHash.constEnd())
{
Trixel trixel = iter.key();
- iter++;
+ iter++;
if (!m_lineIndex->contains(trixel))
{
m_lineIndex->insert(trixel, new LineListList());
}
m_lineIndex->value(trixel)->append(lineList);
}
-
m_listList.append(lineList);
}
@@ -115,6 +108,7 @@ void LineListIndex::appendPoly(LineList *lineList, int debug)
const IndexHash &indexHash = skyMesh()->indexPoly(lineList->points());
IndexHash::const_iterator iter = indexHash.constBegin();
+
while (iter != indexHash.constEnd())
{
Trixel trixel = iter.key();
@@ -131,14 +125,15 @@ void LineListIndex::appendPoly(LineList *lineList, int debug)
void LineListIndex::appendBoth(LineList *lineList, int debug)
{
QMutexLocker m1(&mutex);
+
appendLine(lineList, debug);
appendPoly(lineList, debug);
}
void LineListIndex::reindexLines()
{
- LineListHash *oldIndex = m_lineIndex;
- m_lineIndex = new LineListHash();
+ LineListHash *oldIndex = m_lineIndex.get();
+ m_lineIndex.reset(new LineListHash());
DrawID drawID = skyMesh()->incDrawID();
@@ -192,6 +187,7 @@ void LineListIndex::draw(SkyPainter *skyp)
preDraw(skyp);
drawLines(skyp);
}
+
#ifdef KSTARS_LITE
MeshIterator LineListIndex::visibleTrixels()
{
diff --git a/kstars/skycomponents/linelistindex.h b/kstars/skycomponents/linelistindex.h
index dbc88f0..e0f3cdf 100644
--- a/kstars/skycomponents/linelistindex.h
+++ b/kstars/skycomponents/linelistindex.h
@@ -15,23 +15,22 @@
* *
***************************************************************************/
-#ifndef LINELISTINDEX_H
-#define LINELISTINDEX_H
-
-#include <QList>
-#include <QHash>
-#include <QMutex>
+#pragma once
#include "skycomponent.h"
#include "skymesh.h"
-#include "typedef.h"
-class LineListLabel;
-class SkyPainter;
+#include <QMutex>
+
+#include <memory>
+
class LineList;
+class LineListLabel;
class SkipList;
+class SkyPainter;
-/** @class LineListIndex
+/**
+ * @class LineListIndex
* Contains almost all the code needed for indexing and drawing and clipping
* lines and polygons.
*
@@ -41,127 +40,140 @@ class LineListIndex : public SkyComponent
{
friend class LinesItem; //Needs access to reindexLines
public:
- /** @short Constructor
- * Simply set the internal skyMesh, parent, and name.
- * @param parent Pointer to the parent SkyComponent object
- * @param mesh Pointer to the universal SkyMesh instance
- * @param name name of the subclass used for debugging
- */
+ /**
+ * @short Constructor
+ * Simply set the internal skyMesh, parent, and name.
+ * @param parent Pointer to the parent SkyComponent object
+ * @param mesh Pointer to the universal SkyMesh instance
+ * @param name name of the subclass used for debugging
+ */
explicit LineListIndex(SkyComposite *parent, const QString &name = "");
/** @short Destructor */
~LineListIndex();
- /** @short. The top level draw routine. Draws all the LineLists for any
- * subclass in one fell swoop which minimizes some of the loop overhead.
- * Overridden by MilkWay so it can decide whether to draw outlines or
- * filled. Therefore MilkyWay does not need to override preDraw(). The
- * MilkyWay draw() routine calls all of the more specific draw()
- * routines below.
- */
+ /**
+ * @short The top level draw routine. Draws all the LineLists for any
+ * subclass in one fell swoop which minimizes some of the loop overhead.
+ * Overridden by MilkWay so it can decide whether to draw outlines or
+ * filled. Therefore MilkyWay does not need to override preDraw(). The
+ * MilkyWay draw() routine calls all of the more specific draw()
+ * routines below.
+ */
void draw(SkyPainter *skyp) Q_DECL_OVERRIDE;
#ifdef KSTARS_LITE
/**
- * @short KStars Lite needs direct access to m_lineIndex for drawing the lines
- */
- inline LineListHash *lineIndex() const { return m_lineIndex; }
- inline LineListHash *polyIndex() const { return m_polyIndex; }
+ * @short KStars Lite needs direct access to m_lineIndex for drawing the lines
+ */
+ inline LineListHash *lineIndex() const { return m_lineIndex.get(); }
+ inline LineListHash *polyIndex() const { return m_polyIndex.get(); }
/** @short returns MeshIterator for currently visible trixels */
MeshIterator visibleTrixels();
#endif
//Moved to public because KStars Lite uses it
- /** @short this is called from within the draw routines when the updateID
- * of the lineList is stale. It is virtual because different subclasses
- * have different update routines. NoPrecessIndex doesn't precess in
- * the updates and ConstellationLines must update its points as stars,
- * not points. that doesn't precess the points.
- */
+ /**
+ * @short this is called from within the draw routines when the updateID
+ * of the lineList is stale. It is virtual because different subclasses
+ * have different update routines. NoPrecessIndex doesn't precess in
+ * the updates and ConstellationLines must update its points as stars,
+ * not points. that doesn't precess the points.
+ */
virtual void JITupdate(LineList *lineList);
protected:
- /** @short as the name says, recreates the lineIndex using the LineLists
- * in the previous index. Since we are indexing everything at J2000
- * this is only used by ConstellationLines which needs to reindex
- * because of the proper motion of the stars.
- */
+ /**
+ * @short as the name says, recreates the lineIndex using the LineLists
+ * in the previous index. Since we are indexing everything at J2000
+ * this is only used by ConstellationLines which needs to reindex
+ * because of the proper motion of the stars.
+ */
void reindexLines();
/** @short retrieve name of object */
QString name() const { return m_name; }
- /** @short displays a message that we are loading m_name. Also prints
- * out the message if skyMesh debug is greater than zero.
- */
+ /**
+ * @short displays a message that we are loading m_name. Also prints
+ * out the message if skyMesh debug is greater than zero.
+ */
void intro();
- /** @short prints out some summary statistics if the skyMesh debug is
- * greater than 1.
- */
+ /**
+ * @short prints out some summary statistics if the skyMesh debug is
+ * greater than 1.
+ */
void summary();
/** @short Returns the SkyMesh object. */
SkyMesh *skyMesh() { return m_skyMesh; }
- /** @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.
- */
+ /**
+ * @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(LineList *lineList, int debug = 0);
void removeLine(LineList *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.
- */
+ /**
+ * @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(LineList *lineList, int debug = 0);
- /** @short a convenience method that adds a lineList to both the lineIndex
- * and the polyIndex.
- */
+ /**
+ * @short a convenience method that adds a lineList to both the lineIndex and the polyIndex.
+ */
void appendBoth(LineList *lineList, int debug = 0);
- /** @short Draws all the lines in m_listList as simple lines in float
- * mode.
- */
+ /**
+ * @short Draws all the lines in m_listList as simple lines in float mode.
+ */
void drawLines(SkyPainter *skyp);
- /** @short Draws all the lines in m_listList as filled polygons in float
- * mode.
- */
+ /**
+ * @short Draws all the lines in m_listList as filled polygons in float
+ * mode.
+ */
void drawFilled(SkyPainter *skyp);
- /** @short Gives the subclasses access to the top of the draw() method.
- * Typically used for setting the QPen, etc. in the QPainter being
- * passed in. Defaults to setting a thin white pen.
- */
+ /**
+ * @short Gives the subclasses access to the top of the draw() method.
+ * Typically used for setting the QPen, etc. in the QPainter being
+ * passed in. Defaults to setting a thin white pen.
+ */
virtual void preDraw(SkyPainter *skyp);
- /** @short a callback overridden by NoPrecessIndex so it can use the
- * drawing code with the non-reverse-precessed mesh buffer.
- */
+ /**
+ * @short a callback overridden by NoPrecessIndex so it can use the
+ * drawing code with the non-reverse-precessed mesh buffer.
+ */
virtual MeshBufNum_t drawBuffer() { return DRAW_BUF; }
- /** @short Returns an IndexHash from the SkyMesh that contains the set of
- * trixels that cover lineList. Overridden by SkipListIndex so it can
- * pass SkyMesh an IndexHash indicating which line segments should not
- * be indexed @param lineList contains the list of points to be covered.
- */
+ /**
+ * @short Returns an IndexHash from the SkyMesh that contains the set of
+ * trixels that cover lineList. Overridden by SkipListIndex so it can
+ * pass SkyMesh an IndexHash indicating which line segments should not
+ * be indexed @param lineList contains the list of points to be covered.
+ */
virtual const IndexHash &getIndexHash(LineList *lineList);
- /** @short Also overridden by SkipListIndex.
- * Controls skipping inside of the draw() routines. The default behavior
- * is to simply return a null pointer.
- *
- * FIXME: I don't think that the SkipListIndex class even exists -- hdevalence
- */
+ /**
+ * @short Also overridden by SkipListIndex.
+ * Controls skipping inside of the draw() routines. The default behavior
+ * is to simply return a null pointer.
+ *
+ * FIXME: I don't think that the SkipListIndex class even exists -- hdevalence
+ */
virtual SkipList *skipList(LineList *lineList);
virtual LineListLabel *label() { return 0; }
@@ -171,13 +183,11 @@ class LineListIndex : public SkyComponent
private:
QString m_name;
- SkyMesh *m_skyMesh;
- LineListHash *m_lineIndex;
- LineListHash *m_polyIndex;
+ SkyMesh *m_skyMesh { nullptr };
+ std::unique_ptr<LineListHash> m_lineIndex;
+ std::unique_ptr<LineListHash> m_polyIndex;
LineListList m_listList;
QMutex mutex;
};
-
-#endif
diff --git a/kstars/skycomponents/linelistlabel.h b/kstars/skycomponents/linelistlabel.h
index fac861a..5802e24 100644
--- a/kstars/skycomponents/linelistlabel.h
+++ b/kstars/skycomponents/linelistlabel.h
@@ -16,21 +16,21 @@
* *
***************************************************************************/
-#ifndef LINE_LIST_LABEL_H
-#define LINE_LIST_LABEL_H
+#pragma once
#include <QPointF>
+#include <QString>
-class SkyLabeler;
-class Projector;
class LineList;
+class Projector;
+class SkyLabeler;
/**
- *@class LabelListIndex
- *An abstract parent class to be inherited by Ecliptic and Equator.
+ * @class LabelListIndex
+ * An abstract parent class to be inherited by Ecliptic and Equator.
*
- *@author James B. Bowlin
- *@version 0.1
+ * @author James B. Bowlin
+ * @version 0.1
*/
class LineListLabel
{
@@ -45,15 +45,14 @@ class LineListLabel
RightCandidate
};
- /** @short prepare the context for selecting label position candidates.
- */
+ /** @short prepare the context for selecting label position candidates. */
void reset();
- /** @short draw the label if any. Is currently called at the bottom of
- * draw() but that call could be removed and it could be called
- * externally AFTER draw() has been called so draw() can set up the label
- * position candidates.
- */
+ /**
+ * @short draw the label if any. Is currently called at the bottom of draw() but that call could
+ * be removed and it could be called externally AFTER draw() has been called so draw() can set
+ * up the label position candidates.
+ */
void draw();
void updateLabelCandidates(qreal x, qreal y, LineList *lineList, int i);
@@ -69,13 +68,12 @@ class LineListLabel
float m_marginLeft, m_marginRight, m_marginTop, m_marginBot;
float m_farLeft, m_farRight, m_farTop, m_farBot;
- /** @short This routine does two things at once. It returns the QPointF
- * corresponding to pointList[i] and also computes the angle using
- * pointList[i] and pointList[i-1] therefore you MUST ensure that:
- *
- * 1 <= i < pointList.size().
- */
+ /**
+ * @short This routine does two things at once. It returns the QPointF
+ * corresponding to pointList[i] and also computes the angle using
+ * pointList[i] and pointList[i-1] therefore you MUST ensure that:
+ *
+ * 1 <= i < pointList.size().
+ */
QPointF angleAt(const Projector *proj, LineList *list, int i, double *angle);
};
-
-#endif
diff --git a/kstars/skycomponents/listcomponent.cpp b/kstars/skycomponents/listcomponent.cpp
index e9ce811..a2e252f 100644
--- a/kstars/skycomponents/listcomponent.cpp
+++ b/kstars/skycomponents/listcomponent.cpp
@@ -17,13 +17,10 @@
#include "listcomponent.h"
-#include <QList>
-
#include "kstarsdata.h"
#ifndef KSTARS_LITE
#include "skymap.h"
#endif
-#include "skyobjects/skyobject.h"
ListComponent::ListComponent(SkyComposite *parent) : SkyComponent(parent)
{
@@ -31,6 +28,8 @@ ListComponent::ListComponent(SkyComposite *parent) : SkyComponent(parent)
ListComponent::~ListComponent()
{
+ qDeleteAll(m_ObjectList);
+ m_ObjectList.clear();
clear();
}
diff --git a/kstars/skycomponents/listcomponent.h b/kstars/skycomponents/listcomponent.h
index 5c00c92..d8b2767 100644
--- a/kstars/skycomponents/listcomponent.h
+++ b/kstars/skycomponents/listcomponent.h
@@ -15,23 +15,21 @@
* *
***************************************************************************/
-#ifndef LISTCOMPONENT_H
-#define LISTCOMPONENT_H
-
-#include <QList>
+#pragma once
#include "skycomponent.h"
+#include <QList>
+
class SkyComposite;
class SkyMap;
/**
- *@class ListComponent
- *An abstract parent class, to be inherited by SkyComponents that store a QList
- *of SkyObjects.
+ * @class ListComponent
+ * An abstract parent class, to be inherited by SkyComponents that store a QList of SkyObjects.
*
- *@author Jason Harris
- *@version 0.1
+ * @author Jason Harris
+ * @version 0.1
*/
class ListComponent : public SkyComponent
{
@@ -40,17 +38,18 @@ class ListComponent : public SkyComponent
virtual ~ListComponent();
- /** @short Update the sky positions of this component.
- *
- * This function usually just updates the Horizontal (Azimuth/Altitude)
- * coordinates of the objects in this component. If the KSNumbers*
- * argument is not nullptr, this function also recomputes precession and
- * nutation for the date in KSNumbers.
- * @p num Pointer to the KSNumbers object
- * @note By default, the num parameter is nullptr, indicating that
- * Precession/Nutation computation should be skipped; this computation
- * is only occasionally required.
- */
+ /**
+ * @short Update the sky positions of this component.
+ *
+ * This function usually just updates the Horizontal (Azimuth/Altitude)
+ * coordinates of the objects in this component. If the KSNumbers*
+ * argument is not nullptr, this function also recomputes precession and
+ * nutation for the date in KSNumbers.
+ * @p num Pointer to the KSNumbers object
+ * @note By default, the num parameter is nullptr, indicating that
+ * Precession/Nutation computation should be skipped; this computation
+ * is only occasionally required.
+ */
void update(KSNumbers *num = 0) Q_DECL_OVERRIDE;
SkyObject *findByName(const QString &name) Q_DECL_OVERRIDE;
@@ -63,5 +62,3 @@ class ListComponent : public SkyComponent
protected:
QList<SkyObject *> m_ObjectList;
};
-
-#endif
diff --git a/kstars/skycomponents/milkyway.cpp b/kstars/skycomponents/milkyway.cpp
index 6721443..73beedd 100644
--- a/kstars/skycomponents/milkyway.cpp
+++ b/kstars/skycomponents/milkyway.cpp
@@ -17,28 +17,18 @@
#include "milkyway.h"
-#include <QList>
-#include <QPointF>
-#include <QPolygonF>
-#include <QtConcurrent>
-
-#include <KLocalizedString>
-
+#include "ksfilereader.h"
#include "kstarsdata.h"
#ifdef KSTARS_LITE
#include "skymaplite.h"
#else
#include "skymap.h"
#endif
-#include "skyobjects/skypoint.h"
-#include "dms.h"
#include "Options.h"
-#include "ksfilereader.h"
+#include "skypainter.h"
#include "skycomponents/skiplist.h"
-#include "skymesh.h"
-
-#include "skypainter.h"
+#include <QtConcurrent>
MilkyWay::MilkyWay(SkyComposite *parent) : LineListIndex(parent, i18n("Milky Way"))
{
@@ -100,12 +90,13 @@ void MilkyWay::draw(SkyPainter *skyp)
void MilkyWay::loadContours(QString fname, QString greeting)
{
KSFileReader fileReader;
+ SkipList *skipList = nullptr;
+ int iSkip = 0;
+
if (!fileReader.open(fname))
return;
- fileReader.setProgress(greeting, 2136, 5);
- SkipList *skipList = 0;
- int iSkip = 0;
+ fileReader.setProgress(greeting, 2136, 5);
while (fileReader.hasMoreLines())
{
QString line = fileReader.readLine();
@@ -115,7 +106,7 @@ void MilkyWay::loadContours(QString fname, QString greeting)
if (firstChar == '#')
continue;
- bool okRA, okDec;
+ bool okRA = false, okDec = false;
double ra = line.mid(2, 8).toDouble(&okRA);
double dec = line.mid(11, 8).toDouble(&okDec);
if (!okRA || !okDec)
@@ -128,7 +119,7 @@ void MilkyWay::loadContours(QString fname, QString greeting)
{
if (skipList)
appendBoth(skipList);
- skipList = 0;
+ skipList = nullptr;
iSkip = 0;
}
diff --git a/kstars/skycomponents/milkyway.h b/kstars/skycomponents/milkyway.h
index e71d782..8aa2e04 100644
--- a/kstars/skycomponents/milkyway.h
+++ b/kstars/skycomponents/milkyway.h
@@ -15,12 +15,12 @@
* *
***************************************************************************/
-#ifndef MILKYWAY_H
-#define MILKYWAY_H
+#pragma once
#include "linelistindex.h"
-/** @class MlkyWay
+/**
+ * @class MlkyWay
*
* Draw filled areas as Milky Way and Magellanic clouds.
*
@@ -37,9 +37,10 @@ class MilkyWay : public LineListIndex
friend class MilkyWayItem;
public:
- /** @short Constructor
- * @p parent pointer to the parent SkyComposite
- */
+ /**
+ * @short Constructor
+ * @p parent pointer to the parent SkyComposite
+ */
explicit MilkyWay(SkyComposite *parent);
/** Load skiplists from file */
@@ -49,20 +50,21 @@ class MilkyWay : public LineListIndex
bool selected() Q_DECL_OVERRIDE;
protected:
- /** @short Returns an IndexHash from the SkyMesh that contains the set
- * of trixels that cover the _SkipList_ lineList excluding skipped
- * lines as specified in the SkipList. SkipList is a subclass of
- * LineList.
- * FIXME: Implementation is broken!!
- */
+ /**
+ * @short Returns an IndexHash from the SkyMesh that contains the set
+ * of trixels that cover the _SkipList_ lineList excluding skipped
+ * lines as specified in the SkipList. SkipList is a subclass of
+ * LineList.
+ * FIXME: Implementation is broken!!
+ */
const IndexHash &getIndexHash(LineList *skipList) Q_DECL_OVERRIDE;
- /** @short Returns a boolean indicating whether to skip the i-th line
- * segment in the _SkipList_ skipList. Note that SkipList is a
- * subclass of LineList. This routine allows us to use the drawing
- * code in LineListIndex instead of repeating it all here.
- * FIXME: Implementation is broken!!
- */
+ /**
+ * @short Returns a boolean indicating whether to skip the i-th line
+ * segment in the _SkipList_ skipList. Note that SkipList is a
+ * subclass of LineList. This routine allows us to use the drawing
+ * code in LineListIndex instead of repeating it all here.
+ * FIXME: Implementation is broken!!
+ */
SkipList *skipList(LineList *lineList) Q_DECL_OVERRIDE;
};
-#endif
diff --git a/kstars/skycomponents/noprecessindex.h b/kstars/skycomponents/noprecessindex.h
index 9f6ec93..7f44519 100644
--- a/kstars/skycomponents/noprecessindex.h
+++ b/kstars/skycomponents/noprecessindex.h
@@ -15,12 +15,12 @@
* *
***************************************************************************/
-#ifndef NO_PRECESS_INDEX_H
-#define NO_PRECESS_INDEX_H
+#pragma once
#include "linelistindex.h"
-/** @class NoPrecessIndex
+/**
+ * @class NoPrecessIndex
*
* @author James B. Bowlin
* @version 0.1
@@ -32,16 +32,16 @@ class NoPrecessIndex : public LineListIndex
NoPrecessIndex(SkyComposite *parent, const QString &name);
//Moved to public because KStars Lite uses it
- /** @ short override JITupdate so we don't perform the precession
- * correction, only rotation.
- */
+ /**
+ * @ short override JITupdate so we don't perform the precession
+ * correction, only rotation.
+ */
void JITupdate(LineList *lineList) Q_DECL_OVERRIDE;
protected:
- /** @short we need to use the buffer that does not have the
- * reverse-precession correction.
- */
+ /**
+ * @short we need to use the buffer that does not have the
+ * reverse-precession correction.
+ */
MeshBufNum_t drawBuffer() Q_DECL_OVERRIDE { return NO_PRECESS_BUF; }
};
-
-#endif
diff --git a/kstars/skycomponents/pointlistcomponent.cpp b/kstars/skycomponents/pointlistcomponent.cpp
index 12166b9..5763c9c 100644
--- a/kstars/skycomponents/pointlistcomponent.cpp
+++ b/kstars/skycomponents/pointlistcomponent.cpp
@@ -26,7 +26,6 @@ PointListComponent::PointListComponent(SkyComposite *parent) : SkyComponent(pare
PointListComponent::~PointListComponent()
{
- qDeleteAll(pointList());
}
void PointListComponent::update(KSNumbers *num)
diff --git a/kstars/skycomponents/polylist.h b/kstars/skycomponents/polylist.h
index 86564f4..59c6400 100644
--- a/kstars/skycomponents/polylist.h
+++ b/kstars/skycomponents/polylist.h
@@ -34,7 +34,7 @@ class PolyList
/* @short trivial constructor that also sets the name. It was
* convenient to specify the name at construction time.
*/
- explicit PolyList(QString name) : m_wrapRA(false) { m_name = name; };
+ explicit PolyList(const QString& name) : m_wrapRA(false) { m_name = name; };
/* @short returns the QPolygonF that holds the points. */
const QPolygonF *poly() { return &m_poly; }
diff --git a/kstars/skycomponents/satellitescomponent.cpp b/kstars/skycomponents/satellitescomponent.cpp
index 25d6407..d72842a 100644
--- a/kstars/skycomponents/satellitescomponent.cpp
+++ b/kstars/skycomponents/satellitescomponent.cpp
@@ -38,6 +38,8 @@ SatellitesComponent::SatellitesComponent(SkyComposite *parent) : SkyComponent(pa
SatellitesComponent::~SatellitesComponent()
{
+ qDeleteAll(m_groups);
+ m_groups.clear();
}
void SatellitesComponent::loadData()
diff --git a/kstars/skycomponents/skiplist.h b/kstars/skycomponents/skiplist.h
index 4560dd3..822b53b 100644
--- a/kstars/skycomponents/skiplist.h
+++ b/kstars/skycomponents/skiplist.h
@@ -15,14 +15,12 @@
* *
***************************************************************************/
-#ifndef SKIPLIST_H
-#define SKIPLIST_H
-
-#include <QHash>
+#pragma once
#include "linelist.h"
-/* @class SkipList
+/**
+ * @class SkipList
* Extends LineList by adding the skip hash to allow the same the data in a
* LineList to be drawn as a filled and an outlined polygon.
*
@@ -34,24 +32,22 @@
class SkipList : public LineList
{
public:
- /* @short returns the entire skip hash. Used by the
- * indexLines() routine so all the line segments in
- * this SkipList can be indexed at once.
- */
+ /**
+ * @short returns the entire skip hash.
+ * Used by the indexLines() routine so all the line segments in
+ * this SkipList can be indexed at once.
+ */
IndexHash *skipHash() { return &m_skip; }
- /* @short instructs that the ith line segment should
- * be skipped when drawn (and hence when indexed too).
- */
+ /**
+ * @short instructs that the ith line segment should
+ * be skipped when drawn (and hence when indexed too).
+ */
void setSkip(int i) { m_skip[i] = true; }
- /* @short returns the skip flag for the i-th line
- * segment.
- */
+ /** @short returns the skip flag for the i-th line segment. */
bool skip(int i) { return m_skip.contains(i); }
private:
IndexHash m_skip;
};
-
-#endif
diff --git a/kstars/skycomponents/skycomponent.cpp b/kstars/skycomponents/skycomponent.cpp
index f547c0b..8dafe19 100644
--- a/kstars/skycomponents/skycomponent.cpp
+++ b/kstars/skycomponents/skycomponent.cpp
@@ -55,11 +55,25 @@ void SkyComponent::objectsInArea(QList<SkyObject *> &, const SkyRegion &)
QHash<int, QStringList> &SkyComponent::getObjectNames()
{
+ if (!parent())
+ {
+ // Use a fake list if there is no parent object
+ static QHash<int, QStringList> temp;
+
+ return temp;
+ }
return parent()->objectNames();
}
QHash<int, QVector<QPair<QString, const SkyObject *>>> &SkyComponent::getObjectLists()
{
+ if (!parent())
+ {
+ // Use a fake list if there is no parent object
+ static QHash<int, QVector<QPair<QString, const SkyObject *>>> temp;
+
+ return temp;
+ }
return parent()->objectLists();
}
diff --git a/kstars/skycomponents/skycomposite.cpp b/kstars/skycomponents/skycomposite.cpp
index a0b3f9f..d9b0b36 100644
--- a/kstars/skycomponents/skycomposite.cpp
+++ b/kstars/skycomponents/skycomposite.cpp
@@ -26,6 +26,7 @@ SkyComposite::SkyComposite(SkyComposite *parent) : SkyComponent(parent)
SkyComposite::~SkyComposite()
{
qDeleteAll(components());
+ m_Components.clear();
}
void SkyComposite::addComponent(SkyComponent *component, int priority)
diff --git a/kstars/skycomponents/skymapcomposite.cpp b/kstars/skycomponents/skymapcomposite.cpp
index 98ee9ad..676f4c3 100644
--- a/kstars/skycomponents/skymapcomposite.cpp
+++ b/kstars/skycomponents/skymapcomposite.cpp
@@ -17,61 +17,50 @@
#include "skymapcomposite.h"
-#include <QPolygonF>
-#include <QApplication>
-
-#include "Options.h"
-#include "kstarsdata.h"
-#ifndef KSTARS_LITE
-#include "skymap.h"
-#include "ksutils.h"
-#endif
-#include "skyobjects/starobject.h"
-#include "skyobjects/deepskyobject.h"
-#include "skyobjects/ksplanet.h"
-#include "skyobjects/constellationsart.h"
-
-#include "targetlistcomponent.h"
+#include "artificialhorizoncomponent.h"
+#include "catalogcomponent.h"
+#include "constellationartcomponent.h"
#include "constellationboundarylines.h"
#include "constellationlines.h"
-#include "culturelist.h"
#include "constellationnamescomponent.h"
-#include "equatorialcoordinategrid.h"
-#include "horizontalcoordinategrid.h"
-#include "catalogcomponent.h"
-#include "syncedcatalogcomponent.h"
+#include "culturelist.h"
#include "deepskycomponent.h"
-#include "equator.h"
-#include "artificialhorizoncomponent.h"
+#include "deepstarcomponent.h"
#include "ecliptic.h"
+#include "equator.h"
+#include "equatorialcoordinategrid.h"
#include "horizoncomponent.h"
+#include "horizontalcoordinategrid.h"
+#include "ksasteroid.h"
+#include "kscomet.h"
+#include "kstarsdata.h"
#include "milkyway.h"
+#include "satellitescomponent.h"
+#include "skylabeler.h"
+#include "skypainter.h"
#include "solarsystemcomposite.h"
#include "starcomponent.h"
-#include "deepstarcomponent.h"
-#include "satellitescomponent.h"
#include "supernovaecomponent.h"
-#include "constellationartcomponent.h"
-#include "kscomet.h"
-#include "ksasteroid.h"
+#include "syncedcatalogcomponent.h"
+#include "targetlistcomponent.h"
+#include "projections/projector.h"
+#include "skyobjects/deepskyobject.h"
+#include "skyobjects/ksplanet.h"
+#include "skyobjects/constellationsart.h"
#ifndef KSTARS_LITE
-#include "observinglist.h"
-
#include "flagcomponent.h"
+#include "ksutils.h"
+#include "observinglist.h"
+#include "skymap.h"
#endif
-#include "skymesh.h"
-#include "skylabeler.h"
-#include "skypainter.h"
-#include "projections/projector.h"
-
-#include "typedef.h"
+#include <QApplication>
SkyMapComposite::SkyMapComposite(SkyComposite *parent) : SkyComposite(parent), m_reindexNum(J2000)
{
- m_skyLabeler = SkyLabeler::Instance();
- m_skyMesh = SkyMesh::Create(3); // level 5 mesh = 8192 trixels
+ m_skyLabeler.reset(SkyLabeler::Instance());
+ m_skyMesh.reset(SkyMesh::Create(3)); // level 5 mesh = 8192 trixels
m_skyMesh->debug(0);
// 1 => print "indexing ..."
// 2 => prints totals too
@@ -89,14 +78,14 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent) : SkyComposite(parent), m
// Do add to components.
addComponent(m_CBoundLines = new ConstellationBoundaryLines(this), 80);
- m_Cultures = new CultureList();
- addComponent(m_CLines = new ConstellationLines(this, m_Cultures), 85);
- addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures), 90);
+ m_Cultures.reset(new CultureList());
+ addComponent(m_CLines = new ConstellationLines(this, m_Cultures.get()), 85);
+ addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures.get()), 90);
addComponent(m_Equator = new Equator(this), 95);
addComponent(m_Ecliptic = new Ecliptic(this), 95);
addComponent(m_Horizon = new HorizonComponent(this), 100);
addComponent(m_DeepSky = new DeepSkyComponent(this), 5);
- addComponent(m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures), 100);
+ addComponent(m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures.get()), 100);
addComponent(m_ArtificialHorizon = new ArtificialHorizonComponent(this), 110);
@@ -104,7 +93,7 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent) : SkyComposite(parent), m
m_manualAdditionsCat = "_Manual_Additions";
addComponent(m_internetResolvedComponent = new SyncedCatalogComponent(this, m_internetResolvedCat, true, 0), 6);
addComponent(m_manualAdditionsComponent = new SyncedCatalogComponent(this, m_manualAdditionsCat, true, 0), 6);
- m_CustomCatalogs = new SkyComposite(this);
+ m_CustomCatalogs.reset(new SkyComposite(this));
QStringList allcatalogs = Options::showCatalogNames();
if (!allcatalogs.contains(m_internetResolvedCat))
@@ -142,14 +131,14 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent) : SkyComposite(parent), m
// Do add to components.
addComponent(m_CBoundLines = new ConstellationBoundaryLines(this), 80);
- m_Cultures = new CultureList();
- addComponent(m_CLines = new ConstellationLines(this, m_Cultures), 85);
- addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures), 90);
+ m_Cultures.reset(new CultureList());
+ addComponent(m_CLines = new ConstellationLines(this, m_Cultures.get()), 85);
+ addComponent(m_CNames = new ConstellationNamesComponent(this, m_Cultures.get()), 90);
addComponent(m_Equator = new Equator(this), 95);
addComponent(m_Ecliptic = new Ecliptic(this), 95);
addComponent(m_Horizon = new HorizonComponent(this), 100);
addComponent(m_DeepSky = new DeepSkyComponent(this), 5);
- addComponent(m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures), 100);
+ addComponent(m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures.get()), 100);
addComponent(m_ArtificialHorizon = new ArtificialHorizonComponent(this), 110);
@@ -157,7 +146,7 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent) : SkyComposite(parent), m
m_manualAdditionsCat = "_Manual_Additions";
addComponent(m_internetResolvedComponent = new SyncedCatalogComponent(this, m_internetResolvedCat, true, 0), 6);
addComponent(m_manualAdditionsComponent = new SyncedCatalogComponent(this, m_manualAdditionsCat, true, 0), 6);
- m_CustomCatalogs = new SkyComposite(this);
+ m_CustomCatalogs.reset(new SkyComposite(this));
QStringList allcatalogs = Options::showCatalogNames();
for (int i = 0; i < allcatalogs.size(); ++i)
{
@@ -185,12 +174,6 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent) : SkyComposite(parent), m
SkyMapComposite::~SkyMapComposite()
{
- delete m_skyLabeler; // These are on the heap to avoid header file hell.
- delete m_skyMesh;
- delete m_Cultures;
-#ifndef KSTARS_LITE
- delete m_Flags;
-#endif
}
void SkyMapComposite::update(KSNumbers *num)
@@ -693,7 +676,7 @@ void SkyMapComposite::reloadCLines()
true); // This is not (yet) multithreaded, so I think we don't have to worry about overwriting the state of an existing lock --asimha
delete m_CLines;
m_CLines = 0;
- m_CLines = new ConstellationLines(this, m_Cultures);
+ m_CLines = new ConstellationLines(this, m_Cultures.get());
SkyMapDrawAbstract::setDrawLock(false);
#endif
}
@@ -705,11 +688,11 @@ void SkyMapComposite::reloadCNames()
// objectNames(SkyObject::CONSTELLATION).clear();
// delete m_CNames;
// m_CNames = 0;
- // m_CNames = new ConstellationNamesComponent( this, m_Cultures );
+ // m_CNames = new ConstellationNamesComponent( this, m_Cultures.get() );
// SkyMapDrawAbstract::setDrawLock( false );
objectNames(SkyObject::CONSTELLATION).clear();
delete m_CNames;
- m_CNames = new ConstellationNamesComponent(this, m_Cultures);
+ m_CNames = new ConstellationNamesComponent(this, m_Cultures.get());
}
void SkyMapComposite::reloadConstellationArt()
@@ -719,7 +702,7 @@ void SkyMapComposite::reloadConstellationArt()
SkyMapDrawAbstract::setDrawLock(true);
delete m_ConstellationArt;
m_ConstellationArt = 0;
- m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures);
+ m_ConstellationArt = new ConstellationArtComponent(this, m_Cultures.get());
SkyMapDrawAbstract::setDrawLock(false);
#endif
}
@@ -747,8 +730,7 @@ void SkyMapComposite::reloadDeepSky()
// list really bad to delete and regenerate SkyObjects.
SkyMapDrawAbstract::setDrawLock(true);
- delete m_CustomCatalogs;
- m_CustomCatalogs = new SkyComposite(this);
+ m_CustomCatalogs.reset(new SkyComposite(this));
delete m_internetResolvedComponent;
addComponent(m_internetResolvedComponent = new SyncedCatalogComponent(this, m_internetResolvedCat, true, 0), 6);
delete m_manualAdditionsComponent;
diff --git a/kstars/skycomponents/skymapcomposite.h b/kstars/skycomponents/skymapcomposite.h
index 45128b4..6bed237 100644
--- a/kstars/skycomponents/skymapcomposite.h
+++ b/kstars/skycomponents/skymapcomposite.h
@@ -15,67 +15,67 @@
* *
***************************************************************************/
-#ifndef SKYMAPCOMPOSITE_H
-#define SKYMAPCOMPOSITE_H
-
-#include <QList>
+#pragma once
#include "skycomposite.h"
#include "ksnumbers.h"
#include "skyobject.h"
-class SkyMesh;
-class SkyLabeler;
-class SkyMap;
+#include <QList>
+
+#include <memory>
class QPolygonF;
-class CultureList;
+class ArtificialHorizonComponent;
+class ConstellationArtComponent;
class ConstellationBoundaryLines;
class ConstellationLines;
class ConstellationNamesComponent;
-class EquatorialCoordinateGrid;
-class HorizontalCoordinateGrid;
+class ConstellationsArt;
+class CultureList;
class DeepSkyComponent;
+class DeepSkyObject;
+class DeepStarComponent;
class Ecliptic;
class Equator;
-class ArtificialHorizonComponent;
+class EquatorialCoordinateGrid;
class FlagComponent;
+class HorizontalCoordinateGrid;
class HorizonComponent;
+class KSPlanet;
+class KSPlanetBase;
class MilkyWay;
+class SatellitesComponent;
+class SkyLabeler;
+class SkyMap;
+class SkyMesh;
+class SkyObject;
class SolarSystemComposite;
class StarComponent;
-class DeepStarComponent;
-class TargetListComponent;
-class TargetListComponent;
-class SatellitesComponent;
class SupernovaeComponent;
-class ConstellationArtComponent;
-
-class DeepSkyObject;
-class KSPlanetBase;
-class KSPlanet;
-class ConstellationsArt;
class SyncedCatalogComponent;
+class TargetListComponent;
-/** @class SkyMapComposite
-*SkyMapComposite is the root object in the object hierarchy of the sky map.
-*All requests to update, init, draw etc. will be done with this class.
-*The requests will be delegated to it's children.
-*The object hierarchy will created by adding new objects via addComponent().
-*
-*@author Thomas Kabelmann
-*@version 0.1
-*/
+/**
+ * @class SkyMapComposite
+ * SkyMapComposite is the root object in the object hierarchy of the sky map.
+ * All requests to update, init, draw etc. will be done with this class.
+ * The requests will be delegated to it's children.
+ * The object hierarchy will created by adding new objects via addComponent().
+ *
+ * @author Thomas Kabelmann
+ * @version 0.1
+ */
class SkyMapComposite : public QObject, public SkyComposite
{
Q_OBJECT
public:
/**
- *Constructor
- *@p parent pointer to the parent SkyComponent
- */
+ * Constructor
+ * @p parent pointer to the parent SkyComponent
+ */
explicit SkyMapComposite(SkyComposite *parent = nullptr);
~SkyMapComposite();
@@ -83,79 +83,79 @@ class SkyMapComposite : public QObject, public SkyComposite
void update(KSNumbers *num = 0) Q_DECL_OVERRIDE;
/**
- *@short Delegate planet position updates to the SolarSystemComposite
- *
- *Planet positions change over time, so they need to be recomputed
- *periodically, but not on every call to update(). This function
- *will recompute the positions of all solar system bodies except the
- *Earth's Moon, Jupiter's Moons AND Saturn Moons (because these objects' positions
- *change on a much more rapid timescale).
- *@p num Pointer to the KSNumbers object
- *@sa update()
- *@sa updateMoons()
- *@sa SolarSystemComposite::updatePlanets()
- */
+ * @short Delegate planet position updates to the SolarSystemComposite
+ *
+ * Planet positions change over time, so they need to be recomputed
+ * periodically, but not on every call to update(). This function
+ * will recompute the positions of all solar system bodies except the
+ * Earth's Moon, Jupiter's Moons AND Saturn Moons (because these objects' positions
+ * change on a much more rapid timescale).
+ * @p num Pointer to the KSNumbers object
+ * @sa update()
+ * @sa updateMoons()
+ * @sa SolarSystemComposite::updatePlanets()
+ */
void updateSolarSystemBodies(KSNumbers *num) Q_DECL_OVERRIDE;
/**
- *@short Delegate moon position updates to the SolarSystemComposite
- *
- *Planet positions change over time, so they need to be recomputed
- *periodically, but not on every call to update(). This function
- *will recompute the positions of the Earth's Moon and Jupiter's four
- *Galilean moons. These objects are done separately from the other
- *solar system bodies, because their positions change more rapidly,
- *and so updateMoons() must be called more often than updatePlanets().
- *@p num Pointer to the KSNumbers object
- *@sa update()
- *@sa updatePlanets()
- *@sa SolarSystemComposite::updateMoons()
- */
+ * @short Delegate moon position updates to the SolarSystemComposite
+ *
+ * Planet positions change over time, so they need to be recomputed
+ * periodically, but not on every call to update(). This function
+ * will recompute the positions of the Earth's Moon and Jupiter's four
+ * Galilean moons. These objects are done separately from the other
+ * solar system bodies, because their positions change more rapidly,
+ * and so updateMoons() must be called more often than updatePlanets().
+ * @p num Pointer to the KSNumbers object
+ * @sa update()
+ * @sa updatePlanets()
+ * @sa SolarSystemComposite::updateMoons()
+ */
// virtual void updateMoons( KSNumbers *num );
/**
- *@short Delegate draw requests to all sub components
- *@p psky Reference to the QPainter on which to paint
- */
+ * @short Delegate draw requests to all sub components
+ * @p psky Reference to the QPainter on which to paint
+ */
void draw(SkyPainter *skyp) Q_DECL_OVERRIDE;
/**
- *@return the object nearest a given point in the sky.
- *@param p The point to find an object near
- *@param maxrad The maximum search radius, in Degrees
- *@note the angular separation to the matched object is returned
- *through the maxrad variable.
- */
+ * @return the object nearest a given point in the sky.
+ * @param p The point to find an object near
+ * @param maxrad The maximum search radius, in Degrees
+ * @note the angular separation to the matched object is returned
+ * through the maxrad variable.
+ */
SkyObject *objectNearest(SkyPoint *p, double &maxrad) Q_DECL_OVERRIDE;
/**
- *@return the star nearest a given point in the sky.
- *@param p The point to find a star near
- *@param maxrad The maximum search radius, in Degrees
- *@note the angular separation to the matched star is returned
- *through the maxrad variable.
- */
+ * @return the star nearest a given point in the sky.
+ * @param p The point to find a star near
+ * @param maxrad The maximum search radius, in Degrees
+ * @note the angular separation to the matched star is returned
+ * through the maxrad variable.
+ */
SkyObject *starNearest(SkyPoint *p, double &maxrad);
/**
- *@short Search the children of this SkyMapComposite for
- *a SkyObject whose name matches the argument.
- *
- *The objects' primary, secondary and long-form names will
- *all be checked for a match.
- *@note Overloaded from SkyComposite. In this version, we search
- *the most likely object classes first to be more efficient.
- *@p name the name to be matched
- *@return a pointer to the SkyObject whose name matches
- *the argument, or a nullptr pointer if no match was found.
- */
+ * @short Search the children of this SkyMapComposite for
+ * a SkyObject whose name matches the argument.
+ *
+ * The objects' primary, secondary and long-form names will
+ * all be checked for a match.
+ * @note Overloaded from SkyComposite. In this version, we search
+ * the most likely object classes first to be more efficient.
+ * @p name the name to be matched
+ * @return a pointer to the SkyObject whose name matches
+ * the argument, or a nullptr pointer if no match was found.
+ */
SkyObject *findByName(const QString &name) Q_DECL_OVERRIDE;
/**
- *@return the list of objects in the region defined by skypoints
- *@param p1 first sky point (top-left vertex of rectangular region)
- *@param p2 second sky point (bottom-right vertex of rectangular region)
- */
+ * @return the list of objects in the region defined by skypoints
+ * @param p1 first sky point (top-left vertex of rectangular region)
+ * @param p2 second sky point (bottom-right vertex of rectangular region)
+ */
QList<SkyObject *> findObjectsInArea(const SkyPoint &p1, const SkyPoint &p2);
void addCustomCatalog(const QString &filename, int index);
@@ -236,34 +236,34 @@ class SkyMapComposite : public QObject, public SkyComposite
QHash<int, QStringList> &getObjectNames() Q_DECL_OVERRIDE;
QHash<int, QVector<QPair<QString, const SkyObject *>>> &getObjectLists() Q_DECL_OVERRIDE;
- CultureList *m_Cultures;
- ConstellationBoundaryLines *m_CBoundLines;
- ConstellationNamesComponent *m_CNames;
- ConstellationLines *m_CLines;
- ConstellationArtComponent *m_ConstellationArt;
- EquatorialCoordinateGrid *m_EquatorialCoordinateGrid;
- HorizontalCoordinateGrid *m_HorizontalCoordinateGrid;
- DeepSkyComponent *m_DeepSky;
- Equator *m_Equator;
- ArtificialHorizonComponent *m_ArtificialHorizon;
- Ecliptic *m_Ecliptic;
- HorizonComponent *m_Horizon;
- MilkyWay *m_MilkyWay;
- SolarSystemComposite *m_SolarSystem;
- SkyComposite *m_CustomCatalogs;
- StarComponent *m_Stars;
+ std::unique_ptr<CultureList> m_Cultures;
+ ConstellationBoundaryLines *m_CBoundLines { nullptr };
+ ConstellationNamesComponent *m_CNames { nullptr };
+ ConstellationLines *m_CLines { nullptr };
+ ConstellationArtComponent *m_ConstellationArt { nullptr };
+ EquatorialCoordinateGrid *m_EquatorialCoordinateGrid { nullptr };
+ HorizontalCoordinateGrid *m_HorizontalCoordinateGrid { nullptr };
+ DeepSkyComponent *m_DeepSky { nullptr };
+ Equator *m_Equator { nullptr };
+ ArtificialHorizonComponent *m_ArtificialHorizon { nullptr };
+ Ecliptic *m_Ecliptic { nullptr };
+ HorizonComponent *m_Horizon { nullptr };
+ MilkyWay *m_MilkyWay { nullptr };
+ SolarSystemComposite *m_SolarSystem { nullptr };
+ std::unique_ptr<SkyComposite> m_CustomCatalogs;
+ StarComponent *m_Stars { nullptr };
#ifndef KSTARS_LITE
- FlagComponent *m_Flags;
+ FlagComponent *m_Flags { nullptr };
#endif
- TargetListComponent *m_ObservingList;
- TargetListComponent *m_StarHopRouteList;
- SatellitesComponent *m_Satellites;
- SupernovaeComponent *m_Supernovae;
- SyncedCatalogComponent *m_internetResolvedComponent;
- SyncedCatalogComponent *m_manualAdditionsComponent;
+ TargetListComponent *m_ObservingList { nullptr };
+ TargetListComponent *m_StarHopRouteList { nullptr };
+ SatellitesComponent *m_Satellites { nullptr };
+ SupernovaeComponent *m_Supernovae { nullptr };
+ SyncedCatalogComponent *m_internetResolvedComponent { nullptr };
+ SyncedCatalogComponent *m_manualAdditionsComponent { nullptr };
- SkyMesh *m_skyMesh;
- SkyLabeler *m_skyLabeler;
+ std::unique_ptr<SkyMesh> m_skyMesh;
+ std::unique_ptr<SkyLabeler> m_skyLabeler;
KSNumbers m_reindexNum;
@@ -276,5 +276,3 @@ class SkyMapComposite : public QObject, public SkyComposite
QString m_internetResolvedCat; // Holds the name of the internet resolved catalog
QString m_manualAdditionsCat;
};
-
-#endif
diff --git a/kstars/skycomponents/solarsystemcomposite.cpp b/kstars/skycomponents/solarsystemcomposite.cpp
index 1aa435b..dec00ea 100644
--- a/kstars/skycomponents/solarsystemcomposite.cpp
+++ b/kstars/skycomponents/solarsystemcomposite.cpp
@@ -17,24 +17,16 @@
#include "solarsystemcomposite.h"
-#include <KLocalizedString>
-
-#include "solarsystemsinglecomponent.h"
#include "asteroidscomponent.h"
#include "cometscomponent.h"
-#include "skycomponent.h"
-
#include "Options.h"
#ifndef KSTARS_LITE
#include "skymap.h"
#endif
-#include "kstarsdata.h"
-#include "ksnumbers.h"
+#include "solarsystemsinglecomponent.h"
+#include "skyobjects/ksmoon.h"
#include "skyobjects/ksplanet.h"
#include "skyobjects/kssun.h"
-#include "skyobjects/ksmoon.h"
-//#include "skyobjects/kspluto.h"
-#include "planetmoonscomponent.h"
SolarSystemComposite::SolarSystemComposite(SkyComposite *parent) : SkyComposite(parent)
{
diff --git a/kstars/skycomponents/solarsystemcomposite.h b/kstars/skycomponents/solarsystemcomposite.h
index ded53e4..f567022 100644
--- a/kstars/skycomponents/solarsystemcomposite.h
+++ b/kstars/skycomponents/solarsystemcomposite.h
@@ -15,28 +15,28 @@
* *
***************************************************************************/
-#ifndef SOLARSYSTEMCOMPOSITE_H
-#define SOLARSYSTEMCOMPOSITE_H
+#pragma once
-#include "skycomposite.h"
#include "planetmoonscomponent.h"
+#include "skycomposite.h"
+class AsteroidsComponent;
+class CometsComponent;
+class KSMoon;
class KSPlanet;
class KSSun;
-class KSMoon;
//class JupiterMoonsComponent;
-class AsteroidsComponent;
-class CometsComponent;
class SkyLabeler;
-/** @class SolarSystemComposite
-* The solar system composite manages all planets, asteroids and comets.
-* As every sub component of solar system needs the earth , the composite
-* is managing this object by itself.
-*
-*@author Thomas Kabelmann
-*@version 0.1
-*/
+/**
+ * @class SolarSystemComposite
+ * The solar system composite manages all planets, asteroids and comets.
+ * As every sub component of solar system needs the earth , the composite
+ * is managing this object by itself.
+ *
+ * @author Thomas Kabelmann
+ * @version 0.1
+ */
class SolarSystemComposite : public SkyComposite
{
@@ -72,9 +72,9 @@ class SolarSystemComposite : public SkyComposite
const QList<SolarSystemSingleComponent *> &planets() const;
private:
- KSPlanet *m_Earth;
- KSSun *m_Sun;
- KSMoon *m_Moon;
+ KSPlanet *m_Earth { nullptr };
+ KSSun *m_Sun { nullptr };
+ KSMoon *m_Moon { nullptr };
// PlanetMoonsComponent *m_JupiterMoons;
AsteroidsComponent *m_AsteroidsComponent;
CometsComponent *m_CometsComponent;
@@ -82,5 +82,3 @@ class SolarSystemComposite : public SkyComposite
QList<SkyObject *> m_planetObjects;
QList<SkyObject *> m_moons;
};
-
-#endif
diff --git a/kstars/skycomponents/starblockfactory.cpp b/kstars/skycomponents/starblockfactory.cpp
index 5b66e60..eb1b590 100644
--- a/kstars/skycomponents/starblockfactory.cpp
+++ b/kstars/skycomponents/starblockfactory.cpp
@@ -47,7 +47,7 @@ StarBlockFactory::~StarBlockFactory()
{
deleteBlocks(nBlocks);
if (pInstance)
- pInstance = 0;
+ pInstance = nullptr;
}
StarBlock *StarBlockFactory::getBlock()
diff --git a/kstars/skycomponents/starblocklist.cpp b/kstars/skycomponents/starblocklist.cpp
index f625d3a..ecf9746 100644
--- a/kstars/skycomponents/starblocklist.cpp
+++ b/kstars/skycomponents/starblocklist.cpp
@@ -19,6 +19,7 @@
#include "binfilehelper.h"
#include "deepstarcomponent.h"
+#include "starblock.h"
#include "starcomponent.h"
#ifdef KSTARS_LITE
diff --git a/kstars/skycomponents/starcomponent.cpp b/kstars/skycomponents/starcomponent.cpp
index 34debb4..af419f5 100644
--- a/kstars/skycomponents/starcomponent.cpp
+++ b/kstars/skycomponents/starcomponent.cpp
@@ -19,10 +19,10 @@
#include "binfilehelper.h"
#include "deepstarcomponent.h"
+#include "highpmstarlist.h"
#include "kstarsdata.h"
#include "kstarssplash.h"
#include "Options.h"
-#include "skylabel.h"
#include "skylabeler.h"
#include "skymap.h"
#include "skymesh.h"
@@ -48,12 +48,12 @@
StarComponent *StarComponent::pinstance = 0;
StarComponent::StarComponent(SkyComposite *parent)
- : ListComponent(parent), m_reindexNum(J2000), m_FaintMagnitude(-5.0), starsLoaded(false), focusStar(nullptr)
+ : ListComponent(parent), m_reindexNum(J2000), m_FaintMagnitude(-5.0), starsLoaded(false)
{
m_skyMesh = SkyMesh::Instance();
m_StarBlockFactory = StarBlockFactory::Instance();
- m_starIndex = new StarIndex();
+ m_starIndex.reset(new StarIndex());
for (int i = 0; i < m_skyMesh->size(); i++)
m_starIndex->append(new StarList());
m_highPMStars.append(new HighPMStarList(840.0));
@@ -83,7 +83,14 @@ StarComponent::StarComponent(SkyComposite *parent)
StarComponent::~StarComponent()
{
- qDeleteAll(m_HDHash.values());
+ qDeleteAll(*m_starIndex);
+ m_starIndex->clear();
+ qDeleteAll(m_DeepStarComponents);
+ m_DeepStarComponents.clear();
+ qDeleteAll(m_highPMStars);
+ m_highPMStars.clear();
+ for (int i = 0; i <= MAX_LINENUMBER_MAG; i++)
+ delete m_labelList[i];
}
StarComponent *StarComponent::Create(SkyComposite *parent)
@@ -149,7 +156,7 @@ bool StarComponent::reindex(KSNumbers *num)
bool highPM = true;
// otherwise we just re-index fast movers as needed
for (int j = 0; j < m_highPMStars.size(); j++)
- highPM &= !(m_highPMStars.at(j)->reindex(num, m_starIndex));
+ highPM &= !(m_highPMStars.at(j)->reindex(num, m_starIndex.get()));
return !(highPM);
}
diff --git a/kstars/skycomponents/starcomponent.h b/kstars/skycomponents/starcomponent.h
index 3ac5303..5b1bc17 100644
--- a/kstars/skycomponents/starcomponent.h
+++ b/kstars/skycomponents/starcomponent.h
@@ -32,12 +32,13 @@
* @version 1.0
*/
-#include "listcomponent.h"
-
#include "ksnumbers.h"
+#include "listcomponent.h"
#include "skylabel.h"
#include "skyobjects/starobject.h"
+#include <memory>
+
#ifdef KSTARS_LITE
class StarItem;
#endif
@@ -157,27 +158,27 @@ class StarComponent : public ListComponent
/** true if all stars(not only high PM ones) were reindexed else false**/
bool reindex(KSNumbers *num);
- SkyMesh *m_skyMesh;
- StarIndex *m_starIndex;
+ SkyMesh *m_skyMesh { nullptr };
+ std::unique_ptr<StarIndex> m_starIndex;
KSNumbers m_reindexNum;
double m_reindexInterval;
LabelList *m_labelList[MAX_LINENUMBER_MAG + 1];
- bool m_hideLabels;
+ bool m_hideLabels = false;
float m_zoomMagLimit;
float m_FaintMagnitude; // Limiting magnitude of the catalog currently loaded
- bool starsLoaded;
+ bool starsLoaded = false;
float magLim; // Current limiting magnitude for visible stars
StarObject m_starObject;
- StarObject *focusStar; // This object is always drawn
+ StarObject *focusStar { nullptr }; // This object is always drawn
- KStarsSplash *m_reindexSplash;
+ KStarsSplash *m_reindexSplash { nullptr };
- StarBlockFactory *m_StarBlockFactory;
+ StarBlockFactory *m_StarBlockFactory { nullptr };
QVector<HighPMStarList *> m_highPMStars;
QHash<QString, SkyObject *> m_genName;
diff --git a/kstars/skycomponents/targetlistcomponent.cpp b/kstars/skycomponents/targetlistcomponent.cpp
index 5722acb..2c5d14d 100644
--- a/kstars/skycomponents/targetlistcomponent.cpp
+++ b/kstars/skycomponents/targetlistcomponent.cpp
@@ -16,59 +16,34 @@
***************************************************************************/
#include "targetlistcomponent.h"
+
#ifndef KSTARS_LITE
#include "skymap.h"
#endif
-#include "Options.h"
+#include "skypainter.h"
TargetListComponent::TargetListComponent(SkyComposite *parent) : SkyComponent(parent)
{
- list = 0;
drawSymbols = 0;
drawLabels = 0;
}
TargetListComponent::TargetListComponent(SkyComposite *parent, SkyObjectList *objectList, QPen _pen,
bool (*optionDrawSymbols)(void), bool (*optionDrawLabels)(void))
- : SkyComponent(parent), pen(_pen)
+ : SkyComponent(parent), list(objectList), pen(_pen)
{
- list = objectList;
drawSymbols = optionDrawSymbols;
drawLabels = optionDrawLabels;
}
-/**
-
-// This method is now implemented in SkyPainter subclasses, and hence is redundant.
-// But I'd let this method stick around for a while, before I get rid of it altogether
-// - Akarsh
-
-void TargetListComponent::drawTargetSymbol( SkyPainter *skyp, SkyObject *obj ) {
- SkyMap *map = SkyMap::Instance(); // FIXME: Replace with projector upon merger of Harry's code
- if ( ! map->checkVisibility( obj ) )
- return;
- QPointF o = map->toScreen( obj ); // FIXME: Replace with appropriate call on the projector upon merger of Harry's code
- if( !drawSymbols || (*drawSymbols)() ) {
- if (o.x() >= 0. && o.x() <= map->width()*map->scale() && o.y() >=0. && o.y() <= map->height()*map->scale() ) {
- if ( Options::useAntialias() ) {
- float size = 20.*map->scale();
- float x1 = o.x() - 0.5*size;
- float y1 = o.y() - 0.5*size;
- psky.drawArc( QRectF(x1, y1, size, size), -60*16, 120*16 );
- psky.drawArc( QRectF(x1, y1, size, size), 120*16, 120*16 );
- } else {
- int size = 20*int(map->scale());
- int x1 = int(o.x()) - size/2;
- int y1 = int(o.y()) - size/2;
- psky.drawArc( QRect(x1, y1, size, size), -60*16, 120*16 );
- psky.drawArc( QRect(x1, y1, size, size), 120*16, 120*16 );
- }
- if ( drawLabels && (*drawLabels)() )
- obj->drawRudeNameLabel( psky, o );
- }
+TargetListComponent::~TargetListComponent()
+{
+ if (list)
+ {
+ qDeleteAll(*list);
+ list = nullptr;
}
}
-*/
void TargetListComponent::draw(SkyPainter *skyp)
{
@@ -76,12 +51,7 @@ void TargetListComponent::draw(SkyPainter *skyp)
return;
if (!list || list->count() <= 0)
return;
- /*
- // Superceded by SkyPainter::drawObservingList()
- foreach( SkyObject *obj, *list ) {
- drawTargetSymbol( psky, obj );
- }
- */
+
skyp->setPen(pen);
skyp->drawObservingList(*list);
}
diff --git a/kstars/skycomponents/targetlistcomponent.h b/kstars/skycomponents/targetlistcomponent.h
index cc6e792..44adf73 100644
--- a/kstars/skycomponents/targetlistcomponent.h
+++ b/kstars/skycomponents/targetlistcomponent.h
@@ -15,17 +15,15 @@
* *
***************************************************************************/
-#ifndef TARGETLISTCOMPONENT_H
-#define TARGETLISTCOMPONENT_H
+#pragma once
-#include "skypainter.h"
#include "skycomponent.h"
-#include "typedef.h"
-#include "skyobject.h"
+
+#include <QPen>
/**
- *@class TargetListComponent
- *@short Highlights objects present in certain lists by drawing "target" symbols around them.
+ * @class TargetListComponent
+ * @short Highlights objects present in certain lists by drawing "target" symbols around them.
*
* To represent lists of specific objects on the skymap (eg: A star
* hopping route, or a list of planned observation targets), one would
@@ -40,7 +38,7 @@
* the list. If the pointers are nullptr, the symbols are always drawn,
* but the labels are not drawn.
*
- *@note This does not inherit from ListComponent because it is not
+ * @note This does not inherit from ListComponent because it is not
* necessary. ListComponent has extra methods like objectNearest(),
* which we don't want. Also, ListComponent maintains its own list,
* whereas this class merely holds a pointer to a list that's
@@ -51,54 +49,40 @@ class TargetListComponent : public SkyComponent
{
public:
/**
- *@short Default constructor.
- */
+ * @short Default constructor.
+ */
explicit TargetListComponent(SkyComposite *parent);
/**
- *@short Constructor that sets up this target list
- */
+ * @short Constructor that sets up this target list
+ */
TargetListComponent(SkyComposite *parent, QList<SkyObject *> *objectList, QPen _pen,
bool (*optionDrawSymbols)(void) = 0, bool (*optionDrawLabels)(void) = 0);
+ virtual ~TargetListComponent();
+
/**
- *@short Draw this component by iterating over the list.
- *
- *@note This method does not bother refreshing the coordinates of
- * the objects on the list. So this must be called only after the
- * objects are drawn in a given draw cycle.
- */
+ * @short Draw this component by iterating over the list.
+ *
+ * @note This method does not bother refreshing the coordinates of
+ * the objects on the list. So this must be called only after the
+ * objects are drawn in a given draw cycle.
+ */
void draw(SkyPainter *skyp) Q_DECL_OVERRIDE;
// FIXME: Maybe we should make these member objects private / protected?
- SkyObjectList *list; // Pointer to list of objects to draw
+ SkyObjectList *list { nullptr }; // Pointer to list of objects to draw
QPen pen; // Pen to use to draw
/**
- *@short Pointer to static method that tells us whether to draw this list or not
- *@note If the pointer is nullptr, the list is drawn nevertheless
- */
+ * @short Pointer to static method that tells us whether to draw this list or not
+ * @note If the pointer is nullptr, the list is drawn nevertheless
+ */
bool (*drawSymbols)(void);
/**
- *@short Pointer to static method that tells us whether to draw labels for this list or not
- *@note If the pointer is nullptr, labels are not drawn
- */
+ * @short Pointer to static method that tells us whether to draw labels for this list or not
+ * @note If the pointer is nullptr, labels are not drawn
+ */
bool (*drawLabels)(void);
-
- protected:
- /**
- *@short Draws a target symbol around the object, and also draws labels if requested
- *@note Does not update the positions of the objects. See the note on draw() for details.
- */
- /*
-
- // This method is superseded by the definitions in SkyPainter
- // and might need to be reinstated only while generalizing the
- // class to draw other textures.
-
- virtual void drawTargetSymbol( SkyPainter *skyp, SkyObject *obj );
- */
};
-
-#endif
diff --git a/kstars/skycomponents/typedef.h b/kstars/skycomponents/typedef.h
index a714540..eebf9ee 100644
--- a/kstars/skycomponents/typedef.h
+++ b/kstars/skycomponents/typedef.h
@@ -25,9 +25,9 @@
* -- James B. Bowlin
*/
-#ifndef TYPEDEF_H_
-#define TYPEDEF_H_
+#pragma once
+#include <qglobal.h>
#include <QHash>
#include <QVector>
@@ -50,5 +50,3 @@ typedef QVector<StarList *> StarIndex;
typedef QVector<LineList *> LineListList;
typedef QHash<Trixel, LineListList *> LineListHash; // Wanted LineListIndex, but that is used by a class
typedef QList<SkyObject *> SkyObjectList;
-
-#endif
diff --git a/kstars/skyobjects/kscomet.cpp b/kstars/skyobjects/kscomet.cpp
index 2387bd8..008217a 100644
--- a/kstars/skyobjects/kscomet.cpp
+++ b/kstars/skyobjects/kscomet.cpp
@@ -17,16 +17,10 @@
#include "kscomet.h"
-#include <typeinfo>
-
-#include <QRegExp>
-#include <QDebug>
-#include <QMap>
-
-#include "kstarsdata.h"
-#include "kstarsdatetime.h"
#include "ksnumbers.h"
-#include "dms.h"
+#include "kstarsdata.h"
+
+#include <QDir>
namespace
{
diff --git a/kstars/skyobjects/kscomet.h b/kstars/skyobjects/kscomet.h
index bb536e4..a00b110 100644
--- a/kstars/skyobjects/kscomet.h
+++ b/kstars/skyobjects/kscomet.h
@@ -15,34 +15,34 @@
* *
***************************************************************************/
-#ifndef KSCOMET_H_
-#define KSCOMET_H_
+#pragma once
#include "ksplanetbase.h"
-/** @class KSComet
- *@short A subclass of KSPlanetBase that implements comets.
- *
- *The orbital elements are stored as private member variables, and
- *it provides methods to compute the ecliptic coordinates for any
- *time from the orbital elements.
- *
- *The orbital elements are:
- *@li JD Epoch of element values
- *@li q perihelion distance (AU)
- *@li e eccentricity of orbit
- *@li i inclination angle (with respect to J2000.0 ecliptic plane)
- *@li w argument of perihelion (w.r.t. J2000.0 ecliptic plane)
- *@li N longitude of ascending node (J2000.0 ecliptic)
- *@li Tp time of perihelion passage (YYYYMMDD.DDD)
- *@li M1 comet total magnitude parameter
- *@li M2 comet nuclear magnitude parameter
- *@li K1 total magnitude slope parameter
- *@li K2 nuclear magnitude slope parameter
- *
- *@author Jason Harris
- *@version 1.1
- */
+/**
+ * @class KSComet
+ * @short A subclass of KSPlanetBase that implements comets.
+ *
+ * The orbital elements are stored as private member variables, and
+ * it provides methods to compute the ecliptic coordinates for any
+ * time from the orbital elements.
+ *
+ * The orbital elements are:
+ * @li JD Epoch of element values
+ * @li q perihelion distance (AU)
+ * @li e eccentricity of orbit
+ * @li i inclination angle (with respect to J2000.0 ecliptic plane)
+ * @li w argument of perihelion (w.r.t. J2000.0 ecliptic plane)
+ * @li N longitude of ascending node (J2000.0 ecliptic)
+ * @li Tp time of perihelion passage (YYYYMMDD.DDD)
+ * @li M1 comet total magnitude parameter
+ * @li M2 comet nuclear magnitude parameter
+ * @li K1 total magnitude slope parameter
+ * @li K2 nuclear magnitude slope parameter
+ *
+ * @author Jason Harris
+ * @version 1.1
+ */
class KSNumbers;
class dms;
@@ -50,21 +50,22 @@ class dms;
class KSComet : public KSPlanetBase
{
public:
- /** Constructor.
- *@param s the name of the comet
- *@param image_file the filename for an image of the comet
- *@param JD the Julian Day for the orbital elements
- *@param q the perihelion distance of the comet's orbit (AU)
- *@param e the eccentricity of the comet's orbit
- *@param i the inclination angle of the comet's orbit
- *@param w the argument of the orbit's perihelion
- *@param N the longitude of the orbit's ascending node
- *@param Tp The date of the most proximate perihelion passage (YYYYMMDD.DDD)
- *@param M1 the comet total magnitude parameter
- *@param M2 the comet nuclear magnitude parameter
- *@param K1 the comet total magnitude slope parameter
- *@param K2 the comet nuclear magnitude slope parameter
- */
+ /**
+ * Constructor.
+ * @param s the name of the comet
+ * @param image_file the filename for an image of the comet
+ * @param JD the Julian Day for the orbital elements
+ * @param q the perihelion distance of the comet's orbit (AU)
+ * @param e the eccentricity of the comet's orbit
+ * @param i the inclination angle of the comet's orbit
+ * @param w the argument of the orbit's perihelion
+ * @param N the longitude of the orbit's ascending node
+ * @param Tp The date of the most proximate perihelion passage (YYYYMMDD.DDD)
+ * @param M1 the comet total magnitude parameter
+ * @param M2 the comet nuclear magnitude parameter
+ * @param K1 the comet total magnitude slope parameter
+ * @param K2 the comet nuclear magnitude slope parameter
+ */
KSComet(const QString &s, const QString &image_file, long double JD, double q, double e, dms i, dms w, dms N,
double Tp, float M1, float M2, float K1, float K2);
@@ -74,171 +75,118 @@ class KSComet : public KSPlanetBase
/** Destructor (empty)*/
virtual ~KSComet() {}
- /** Unused virtual function inherited from KSPlanetBase,
- *so it's simply empty here.
- */
+ /**
+ * Unused virtual function inherited from KSPlanetBase thus it's simply empty here.
+ */
bool loadData() Q_DECL_OVERRIDE;
/**
- *@short Returns the Julian Day of Perihelion passage
- *@return Julian Day of Perihelion Passage
- */
+ * @short Returns the Julian Day of Perihelion passage
+ * @return Julian Day of Perihelion Passage
+ */
inline long double getPerihelionJD() { return JDp; }
/**
- *@short Returns Perihelion distance
- *@return Perihelion distance
- */
+ * @short Returns Perihelion distance
+ * @return Perihelion distance
+ */
inline double getPerihelion() { return q; }
- /**
- * @return the comet total magnitude parameter
- */
+ /** @return the comet total magnitude parameter */
inline float getTotalMagnitudeParameter() { return M1; }
- /**
- * @return the comet nuclear magnitude parameter
- */
+ /** @return the comet nuclear magnitude parameter */
inline float getNuclearMagnitudeParameter() { return M2; }
- /**
- *@return the total magnitude slope parameter
- */
+ /** @return the total magnitude slope parameter */
inline float getTotalSlopeParameter() { return K1; }
- /**
- *@return the nuclear magnitude slope parameter
- */
+ /** @return the nuclear magnitude slope parameter */
inline float getNuclearSlopeParameter() { return K2; }
- /**
- *@short Sets the comet's tail length in km
- */
+ /** @short Sets the comet's tail length in km */
void setTailSize(double tailsize) { TailSize = tailsize; }
- /**
- *@return the estimated tail length in km
- */
+ /** @return the estimated tail length in km */
inline float getTailSize() { return TailSize; }
- /**
- *@short Sets the comet's apparent tail length in degrees
- */
+ /** @short Sets the comet's apparent tail length in degrees */
void setComaAngSize(double comaAngSize) { ComaAngSize = comaAngSize; }
- /**
- *@return the estimated angular size of the tail as a dms
- */
+ /** @return the estimated angular size of the tail as a dms */
inline dms getComaAngSize() { return dms(ComaAngSize); }
- /**
- *@return the estimated diameter of the nucleus in km
- */
+ /** @return the estimated diameter of the nucleus in km */
inline float getNuclearSize() { return NuclearSize; }
- /**
- *@short Sets the comet's earth minimum orbit intersection distance
- */
+ /** @short Sets the comet's earth minimum orbit intersection distance */
void setEarthMOID(double earth_moid);
- /**
- *@return the comet's earth minimum orbit intersection distance in km
- */
+ /** @return the comet's earth minimum orbit intersection distance in km */
inline double getEarthMOID() { return EarthMOID; }
- /**
- *@short Sets the comet's orbit solution ID
- */
+ /** @short Sets the comet's orbit solution ID */
void setOrbitID(QString orbit_id);
- /**
- *@return the comet's orbit solution ID
- */
+ /** @return the comet's orbit solution ID */
inline QString getOrbitID() { return OrbitID; }
- /**
- *@short Sets the comet's orbit class
- */
+ /** @short Sets the comet's orbit class */
void setOrbitClass(QString orbit_class);
- /**
- *@return the comet's orbit class
- */
+ /** @return the comet's orbit class */
inline QString getOrbitClass() { return OrbitClass; }
- /**
- *@short Sets if the comet is a near earth object
- */
+ /** @short Sets if the comet is a near earth object */
void setNEO(bool neo);
- /**
- *@return true if the comet is a near earth object
- */
+ /** @return true if the comet is a near earth object */
inline bool isNEO() { return NEO; }
- /**
- *@short Sets the comet's albedo
- */
+ /** @short Sets the comet's albedo */
void setAlbedo(float albedo);
- /**
- *@return the comet's albedo
- */
+ /** @return the comet's albedo */
inline float getAlbedo() { return Albedo; }
- /**
- *@short Sets the comet's diameter
- */
+ /** @short Sets the comet's diameter */
void setDiameter(float diam);
- /**
- *@return the comet's diameter
- */
+ /** @return the comet's diameter */
inline float getDiameter() { return Diameter; }
- /**
- *@short Sets the comet's dimensions
- */
+ /** @short Sets the comet's dimensions */
void setDimensions(QString dim);
- /**
- *@return the comet's dimensions
- */
+ /** @return the comet's dimensions */
inline QString getDimensions() { return Dimensions; }
- /**
- *@short Sets the comet's rotation period
- */
+ /** @short Sets the comet's rotation period */
void setRotationPeriod(float rot_per);
- /**
- *@return the comet's rotation period
- */
+ /** @return the comet's rotation period */
inline float getRotationPeriod() { return RotationPeriod; }
- /**
- *@short Sets the comet's period
- */
+ /** @short Sets the comet's period */
void setPeriod(float per);
- /**
- *@return the comet's period
- */
+ /** @return the comet's period */
inline float getPeriod() { return Period; }
protected:
- /** Calculate the geocentric RA, Dec coordinates of the Comet.
- *@note reimplemented from KSPlanetBase
- *@param num time-dependent values for the desired date
- *@param Earth planet Earth (needed to calculate geocentric coords)
- *@return true if position was successfully calculated.
- */
+ /**
+ * Calculate the geocentric RA, Dec coordinates of the Comet.
+ * @note reimplemented from KSPlanetBase
+ * @param num time-dependent values for the desired date
+ * @param Earth planet Earth (needed to calculate geocentric coords)
+ * @return true if position was successfully calculated.
+ */
bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth = nullptr) Q_DECL_OVERRIDE;
/**
- *@short Estimate physical parameters of the comet such as coma size, tail length and size of the nucleus
- *@note invoked from findGeocentricPosition in order
- */
+ * @short Estimate physical parameters of the comet such as coma size, tail length and size of the nucleus
+ * @note invoked from findGeocentricPosition in order
+ */
void findPhysicalParameters();
private:
@@ -254,5 +202,3 @@ class KSComet : public KSPlanetBase
qint64 uidPart; // Part of UID
};
-
-#endif
diff --git a/kstars/skyobjects/ksplanetbase.cpp b/kstars/skyobjects/ksplanetbase.cpp
index 6605a07..2668441 100644
--- a/kstars/skyobjects/ksplanetbase.cpp
+++ b/kstars/skyobjects/ksplanetbase.cpp
@@ -17,26 +17,18 @@
#include "ksplanetbase.h"
-#include <cmath>
-
-#include <QFile>
-#include <QPoint>
-#include <QMatrix>
-
-#include "nan.h"
+#include "ksnumbers.h"
#include "kstarsdata.h"
#include "ksutils.h"
-#include "ksnumbers.h"
#include "Options.h"
#include "skymap.h"
#include "ksasteroid.h"
#include "kscomet.h"
-#include "kspluto.h"
+#include "ksmoon.h"
#include "ksplanet.h"
#include "kssun.h"
-#include "ksmoon.h"
-#include "skycomponents/skymapcomposite.h"
#include "texturemanager.h"
+#include "skycomponents/skymapcomposite.h"
QVector<QColor> KSPlanetBase::planetColor = QVector<QColor>() << QColor("slateblue") << //Mercury
QColor("lightgreen") << //Venus
diff --git a/kstars/skyobjects/ksplanetbase.h b/kstars/skyobjects/ksplanetbase.h
index 790e4aa..2adc688 100644
--- a/kstars/skyobjects/ksplanetbase.h
+++ b/kstars/skyobjects/ksplanetbase.h
@@ -15,24 +15,22 @@
* *
***************************************************************************/
-#ifndef KSPLANETBASE_H_
-#define KSPLANETBASE_H_
+#pragma once
-#include <QList>
-#include <QImage>
-#include <QColor>
+#include "trailobject.h"
+#include <QColor>
#include <QDebug>
-
-#include "trailobject.h"
+#include <QImage>
+#include <QList>
class KSNumbers;
/**
- *@class EclipticPosition
- *@short The ecliptic position of a planet (Longitude, Latitude, and distance from Sun).
- *@author Mark Hollomon
- *@version 1.0
+ * @class EclipticPosition
+ * @short The ecliptic position of a planet (Longitude, Latitude, and distance from Sun).
+ * @author Mark Hollomon
+ * @version 1.0
*/
class EclipticPosition
{
@@ -49,27 +47,26 @@ class EclipticPosition
};
/**
- *@class KSPlanetBase
- *A subclass of TrailObject that provides additional information
- *needed for most solar system objects. This is a base class for
- *KSSun, KSMoon, KSPlanet, KSAsteroid, and KSComet. Those classes
- *cover all solar system objects except planetary moons, which are
- *derived directly from TrailObject
- *@short Provides necessary information about objects in the solar system.
- *@author Mark Hollomon
- *@version 1.0
- */
+ * @class KSPlanetBase
+ * A subclass of TrailObject that provides additional information needed for most solar system
+ * objects. This is a base class for KSSun, KSMoon, KSPlanet, KSAsteroid and KSComet.
+ * Those classes cover all solar system objects except planetary moons, which are
+ * derived directly from TrailObject
+ * @short Provides necessary information about objects in the solar system.
+ * @author Mark Hollomon
+ * @version 1.0
+ */
class KSPlanetBase : public TrailObject
{
public:
/**
- *Constructor. Calls SkyObject constructor with type=2 (planet),
- *coordinates=0.0, mag=0.0, primary name s, and all other QStrings empty.
- *@param s Name of planet
- *@param image_file filename of the planet's image
- *@param c color of the symbol to use for this planet
- *@param pSize the planet's physical size, in km
- */
+ * Constructor. Calls SkyObject constructor with type=2 (planet),
+ * coordinates=0.0, mag=0.0, primary name s, and all other QStrings empty.
+ * @param s Name of planet
+ * @param image_file filename of the planet's image
+ * @param c color of the symbol to use for this planet
+ * @param pSize the planet's physical size, in km
+ */
explicit KSPlanetBase(const QString &s = i18n("unnamed"), const QString &image_file = QString(),
const QColor &c = Qt::white, double pSize = 0);
@@ -105,14 +102,16 @@ class KSPlanetBase : public TrailObject
/** @return pointer to Ecliptic Latitude coordinate */
const dms &ecLat() const { return ep.latitude; }
- /** @short Set Ecliptic Geocentric Longitude according to argument.
- * @param elong Ecliptic Longitude
- */
+ /**
+ * @short Set Ecliptic Geocentric Longitude according to argument.
+ * @param elong Ecliptic Longitude
+ */
void setEcLong(dms elong) { ep.longitude = elong; }
- /** @short Set Ecliptic Geocentric Latitude according to argument.
- * @param elat Ecliptic Latitude
- */
+ /**
+ * @short Set Ecliptic Geocentric Latitude according to argument.
+ * @param elat Ecliptic Latitude
+ */
void setEcLat(dms elat) { ep.latitude = elat; }
/** @return pointer to Ecliptic Heliocentric Longitude coordinate */
@@ -121,14 +120,16 @@ class KSPlanetBase : public TrailObject
/** @return pointer to Ecliptic Heliocentric Latitude coordinate */
const dms &helEcLat() const { return helEcPos.latitude; }
- /** @short Convert Ecliptic logitude/latitude to Right Ascension/Declination.
- * @param Obliquity current Obliquity of the Ecliptic (angle from Equator)
- */
+ /**
+ * @short Convert Ecliptic logitude/latitude to Right Ascension/Declination.
+ * @param Obliquity current Obliquity of the Ecliptic (angle from Equator)
+ */
void EclipticToEquatorial(const CachingDms *Obliquity);
- /** @short Convert Right Ascension/Declination to Ecliptic logitude/latitude.
- * @param Obliquity current Obliquity of the Ecliptic (angle from Equator)
- */
+ /**
+ * @short Convert Right Ascension/Declination to Ecliptic logitude/latitude.
+ * @param Obliquity current Obliquity of the Ecliptic (angle from Equator)
+ */
void EquatorialToEcliptic(const CachingDms *Obliquity);
/** @return pointer to this planet's texture */
@@ -137,48 +138,54 @@ class KSPlanetBase : public TrailObject
/** @return distance from Sun, in Astronomical Units (1 AU is Earth-Sun distance) */
double rsun() const { return ep.radius; }
- /** @short Set the solar distance in AU.
- * @param r the new solar distance in AU
- */
+ /**
+ * @short Set the solar distance in AU.
+ * @param r the new solar distance in AU
+ */
void setRsun(double r) { ep.radius = r; }
/** @return distance from Earth, in Astronomical Units (1 AU is Earth-Sun distance) */
double rearth() const { return Rearth; }
- /** @short Set the distance from Earth, in AU.
- * @param r the new earth-distance in AU
- */
+ /**
+ * @short Set the distance from Earth, in AU.
+ * @param r the new earth-distance in AU
+ */
void setRearth(double r) { Rearth = r; }
- /** @short compute and set the distance from Earth, in AU.
- * @param Earth pointer to the Earth from which to calculate the distance.
- */
+ /**
+ * @short compute and set the distance from Earth, in AU.
+ * @param Earth pointer to the Earth from which to calculate the distance.
+ */
void setRearth(const KSPlanetBase *Earth);
- /**Update position of the planet (reimplemented from SkyPoint)
- * @param num current KSNumbers object
- * @param includePlanets this function does nothing if includePlanets=false
- * @param lat pointer to the geographic latitude; if nullptr, we skip localizeCoords()
- * @param LST pointer to the local sidereal time; if nullptr, we skip localizeCoords()
- */
+ /**
+ * Update position of the planet (reimplemented from SkyPoint)
+ * @param num current KSNumbers object
+ * @param includePlanets this function does nothing if includePlanets=false
+ * @param lat pointer to the geographic latitude; if nullptr, we skip localizeCoords()
+ * @param LST pointer to the local sidereal time; if nullptr, we skip localizeCoords()
+ */
void updateCoords(const KSNumbers *num, bool includePlanets = true, const CachingDms *lat = 0,
const CachingDms *LST = 0, bool forceRecompute = false) Q_DECL_OVERRIDE;
- /** @short Find position, including correction for Figure-of-the-Earth.
- * @param num KSNumbers pointer for the target date/time
- * @param lat pointer to the geographic latitude; if nullptr, we skip localizeCoords()
- * @param LST pointer to the local sidereal time; if nullptr, we skip localizeCoords()
- * @param Earth pointer to the Earth (not used for the Moon)
- */
+ /**
+ * @short Find position, including correction for Figure-of-the-Earth.
+ * @param num KSNumbers pointer for the target date/time
+ * @param lat pointer to the geographic latitude; if nullptr, we skip localizeCoords()
+ * @param LST pointer to the local sidereal time; if nullptr, we skip localizeCoords()
+ * @param Earth pointer to the Earth (not used for the Moon)
+ */
void findPosition(const KSNumbers *num, const CachingDms *lat = 0, const CachingDms *LST = 0,
const KSPlanetBase *Earth = 0);
/** @return the Planet's position angle. */
double pa() const Q_DECL_OVERRIDE { return PositionAngle; }
- /** @short Set the Planet's position angle.
- * @param p the new position angle
- */
+ /**
+ * @short Set the Planet's position angle.
+ * @param p the new position angle
+ */
void setPA(double p) { PositionAngle = p; }
/** @return the Planet's angular size, in arcminutes */
@@ -223,26 +230,28 @@ class KSPlanetBase : public TrailObject
/** Compute high 32-bits of UID. */
inline UID solarsysUID(UID type) const { return (SkyObject::UID_SOLARSYS << 60) | (type << 56); }
- /** @short find the object's current geocentric equatorial coordinates (RA and Dec)
- * This function is pure virtual; it must be overloaded by subclasses.
- * This function is private; it is called by the public function findPosition()
- * which also includes the figure-of-the-earth correction, localizeCoords().
- * @param num pointer to current KSNumbers object
- * @param Earth pointer to planet Earth (needed to calculate geocentric coords)
- * @return true if position was successfully calculated.
- */
+ /**
+ * @short find the object's current geocentric equatorial coordinates (RA and Dec)
+ * This function is pure virtual; it must be overloaded by subclasses.
+ * This function is private; it is called by the public function findPosition()
+ * which also includes the figure-of-the-earth correction, localizeCoords().
+ * @param num pointer to current KSNumbers object
+ * @param Earth pointer to planet Earth (needed to calculate geocentric coords)
+ * @return true if position was successfully calculated.
+ */
virtual bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth = nullptr) = 0;
/**
- * @short Computes the visual magnitude for the major planets.
- * @param num pointer to a ksnumbers object. Needed for the saturn rings contribution to
- * saturn's magnitude.
- */
+ * @short Computes the visual magnitude for the major planets.
+ * @param num pointer to a ksnumbers object. Needed for the saturn rings contribution to
+ * saturn's magnitude.
+ */
virtual void findMagnitude(const KSNumbers *num) = 0;
- /**Determine the position angle of the planet for a given date
- * (used internally by findPosition() )
- */
+ /**
+ * Determine the position angle of the planet for a given date
+ * (used internally by findPosition() )
+ */
void findPA(const KSNumbers *num);
/** Determine the phase of the planet. */
@@ -260,18 +269,16 @@ class KSPlanetBase : public TrailObject
private:
/**
- * @short correct the position for the fact that the location is not at the center of the Earth,
- * but a position on its surface. This causes a small parallactic shift in a solar system
- * body's apparent position. The effect is most significant for the Moon.
- * This function is private, and should only be called from the public findPosition() function.
- * @param num pointer to a ksnumbers object for the target date/time
- * @param lat pointer to the geographic latitude of the location.
- * @param LST pointer to the local sidereal time.
- */
+ * @short correct the position for the fact that the location is not at the center of the Earth,
+ * but a position on its surface. This causes a small parallactic shift in a solar system
+ * body's apparent position. The effect is most significant for the Moon.
+ * This function is private, and should only be called from the public findPosition() function.
+ * @param num pointer to a ksnumbers object for the target date/time
+ * @param lat pointer to the geographic latitude of the location.
+ * @param LST pointer to the local sidereal time.
+ */
void localizeCoords(const KSNumbers *num, const CachingDms *lat, const CachingDms *LST);
double PositionAngle, AngularSize, PhysicalSize;
QColor m_Color;
};
-
-#endif
diff --git a/kstars/skyobjects/skypoint.cpp b/kstars/skyobjects/skypoint.cpp
index 8284af7..6ba60a8 100644
--- a/kstars/skyobjects/skypoint.cpp
+++ b/kstars/skyobjects/skypoint.cpp
@@ -53,6 +53,10 @@ SkyPoint::SkyPoint()
lastPrecessJD = J2000; // By convention, we use J2000 coordinates
}
+SkyPoint::~SkyPoint()
+{
+}
+
void SkyPoint::set(const dms &r, const dms &d)
{
RA0 = RA = r;
@@ -60,10 +64,6 @@ void SkyPoint::set(const dms &r, const dms &d)
lastPrecessJD = J2000; // By convention, we use J2000 coordinates
}
-SkyPoint::~SkyPoint()
-{
-}
-
void SkyPoint::EquatorialToHorizontal(const dms *LST, const dms *lat)
{
// qDebug() << "NOTE: This EquatorialToHorizontal overload (using dms pointers instead of CachingDms pointers) is deprecated and should be replaced with CachingDms prototype wherever speed is desirable!";
diff --git a/kstars/skyobjects/skypoint.h b/kstars/skyobjects/skypoint.h
index 6a74e26..24a34c2 100644
--- a/kstars/skyobjects/skypoint.h
+++ b/kstars/skyobjects/skypoint.h
@@ -74,7 +74,6 @@ class SkyPoint
*/
SkyPoint();
- /** Empty destructor. */
virtual ~SkyPoint();
////
diff --git a/kstars/skypainter.h b/kstars/skypainter.h
index 82ab389..ec83416 100644
--- a/kstars/skypainter.h
+++ b/kstars/skypainter.h
@@ -18,42 +18,38 @@
*/
-#ifndef SKYPAINTER_H
-#define SKYPAINTER_H
+#pragma once
+#include <QList>
#include <QPainter>
#include "skycomponents/typedef.h"
-class KSPlanetBase;
+class ConstellationsArt;
class DeepSkyObject;
-class SkyPoint;
-class SkyObject;
-class SkyMap;
-class SkipList;
+class KSComet;
+class KSPlanetBase;
class LineList;
class LineListLabel;
class Satellite;
+class SkipList;
+class SkyMap;
+class SkyObject;
+class SkyPoint;
class Supernova;
-class ConstellationsArt;
-class KSComet;
-class SolarSystemComposite;
-class KSSun;
-/** @short Draws things on the sky, without regard to backend.
- This class serves as an interface to draw objects onto the sky without
- worrying about whether we are using a QPainter or OpenGL.
-. */
+/**
+ * @short Draws things on the sky, without regard to backend.
+ * This class serves as an interface to draw objects onto the sky without
+ * worrying about whether we are using a QPainter or OpenGL.
+ */
class SkyPainter
{
public:
- /** @short Constructor.
- */
+ /** @short Constructor. */
SkyPainter();
- /**
- *@short Destructor
- */
+ /** @short Destructor */
virtual ~SkyPainter();
/** @short Set the pen of the painter **/
@@ -65,17 +61,19 @@ class SkyPainter
//FIXME: find a better way to do this.
void setSizeMagLimit(float sizeMagLim);
- /** Begin painting.
- @note this function <b>must</b> be called before painting anything.
- @see end()
- */
+ /**
+ * Begin painting.
+ * @note this function <b>must</b> be called before painting anything.
+ * @see end()
+ */
virtual void begin() = 0;
- /** End and finalize painting.
- @note this function <b>must</b> be called after painting anything.
- @note it is not guaranteed that anything will actually be drawn until end() is called.
- @see begin();
- */
+ /**
+ * End and finalize painting.
+ * @note this function <b>must</b> be called after painting anything.
+ * @note it is not guaranteed that anything will actually be drawn until end() is called.
+ * @see begin();
+ */
virtual void end() = 0;
////////////////////////////////////
@@ -87,72 +85,78 @@ class SkyPainter
/** @short Draw the sky background */
virtual void drawSkyBackground() = 0;
- /** @short Draw a line between points in the sky.
- @param a the first point
- @param b the second point
- @note this function will skip lines not on screen and clip lines
- that are only partially visible. */
+ /**
+ * @short Draw a line between points in the sky.
+ * @param a the first point
+ * @param b the second point
+ * @note this function will skip lines not on screen and clip lines
+ * that are only partially visible.
+ */
virtual void drawSkyLine(SkyPoint *a, SkyPoint *b) = 0;
- /** @short Draw a polyline in the sky.
- @param list a list of points in the sky
- @param skipList a SkipList object used to control skipping line segments
- @param label a pointer to the label for this line
- @note it's more efficient to use this than repeated calls to drawSkyLine(),
- because it avoids an extra points->size() -2 projections.
- */
+ /**
+ * @short Draw a polyline in the sky.
+ * @param list a list of points in the sky
+ * @param skipList a SkipList object used to control skipping line segments
+ * @param label a pointer to the label for this line
+ * @note it's more efficient to use this than repeated calls to drawSkyLine(),
+ * because it avoids an extra points->size() -2 projections.
+ */
virtual void drawSkyPolyline(LineList *list, SkipList *skipList = 0, LineListLabel *label = 0) = 0;
- /** @short Draw a polygon in the sky.
- @param list a list of points in the sky
- @param forceClip If true (default), it enforces clipping of the polygon, otherwise, it draws the
- complete polygen without running any boundary checks.
- @see drawSkyPolyline()
- */
+ /**
+ * @short Draw a polygon in the sky.
+ * @param list a list of points in the sky
+ * @param forceClip If true (default), it enforces clipping of the polygon, otherwise, it draws the
+ * complete polygen without running any boundary checks.
+ * @see drawSkyPolyline()
+ */
virtual void drawSkyPolygon(LineList *list, bool forceClip = true) = 0;
- /** @short Draw a comet in the sky.
- @param com comet to draw
- @return true if a comet was drawn
- */
+ /**
+ * @short Draw a comet in the sky.
+ * @param com comet to draw
+ * @return true if a comet was drawn
+ */
virtual bool drawComet(KSComet *com) = 0;
- /** @short Draw a point source (e.g., a star).
- @param loc the location of the source in the sky
- @param mag the magnitude of the source
- @param sp the spectral class of the source
- @return true if a source was drawn
- */
+ /**
+ * @short Draw a point source (e.g., a star).
+ * @param loc the location of the source in the sky
+ * @param mag the magnitude of the source
+ * @param sp the spectral class of the source
+ * @return true if a source was drawn
+ */
virtual bool drawPointSource(SkyPoint *loc, float mag, char sp = 'A') = 0;
- /** @short Draw a deep sky object
- @param obj the object to draw
- @param drawImage if true, try to draw the image of the object
- @return true if it was drawn
- */
+ /**
+ * @short Draw a deep sky object
+ * @param obj the object to draw
+ * @param drawImage if true, try to draw the image of the object
+ * @return true if it was drawn
+ */
virtual bool drawDeepSkyObject(DeepSkyObject *obj, bool drawImage = false) = 0;
- /** @short Draw a planet
- @param planet the planet to draw
- @return true if it was drawn
- */
+ /**
+ * @short Draw a planet
+ * @param planet the planet to draw
+ * @return true if it was drawn
+ */
virtual bool drawPlanet(KSPlanetBase *planet) = 0;
- /** @short Draw the symbols for the observing list
- @param obs the oberving list
- */
+ /**
+ * @short Draw the symbols for the observing list
+ * @param obs the oberving list
+ */
virtual void drawObservingList(const QList<SkyObject *> &obs) = 0;
- /** @short Draw flags
- */
+ /** @short Draw flags */
virtual void drawFlags() = 0;
- /** @short Draw a satellite
- */
+ /** @short Draw a satellite */
virtual bool drawSatellite(Satellite *sat) = 0;
- /** @short Draw a Supernova
- */
+ /** @short Draw a Supernova */
virtual bool drawSupernova(Supernova *sup) = 0;
virtual void drawHorizon(bool filled, SkyPoint *labelPoint = 0, bool *drawLabel = 0) = 0;
@@ -160,17 +164,16 @@ class SkyPainter
/** @short Get the width of a star of magnitude mag */
float starWidth(float mag) const;
- /** @short Draw a ConstellationsArt object
- @param obj the object to draw
- @return true if it was drawn
- */
+ /**
+ * @short Draw a ConstellationsArt object
+ * @param obj the object to draw
+ * @return true if it was drawn
+ */
virtual bool drawConstellationArtImage(ConstellationsArt *obj) = 0;
protected:
- SkyMap *m_sm;
+ SkyMap *m_sm { nullptr };
private:
float m_sizeMagLim;
};
-
-#endif // SKYPAINTER_H
diff --git a/kstars/skyqpainter.cpp b/kstars/skyqpainter.cpp
index c01de8c..08cf8cf 100644
--- a/kstars/skyqpainter.cpp
+++ b/kstars/skyqpainter.cpp
@@ -22,30 +22,21 @@
#include "kstarsdata.h"
#include "Options.h"
#include "skymap.h"
-
+#include "projections/projector.h"
+#include "skycomponents/flagcomponent.h"
#include "skycomponents/linelist.h"
-#include "skycomponents/skiplist.h"
#include "skycomponents/linelistlabel.h"
-#include "skycomponents/skymapcomposite.h"
-#include "skycomponents/flagcomponent.h"
#include "skycomponents/satellitescomponent.h"
+#include "skycomponents/skiplist.h"
+#include "skycomponents/skymapcomposite.h"
#include "skycomponents/solarsystemcomposite.h"
-
+#include "skyobjects/constellationsart.h"
#include "skyobjects/deepskyobject.h"
-#include "skyobjects/kscomet.h"
#include "skyobjects/ksasteroid.h"
-#include "skyobjects/trailobject.h"
+#include "skyobjects/kscomet.h"
+#include "skyobjects/kssun.h"
#include "skyobjects/satellite.h"
#include "skyobjects/supernova.h"
-#include "skyobjects/constellationsart.h"
-#include "skyobjects/kssun.h"
-#include "projections/projector.h"
-#include "ksutils.h"
-
-#include <QMap>
-#include <QWidget>
-
-#include <functional>
namespace
{
@@ -93,13 +84,29 @@ const int nSPclasses = 7;
// These pixmaps are never deallocated. Not really good...
QPixmap *imageCache[nSPclasses][nStarSizes] = { { 0 } };
-QPixmap *visibleSatPixmap = 0, *invisibleSatPixmap = 0;
+std::unique_ptr<QPixmap> visibleSatPixmap, invisibleSatPixmap;
}
int SkyQPainter::starColorMode = 0;
QColor SkyQPainter::m_starColor = QColor();
QMap<char, QColor> SkyQPainter::ColorMap = QMap<char, QColor>();
+void SkyQPainter::releaseImageCache()
+{
+ foreach (char color, ColorMap.keys())
+ {
+ QPixmap **pmap = imageCache[harvardToIndex(color)];
+
+ for (int size = 1; size < nStarSizes; size++)
+ {
+ if (pmap[size])
+ delete pmap[size];
+
+ pmap[size] = nullptr;
+ }
+ }
+}
+
SkyQPainter::SkyQPainter(QPaintDevice *pd) : SkyPainter(), QPainter()
{
Q_ASSERT(pd);
@@ -240,6 +247,7 @@ void SkyQPainter::initStarImages()
// Cache array slice
QPixmap **pmap = imageCache[harvardToIndex(color)];
+
for (int size = 1; size < nStarSizes; size++)
{
if (!pmap[size])
@@ -249,8 +257,10 @@ void SkyQPainter::initStarImages()
}
starColorMode = Options::starColorMode();
- visibleSatPixmap = new QPixmap(":/icons/breeze/default/kstars_satellites_visible.svg");
- invisibleSatPixmap = new QPixmap(":/icons/breeze/default/kstars_satellites_invisible.svg");
+ if (!visibleSatPixmap.get())
+ visibleSatPixmap.reset(new QPixmap(":/icons/breeze/default/kstars_satellites_visible.svg"));
+ if (!invisibleSatPixmap.get())
+ invisibleSatPixmap.reset(new QPixmap(":/icons/breeze/default/kstars_satellites_invisible.svg"));
}
void SkyQPainter::drawSkyLine(SkyPoint *a, SkyPoint *b)
diff --git a/kstars/skyqpainter.h b/kstars/skyqpainter.h
index 79bfbc7..41a987d 100644
--- a/kstars/skyqpainter.h
+++ b/kstars/skyqpainter.h
@@ -17,40 +17,47 @@
*/
-#ifndef SKYQPAINTER_H
-#define SKYQPAINTER_H
+#pragma once
#include "skypainter.h"
+#include <QColor>
+#include <QMap>
+
class Projector;
class QWidget;
class QSize;
class QMessageBox;
-/** @short The QPainter-based painting backend.
- This class implements the SkyPainter interface using a QPainter.
- For documentation, @see SkyPainter. */
+/**
+ * @short The QPainter-based painting backend.
+ * This class implements the SkyPainter interface using a QPainter.
+ * For documentation, @see SkyPainter.
+ */
class SkyQPainter : public SkyPainter, public QPainter
{
public:
+ /** Release the image cache */
+ static void releaseImageCache();
+
/**
- * @short Creates a SkyQPainter with the given QPaintDevice and uses the dimensions of the paint device as canvas dimensions
- * @param pd the painting device. Cannot be 0
- * @param canvasSize the size of the canvas
- */
+ * @short Creates a SkyQPainter with the given QPaintDevice and uses the dimensions of the paint device as canvas dimensions
+ * @param pd the painting device. Cannot be 0
+ * @param canvasSize the size of the canvas
+ */
SkyQPainter(QPaintDevice *pd, const QSize &canvasSize);
/**
- * @short Creates a SkyQPainter with the given QPaintDevice and given canvas size
- * @param pd the painting device. Cannot be 0
- */
+ * @short Creates a SkyQPainter with the given QPaintDevice and given canvas size
+ * @param pd the painting device. Cannot be 0
+ */
SkyQPainter(QPaintDevice *pd);
/**
- * @short Creates a SkyQPainter given a QWidget and an optional QPaintDevice.
- * @param widget the QWidget that provides the canvas size, and also the paint device unless @p pd is specified
- * @param pd the painting device. If 0, then @p widget will be used.
- */
+ * @short Creates a SkyQPainter given a QWidget and an optional QPaintDevice.
+ * @param widget the QWidget that provides the canvas size, and also the paint device unless @p pd is specified
+ * @param pd the painting device. If 0, then @p widget will be used.
+ */
explicit SkyQPainter(QWidget *widget, QPaintDevice *pd = 0);
virtual ~SkyQPainter();
@@ -58,9 +65,9 @@ class SkyQPainter : public SkyPainter, public QPainter
void setBrush(const QBrush &brush) Q_DECL_OVERRIDE;
/**
- * @param vectorStars Draw stars as vector graphics whenever possible.
- * @note Drawing stars as vectors is slower, but is better when saving .svg files. Set to true only when you are drawing on a canvas where speed doesn't matter. Definitely not when drawing on the SkyMap.
- */
+ * @param vectorStars Draw stars as vector graphics whenever possible.
+ * @note Drawing stars as vectors is slower, but is better when saving .svg files. Set to true only when you are drawing on a canvas where speed doesn't matter. Definitely not when drawing on the SkyMap.
+ */
inline void setVectorStars(bool vectorStars) { m_vectorStars = vectorStars; }
inline bool getVectorStars() const { return m_vectorStars; }
@@ -85,7 +92,7 @@ class SkyQPainter : public SkyPainter, public QPainter
virtual void drawDeepSkySymbol(const QPointF &pos, int type, float size, float e, float positionAngle);
bool drawSupernova(Supernova *sup) Q_DECL_OVERRIDE;
bool drawComet(KSComet *com) Q_DECL_OVERRIDE;
- ///This function exists so that we can draw other objects (e.g., planets) as point sources.
+ /// This function exists so that we can draw other objects (e.g., planets) as point sources.
virtual void drawPointSource(const QPointF &pos, float size, char sp = 'A');
bool drawConstellationArtImage(ConstellationsArt *obj) Q_DECL_OVERRIDE;
@@ -99,5 +106,3 @@ class SkyQPainter : public SkyPainter, public QPainter
static QColor m_starColor;
static QMap<char, QColor> ColorMap;
};
-
-#endif
diff --git a/kstars/texturemanager.cpp b/kstars/texturemanager.cpp
index 425b614..965d933 100644
--- a/kstars/texturemanager.cpp
+++ b/kstars/texturemanager.cpp
@@ -19,6 +19,10 @@
*/
#include "texturemanager.h"
+
+#include "kspaths.h"
+#include "auxiliary/kspaths.h"
+
#ifdef KSTARS_LITE
#include <QStandardPaths>
#include <QImage>
@@ -27,9 +31,6 @@
#include "kstars.h"
#endif
-#include "auxiliary/kspaths.h"
-#include "kspaths.h"
-
#ifdef HAVE_OPENGL
#include <QGLWidget>
#endif
@@ -38,7 +39,7 @@
// for image fails
const static QImage emptyImage;
-TextureManager *TextureManager::m_p;
+TextureManager *TextureManager::m_p = nullptr;
TextureManager *TextureManager::Create()
{
@@ -47,6 +48,12 @@ TextureManager *TextureManager::Create()
return m_p;
}
+void TextureManager::Release()
+{
+ delete m_p;
+ m_p = nullptr;
+}
+
const QImage &TextureManager::getImage(const QString &name)
{
Create();
diff --git a/kstars/texturemanager.h b/kstars/texturemanager.h
index 89fdf1d..6704557 100644
--- a/kstars/texturemanager.h
+++ b/kstars/texturemanager.h
@@ -17,8 +17,7 @@
*/
-#ifndef TEXTUREMANAGER_H
-#define TEXTUREMANAGER_H
+#pragma once
#include <QObject>
#include <QHash>
@@ -28,7 +27,8 @@
class QGLWidget;
class QImage;
-/** @brief a singleton class to manage texture loading/retrieval
+/**
+ * @brief a singleton class to manage texture loading/retrieval
*/
class TextureManager : public QObject
{
@@ -36,15 +36,20 @@ class TextureManager : public QObject
public:
/** @short Create the instance of TextureManager */
static TextureManager *Create();
+ /** @short Release the instance of TextureManager */
+ static void Release();
- /** Return texture image. If image is not found in cache tries to
- * load it from disk if that fails too returns reference to empty
- * image. */
+ /**
+ * Return texture image. If image is not found in cache tries to
+ * load it from disk if that fails too returns reference to empty image.
+ */
static const QImage &getImage(const QString &name);
#ifdef HAVE_OPENGL
- /** Bind OpenGL texture. Acts similarly to getImage but does
- * nothing if image is not found in the end */
+ /**
+ * Bind OpenGL texture. Acts similarly to getImage but does
+ * nothing if image is not found in the end
+ */
static void bindTexture(const QString &name, QGLWidget *cxt);
/** Bind OpenGL texture using QImage as source */
@@ -57,8 +62,7 @@ class TextureManager : public QObject
/** Private constructor */
explicit TextureManager(QObject *parent = 0);
- /** Try find image in the cache and then to load it from disk if
- * it's not found */
+ /** Try find image in the cache and then to load it from disk if it's not found */
static CacheIter findTexture(const QString &name);
// Pointer to singleton instance
@@ -70,5 +74,3 @@ class TextureManager : public QObject
TextureManager(const TextureManager &);
TextureManager &operator=(const TextureManager &);
};
-
-#endif // TEXTUREMANAGER_H
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index 7859966..49dfcfa 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -18,36 +18,33 @@
***************************************************************************/
#include "observinglist.h"
-#include "sessionsortfilterproxymodel.h"
+#include "config-kstars.h"
+
+#include "constellationboundarylines.h"
+#include "fov.h"
+#include "imageviewer.h"
#include "ksalmanac.h"
-#include "obslistwizard.h"
+#include "ksdssdownloader.h"
+#include "kspaths.h"
#include "kstars.h"
#include "kstarsdata.h"
#include "ksutils.h"
-#include "ksdssimage.h"
-#include "ksdssdownloader.h"
-#include "dialogs/locationdialog.h"
-#include "skyobjects/skyobject.h"
-#include "skyobjects/starobject.h"
-#include "skycomponents/skymapcomposite.h"
+#include "obslistpopupmenu.h"
+#include "obslistwizard.h"
+#include "Options.h"
+#include "sessionsortfilterproxymodel.h"
#include "skymap.h"
+#include "thumbnailpicker.h"
#include "dialogs/detaildialog.h"
#include "dialogs/finddialog.h"
-#include "tools/altvstime.h"
-#include "tools/wutdialog.h"
-#include "Options.h"
-#include "imageviewer.h"
-#include "thumbnailpicker.h"
-#include "obslistpopupmenu.h"
-#include "oal/log.h"
-#include "oal/oal.h"
+#include "dialogs/locationdialog.h"
#include "oal/execute.h"
+#include "skycomponents/skymapcomposite.h"
+#include "skyobjects/starobject.h"
+#include "tools/altvstime.h"
#include "tools/eyepiecefield.h"
-#include "fov.h"
-#include "constellationboundarylines.h"
-
-#include <config-kstars.h>
+#include "tools/wutdialog.h"
#ifdef HAVE_INDI
#include <basedevice.h>
@@ -56,29 +53,9 @@
#include "indi/driverinfo.h"
#include "ekos/ekosmanager.h"
#endif
-#include "kspaths.h"
+
#include <KPlotting/KPlotAxis>
#include <KPlotting/KPlotObject>
-#include <KMessageBox>
-
-#include <QFile>
-#include <QDir>
-#include <QFrame>
-#include <QTextStream>
-#include <QStandardItem>
-#include <QStandardItemModel>
-#include <QSortFilterProxyModel>
-#include <QHeaderView>
-#include <QDirIterator>
-#include <QPushButton>
-#include <QStatusBar>
-#include <QFileDialog>
-#include <QStandardPaths>
-#include <QTextEdit>
-#include <QLineEdit>
-#include <QInputDialog>
-
-#include <cstdio>
//
// ObservingListUI
@@ -109,7 +86,7 @@ ObservingList::ObservingList()
geo = KStarsData::Instance()->geo();
sessionView = false;
m_listFileName = QString();
- pmenu = new ObsListPopupMenu();
+ pmenu.reset(new ObsListPopupMenu());
//Set up the Table Views
m_WishListModel = new QStandardItemModel(0, 5, this);
m_SessionModel = new QStandardItemModel(0, 5);
diff --git a/kstars/tools/observinglist.h b/kstars/tools/observinglist.h
index c75372e..50a0712 100644
--- a/kstars/tools/observinglist.h
+++ b/kstars/tools/observinglist.h
@@ -15,33 +15,34 @@
* *
***************************************************************************/
-#ifndef OBSERVINGLIST_H_
-#define OBSERVINGLIST_H_
+#pragma once
#include "kstarsdatetime.h"
+#include "ui_observinglist.h"
-#include <QList>
#include <QAbstractTableModel>
-
#include <QDialog>
-#include <QTimer>
-//#include <KIO/CopyJob>
-
-#include "ui_observinglist.h"
+#include <QFrame>
+#include <QList>
+#include <QPixmap>
+#include <QTime>
#include <functional>
+#include <memory>
-class KSAlmanac;
class QSortFilterProxyModel;
+class QStandardItem;
class QStandardItemModel;
+class QTimer;
+
+class GeoLocation;
+class KSAlmanac;
+class KSDssDownloader;
class KStars;
class KStarsDateTime;
-class GeoLocation;
class ObsListPopupMenu;
-class SkyPoint;
class SkyObject;
-class KSDssDownloader;
-class QStandardItem;
+class SkyPoint;
class ObservingListUI : public QFrame, public Ui::ObservingList
{
@@ -409,7 +410,7 @@ class ObservingList : public QDialog
QStandardItemModel *m_WishListModel, *m_SessionModel;
QSortFilterProxyModel *m_WishListSortModel, *m_SessionSortModel;
QHash<QString, QTime> TimeHash;
- ObsListPopupMenu *pmenu;
+ std::unique_ptr<ObsListPopupMenu> pmenu;
KSDssDownloader *m_dl;
QHash<SkyObject *, QPixmap> ImagePreviewHash;
QPixmap m_NoImagePixmap;
@@ -417,5 +418,3 @@ class ObservingList : public QDialog
std::function<QStandardItem *(const SkyPoint &)> m_altCostHelper;
bool m_initialWishlistLoad = false;
};
-
-#endif // OBSERVINGLIST_H_
diff --git a/kstars/tools/obslistpopupmenu.cpp b/kstars/tools/obslistpopupmenu.cpp
index 7fbef6a..ffe9029 100644
--- a/kstars/tools/obslistpopupmenu.cpp
+++ b/kstars/tools/obslistpopupmenu.cpp
@@ -17,15 +17,12 @@
#include "obslistpopupmenu.h"
-#include <KLocalizedString>
+#include "config-kstars.h"
#include "kstars.h"
#include "kstarsdata.h"
-#include "skyobjects/skyobject.h"
#include "observinglist.h"
-#include <config-kstars.h>
-
ObsListPopupMenu::ObsListPopupMenu() : QMenu(0)
{
}
diff --git a/kstars/tools/obslistpopupmenu.h b/kstars/tools/obslistpopupmenu.h
index 01e2ddb..c9fb0bd 100644
--- a/kstars/tools/obslistpopupmenu.h
+++ b/kstars/tools/obslistpopupmenu.h
@@ -15,8 +15,7 @@
* *
***************************************************************************/
-#ifndef OBSLISTPOPUPMENU_H_
-#define OBSLISTPOPUPMENU_H_
+#pragma once
#include <QMenu>
@@ -37,15 +36,13 @@ class ObsListPopupMenu : public QMenu
/** Destructor (empty)*/
virtual ~ObsListPopupMenu();
- /** Initialize the popup menus. */
/**
- * @short initializes the popup menu based on the kind of selection in the observation planner
- * @param sessionView true if we are viewing the session, false if we are viewing the wish list
- * @param multiSelection true if multiple objects were selected, false if a single object was selected
- * @param showScope true if we should show INDI/telescope-related options, false otherwise.
- * @note Showing this popup-menu without a selection may lead to crashes.
- */
+ * Initialize the popup menus.
+ * @short initializes the popup menu based on the kind of selection in the observation planner
+ * @param sessionView true if we are viewing the session, false if we are viewing the wish list
+ * @param multiSelection true if multiple objects were selected, false if a single object was selected
+ * @param showScope true if we should show INDI/telescope-related options, false otherwise.
+ * @note Showing this popup-menu without a selection may lead to crashes.
+ */
void initPopupMenu(bool sessionView, bool multiSelection, bool showScope);
};
-
-#endif
diff --git a/tools/valgrind.supp b/tools/valgrind.supp
new file mode 100644
index 0000000..88175f9
--- /dev/null
+++ b/tools/valgrind.supp
@@ -0,0 +1,361 @@
+{
+ Glib1
+ Memcheck:Leak
+ ...
+ fun:call_init.part.0
+ fun:call_init
+ fun:_dl_init
+ ...
+}
+{
+ Glib2
+ Memcheck:Leak
+ ...
+ fun:_dl_catch_error
+ fun:_dl_open
+ fun:dlopen_doit
+ fun:_dl_catch_error
+ ...
+}
+{
+ Glib3
+ Memcheck:Leak
+ ...
+ fun:_dl_close_worker.part.0
+ fun:_dl_close_worker
+ fun:_dl_close
+ fun:_dl_catch_error
+ fun:_dlerror_run
+ fun:dlclose
+ ...
+}
+{
+ Whattheheck
+ Memcheck:Leak
+ ...
+ fun:malloc
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+ obj:*
+}
+{
+ Dbus1
+ Memcheck:Leak
+ ...
+ fun:_dbus_auth_client_new
+ ...
+}
+{
+ Dbus2
+ Memcheck:Leak
+ ...
+ obj:*libdbus*
+ ...
+ obj:*libQt5DBus*
+ ...
+}
+{
+ Dbus3
+ Memcheck:Leak
+ ...
+ fun:_dbus_message_loader_queue_messages
+ ...
+}
+{
+ Dbus4
+ Memcheck:Leak
+ ...
+ fun:_dbus_message_loader_new
+ ...
+}
+{
+ Dbus5
+ Memcheck:Leak
+ ...
+ fun:_dbus_auth_do_work
+ ...
+}
+{
+ Dbus6
+ Memcheck:Leak
+ ...
+ fun:dbus_message_append_args_valist
+ fun:dbus_message_append_args
+ fun:dbus_bus_add_match
+ ...
+}
+{
+ Dbus7
+ Memcheck:Leak
+ ...
+ fun:dbus_bus_register
+ ...
+}
+{
+ Xorg1
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ ...
+ fun:_XlcUtf8Loader
+ fun:_XOpenLC
+ fun:_XlcCurrentLC
+ ...
+}
+{
+ xml1
+ Memcheck:Leak
+ ...
+ fun:XML_ParseBuffer
+ ...
+}
+{
+ Qt1a
+ Memcheck:Param
+ writev(vector[...])
+ ...
+ fun:_ZN7QWidget10setVisibleEb
+ ...
+}
+{
+ Qt1b
+ Memcheck:Leak
+ ...
+ fun:_ZN7QWidget10setVisibleEb
+ ...
+}
+{
+ Qt2
+ Memcheck:Leak
+ match-leak-kinds: definite
+ fun:malloc
+ ...
+ fun:_XmbTextListToTextProperty
+ ...
+ fun:_ZN7QWindow8setTitleERK7QString
+ fun:_ZN14QWidgetPrivate21setWindowTitle_helperERK7QString
+ fun:_ZN14QWidgetPrivate24setWindowModified_helperEv
+ fun:_ZN14QWidgetPrivate10create_sysEybb
+ fun:_ZN7QWidget6createEybb
+ fun:_ZN7QWidget10setVisibleEb
+ fun:_ZN8QToolTip8showTextERK6QPointRK7QStringP7QWidgetRK5QRecti
+ fun:_ZN8QToolTip8showTextERK6QPointRK7QStringP7QWidget
+}
+{
+ Qt3
+ Memcheck:Leak
+ ...
+ fun:_ZN13QFontDatabase8findFontERK8QFontDefi
+ fun:_ZN13QFontDatabase4loadEPK12QFontPrivatei
+ ...
+}
+{
+ Qt4
+ Memcheck:Leak
+ ...
+ fun:_ZN27QEventDispatcherGlibPrivateC1EP13_GMainContext
+ ...
+}
+{
+ Qt5
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ ...
+ fun:g_private_get
+ ...
+ fun:g_main_context_dispatch
+ ...
+ fun:g_main_context_iteration
+ fun:_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
+ fun:_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE
+ fun:_ZN7QThread4execEv
+ ...
+}
+{
+ Qt6a
+ Memcheck:Leak
+ ...
+ fun:_ZN22QGuiApplicationPrivate4initEv
+ ...
+}
+{
+ Qt6b
+ Memcheck:Leak
+ ...
+ fun:_ZN23QCoreApplicationPrivate4initEv
+ ...
+}
+{
+ Qt6c
+ Memcheck:Leak
+ ...
+ fun:_ZN19QApplicationPrivate4initEv
+ ...
+}
+{
+ Qt7
+ Memcheck:Leak
+ ...
+ fun:_ZN7QObject5eventEP6QEvent
+ fun:_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent
+ ...
+}
+{
+ Qt8
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ ...
+ fun:_ZN15QGuiApplication16saveStateRequestER15QSessionManager
+ ...
+}
+{
+ Qt9
+ Memcheck:Leak
+ match-leak-kinds: reachable
+ fun:malloc
+ fun:_XlcCreateLC
+ fun:_XlcUtf8Loader
+ fun:_XOpenLC
+ fun:_XlcCurrentLC
+ fun:XmbTextListToTextProperty
+ ...
+ fun:_ZN14QWindowPrivate6createEb
+ fun:_ZN14QWidgetPrivate10create_sysEybb
+ fun:_ZN7QWidget6createEybb
+}
+{
+ Qt10
+ Memcheck:Leak
+ ...
+ fun:_ZNK7QWidget14ensurePolishedEv
+ ...
+}
+{
+ Qt11
+ Memcheck:Leak
+ ...
+ fun:_ZN7QWindow8setTitleERK7QString
+ fun:_ZN14QWidgetPrivate21setWindowTitle_helperERK7QString
+ fun:_ZN7QWidget6createEybb
+ fun:_ZNK7QWidget5winIdEv
+ ...
+}
+{
+ Qt12
+ Memcheck:Leak
+ ...
+ fun:_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent
+ ...
+}
+{
+ Qt13
+ Memcheck:Leak
+ ...
+ fun:_ZN15QGuiApplication16saveStateRequestER15QSessionManager
+ ...
+}
+{
+ Qt14
+ Memcheck:Leak
+ ...
+ fun:_ZN7QString20fromLocal8Bit_helperEPKci
+ ...
+}
+{
+ Qt15
+ Memcheck:Leak
+ ...
+ fun:_ZN14QWindowPrivate9setCursorEPK7QCursor
+ ...
+}
+{
+ Qt16
+ Memcheck:Leak
+ ...
+ fun:_ZN10QArrayData8allocateEmmm6QFlagsINS_16AllocationOptionEE
+ ...
+}
+{
+ Qt17
+ Memcheck:Leak
+ ...
+ fun:_ZN9QHashData6rehashEi
+ fun:willGrow
+ fun:_ZN5QHashIjbEixERKj
+ ...
+}
+{
+ Qt18
+ Memcheck:Leak
+ ...
+ fun:_ZNK20QPlatformIntegration20createPlatformPixmapEN15QPlatformPixmap9PixelTypeE
+ fun:_ZN7QPixmap16fromImageInPlaceER6QImage6QFlagsIN2Qt19ImageConversionFlagEE
+ fun:_ZNK15QPlatformPixmap11transformedERK10QTransformN2Qt18TransformationModeE
+ fun:_ZNK7QPixmap11transformedERK10QTransformN2Qt18TransformationModeE
+ fun:_ZNK7QPixmap6scaledERK5QSizeN2Qt15AspectRatioModeENS3_18TransformationModeE
+ ...
+}
+{
+ Qt19
+ Memcheck:Leak
+ ...
+ fun:_ZN8QPaletteC1Ev
+ ...
+}
+{
+ Qt20
+ Memcheck:Leak
+ ...
+ fun:_ZN12QApplication5styleEv
+ ...
+}
+{
+ KDE1
+ Memcheck:Leak
+ ...
+ fun:_ZN6KCrash10initializeEv
+ ...
+}
+{
+ KDE2
+ Memcheck:Leak
+ ...
+ fun:_ZN13KSelectActionC1ERK7QStringP7QObject
+ ...
+}
+{
+ KDE3
+ Memcheck:Leak
+ ...
+ fun:_ZN9KuitSetupC1ERK10QByteArray
+ ...
+}
+{
+ KDE4
+ Memcheck:Leak
+ ...
+ fun:_ZNK16KLocalizedString8toStringEv
+ ...
+}
+{
+ KDE5
+ Memcheck:Leak
+ ...
+ fun:_ZN12KConfigGroupC1EP11KConfigBasePKc
+ ...
+}
+{
+ KDE6
+ Memcheck:Leak
+ ...
+ fun:_ZN16KLocalizedString20setApplicationDomainEPKc
+ ...
+}