diff --git a/datahandlers/catalogdb.h b/datahandlers/catalogdb.h index 712a775ce..7f5639b72 100644 --- a/datahandlers/catalogdb.h +++ b/datahandlers/catalogdb.h @@ -1,261 +1,262 @@ /*************************************************************************** catalogDB.h - K Desktop Planetarium ------------------- begin : 2012/03/08 copyright : (C) 2012 by Rishab Arora email : ra.rishab@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "ksparser.h" #include #if !defined(ANDROID) #include #endif #include #include class SkyObject; class CatalogComponent; class CatalogData; class CatalogEntryData; /* * 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. 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. */ 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 **/ bool Initialize(); /** * @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* **/ QStringList *Catalogs(); /** * @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 */ 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 */ 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 + * @param magnitude Magnitude 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 **/ void RemoveCatalog(const QString &catalog_name); /** * @brief Creates objects of type SkyObject and assigns them to references * * @param catalog_name Name of the catalog whose objects are needed. * @param sky_list List of all skyobjects stored in database (assigns) * @param object_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 &sky_list, QList> &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 **/ 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 **/ bool AddEntry(const CatalogEntryData &catalog_entry, int catid); /** * @brief Check an entry in the database * * @note This public method opens and closes the database. * * @param entry_long_name Long name of the entry * @param catid Category ID in the database * @return True if successful otherwise false **/ bool CheckCustomEntry(const QString &entry_long_name, int catid); /** * @brief Remove an entry from the database * * @note This public method opens and closes the database. * * @param entry_long_name Long name of the entry * @param catid Category ID in the database * @return True if successful otherwise false **/ bool RemoveCustomEntry(const QString &entry_long_name, int catid); /** * @brief Returns database ID of the required catalog. * Returns -1 if not found. * * @param catalog_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 **/ 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 **/ bool _AddEntry(const CatalogEntryData &catalog_entry, int catid); /** * @brief Database object for the sky object. Assigned and Initialized by Initialize() **/ QSqlDatabase skydb_; /** * @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() **/ 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 **/ 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 **/ QList> buildParserSequence(const QStringList &Columns); /** * @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 initialize a database for catalog storage * * @return void **/ void FirstRun(); }; diff --git a/kstars/auxiliary/dms.h b/kstars/auxiliary/dms.h index cc4b824b2..dd2b2b929 100644 --- a/kstars/auxiliary/dms.h +++ b/kstars/auxiliary/dms.h @@ -1,492 +1,495 @@ /*************************************************************************** dms.h - K Desktop Planetarium ------------------- begin : Sun Feb 11 2001 copyright : (C) 2001 by Jason Harris email : jharris@30doradus.org ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "../nan.h" #include #include #include //#define COUNT_DMS_SINCOS_CALLS true //#define PROFILE_SINCOS true #ifdef PROFILE_SINCOS #include #endif /** @class dms * @short An angle, stored as degrees, but expressible in many ways. * @author Jason Harris * @version 1.0 * * dms encapsulates an angle. The angle is stored as a double, * equal to the value of the angle in degrees. Methods are available * for setting/getting the angle as a floating-point measured in * Degrees or Hours, or as integer triplets (degrees, arcminutes, * arcseconds or hours, minutes, seconds). There is also a method * to set the angle according to a radian value, and to return the * angle expressed in radians. Finally, a SinCos() method computes * the sin and cosine of the angle. */ class dms { public: /** Default constructor. */ dms() : D(NaN::d) #ifdef COUNT_DMS_SINCOS_CALLS , m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** Empty virtual destructor */ virtual ~dms() = default; /** @short Set the floating-point value of the angle according to the four integer arguments. * @param d degree portion of angle (int). Defaults to zero. * @param m arcminute portion of angle (int). Defaults to zero. * @param s arcsecond portion of angle (int). Defaults to zero. * @param ms arcsecond portion of angle (int). Defaults to zero. */ explicit dms(const int &d, const int &m = 0, const int &s = 0, const int &ms = 0) #ifdef COUNT_DMS_SINCOS_CALLS : m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { dms::setD(d, m, s, ms); #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** @short Construct an angle from a double value. * * Creates an angle whose value in Degrees is equal to the argument. * @param x angle expressed as a floating-point number (in degrees) */ explicit dms(const double &x) : D(x) #ifdef COUNT_DMS_SINCOS_CALLS , m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** @short Construct an angle from a string representation. * * Attempt to create the angle according to the string argument. If the string * cannot be parsed as an angle value, the angle is set to zero. * * @warning There is not an unambiguous notification that it failed to parse the string, * since the string could have been a valid representation of zero degrees. * If this is a concern, use the setFromString() function directly instead. * * @param s the string to parse as a dms value. * @param isDeg if true, value is in degrees; if false, value is in hours. * @sa setFromString() */ explicit dms(const QString &s, bool isDeg = true) #ifdef COUNT_DMS_SINCOS_CALLS : m_sinCosCalled(false), m_sinDirty(true), m_cosDirty(true) #endif { setFromString(s, isDeg); #ifdef COUNT_DMS_SINCOS_CALLS ++dms_constructor_calls; #endif } /** @return integer degrees portion of the angle */ inline int degree() const { if (std::isnan(D)) return 0; return int(D); } /** @return integer arcminutes portion of the angle. * @note an arcminute is 1/60 degree. */ int arcmin() const; /** @return integer arcseconds portion of the angle * @note an arcsecond is 1/60 arcmin, or 1/3600 degree. */ int arcsec() const; /** @return integer milliarcseconds portion of the angle * @note a milliarcsecond is 1/1000 arcsecond. */ int marcsec() const; /** @return angle in degrees expressed as a double. */ inline const double &Degrees() const { return D; } /** @return integer hours portion of the angle * @note an angle can be measured in degrees/arcminutes/arcseconds * or hours/minutes/seconds. An hour is equal to 15 degrees. */ inline int hour() const { return int(reduce().Degrees() / 15.0); } /** @return integer minutes portion of the angle * @note a minute is 1/60 hour (not the same as an arcminute) */ int minute() const; /** @return integer seconds portion of the angle * @note a second is 1/3600 hour (not the same as an arcsecond) */ int second() const; /** @return integer milliseconds portion of the angle * @note a millisecond is 1/1000 second (not the same as a milliarcsecond) */ int msecond() const; /** @return angle in hours expressed as a double. * @note an angle can be measured in degrees/arcminutes/arcseconds * or hours/minutes/seconds. An hour is equal to 15 degrees. */ inline double Hours() const { return reduce().Degrees() / 15.0; } /** Sets floating-point value of angle, in degrees. * @param x new angle (double) */ inline virtual void setD(const double &x) { #ifdef COUNT_DMS_SINCOS_CALLS m_sinDirty = m_cosDirty = true; #endif D = x; } /** @short Sets floating-point value of angle, in degrees. * * This is an overloaded member function; it behaves essentially * like the above function. The floating-point value of the angle * (D) is determined from the following formulae: * * \f$ fabs(D) = fabs(d) + \frac{(m + (s/60))}{60} \f$ * \f$ sgn(D) = sgn(d) \f$ * * @param d integer degrees portion of angle * @param m integer arcminutes portion of angle * @param s integer arcseconds portion of angle * @param ms integer arcseconds portion of angle */ virtual void setD(const int &d, const int &m, const int &s, const int &ms = 0); /** @short Sets floating-point value of angle, in hours. * * Converts argument from hours to degrees, then * sets floating-point value of angle, in degrees. * @param x new angle, in hours (double) * @sa setD() */ inline virtual void setH(const double &x) { dms::setD(x * 15.0); #ifdef COUNT_DMS_SINCOS_CALLS m_cosDirty = m_sinDirty = true; #endif } /** @short Sets floating-point value of angle, in hours. * * Converts argument values from hours to degrees, then * sets floating-point value of angle, in degrees. * This is an overloaded member function, provided for convenience. It * behaves essentially like the above function. * @param h integer hours portion of angle * @param m integer minutes portion of angle * @param s integer seconds portion of angle * @param ms integer milliseconds portion of angle * @sa setD() */ virtual void setH(const int &h, const int &m, const int &s, const int &ms = 0); /** @short Attempt to parse the string argument as a dms value, and set the dms object * accordingly. * @param s the string to be parsed as a dms value. The string can be an int or * floating-point value, or a triplet of values (d/h, m, s) separated by spaces or colons. * @param isDeg if true, the value is in degrees. Otherwise, it is in hours. * @return true if sting was parsed successfully. Otherwise, set the dms value * to 0.0 and return false. */ virtual bool setFromString(const QString &s, bool isDeg = true); /** @short Compute Sine and Cosine of the angle simultaneously. * On machines using glibc >= 2.1, calling SinCos() is somewhat faster * than calling sin() and cos() separately. * The values are returned through the arguments (passed by reference). * * @param s Sine of the angle * @param c Cosine of the angle * @sa sin() cos() */ inline void SinCos(double &s, double &c) const; /** @short Compute the Angle's Sine. * * @return the Sine of the angle. * @sa cos() */ double sin() const { #ifdef COUNT_DMS_SINCOS_CALLS if (!m_sinCosCalled) { m_sinCosCalled = true; ++dms_with_sincos_called; } if (m_sinDirty) m_sinDirty = false; else ++redundant_trig_function_calls; ++trig_function_calls; #endif #ifdef PROFILE_SINCOS std::clock_t start, stop; double s; start = std::clock(); s = ::sin(D * DegToRad); stop = std::clock(); seconds_in_trig += double(stop - start) / double(CLOCKS_PER_SEC); return s; #else return ::sin(D * DegToRad); #endif } /** @short Compute the Angle's Cosine. * * @return the Cosine of the angle. * @sa sin() */ double cos() const { #ifdef COUNT_DMS_SINCOS_CALLS if (!m_sinCosCalled) { m_sinCosCalled = true; ++dms_with_sincos_called; } if (m_cosDirty) m_cosDirty = false; else ++redundant_trig_function_calls; ++trig_function_calls; #endif #ifdef PROFILE_SINCOS std::clock_t start, stop; double c; start = std::clock(); c = ::cos(D * DegToRad); stop = std::clock(); seconds_in_trig += double(stop - start) / double(CLOCKS_PER_SEC); return c; #else return ::cos(D * DegToRad); #endif } /** @short Express the angle in radians. * @return the angle in radians (double) */ inline double radians() const { return D * DegToRad; } /** @short Set angle according to the argument, in radians. * * This function converts the argument to degrees, then sets the angle * with setD(). * @param Rad an angle in radians */ inline virtual void setRadians(const double &Rad) { dms::setD(Rad / DegToRad); #ifdef COUNT_DMS_SINCOS_CALLS m_cosDirty = m_sinDirty = true; #endif } /** return the equivalent angle between 0 and 360 degrees. * @warning does not change the value of the parent angle itself. */ const dms reduce() const; /** * @brief deltaAngle Return the shortest difference (path) between this angle and the supplied angle. The range is normalized to [-180,+180] * @param angle Angle to subtract from current angle. * @return Normalized angle in the range [-180,+180] */ const dms deltaAngle(dms angle) const; /** * @short an enum defining standard angle ranges */ enum AngleRanges { ZERO_TO_2PI, MINUSPI_TO_PI }; /** * @short Reduce _this_ angle to the given range */ void reduceToRange(enum dms::AngleRanges range); /** @return a nicely-formatted string representation of the angle * in degrees, arcminutes, and arcseconds. + * @param forceSign if @c true then adds '+' or '-' to the string * @param machineReadable uses a colon separator and produces +/-dd:mm:ss format instead + * @param highPrecision adds milliseconds, if @c false the seconds will be shown as an integer */ const QString toDMSString(const bool forceSign = false, const bool machineReadable = false, const bool highPrecision=false) const; /** @return a nicely-formatted string representation of the angle * in hours, minutes, and seconds. * @param machineReadable uses a colon separator and produces hh:mm:ss format instead + * @param highPrecision adds milliseconds, if @c false the seconds will be shown as an integer */ const QString toHMSString(const bool machineReadable = false, const bool highPrecision=false) const; /** PI is a const static member; it's public so that it can be used anywhere, * as long as dms.h is included. */ static constexpr double PI = { M_PI }; /** DegToRad is a const static member equal to the number of radians in * one degree (dms::PI/180.0). */ static constexpr double DegToRad = { M_PI / 180.0 }; /** @short Static function to create a DMS object from a QString. * * There are several ways to specify the angle: * @li Integer numbers ( 5 or -33 ) * @li Floating-point numbers ( 5.0 or -33.0 ) * @li colon-delimited integers ( 5:0:0 or -33:0:0 ) * @li colon-delimited with float seconds ( 5:0:0.0 or -33:0:0.0 ) * @li colon-delimited with float minutes ( 5:0.0 or -33:0.0 ) * @li space-delimited ( 5 0 0; -33 0 0 ) or ( 5 0.0 or -33 0.0 ) * @li space-delimited, with unit labels ( 5h 0m 0s or -33d 0m 0s ) * @param s the string to be parsed as an angle value * @param deg if true, s is expressed in degrees; if false, s is expressed in hours * @return a dms object whose value is parsed from the string argument */ static dms fromString(const QString &s, bool deg); inline dms operator-() { return dms(-D); } #ifdef COUNT_DMS_SINCOS_CALLS static long unsigned dms_constructor_calls; // counts number of DMS constructor calls static long unsigned dms_with_sincos_called; static long unsigned trig_function_calls; // total number of trig function calls static long unsigned redundant_trig_function_calls; // counts number of redundant trig function calls static double seconds_in_trig; // accumulates number of seconds spent in trig function calls #endif protected: double D; private: #ifdef COUNT_DMS_SINCOS_CALLS mutable bool m_sinDirty, m_cosDirty, m_sinCosCalled; #endif friend dms operator+(dms, dms); friend dms operator-(dms, dms); friend QDataStream &operator<<(QDataStream &out, const dms &d); friend QDataStream &operator>>(QDataStream &in, dms &d); }; /// Add two angles inline dms operator+(dms a, dms b) { return dms(a.D + b.D); } /// Subtract angles inline dms operator-(dms a, dms b) { return dms(a.D - b.D); } // Inline sincos inline void dms::SinCos(double &s, double &c) const { #ifdef PROFILE_SINCOS std::clock_t start, stop; start = std::clock(); #endif #ifdef __GLIBC__ #if (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && !defined(__UCLIBC__)) //GNU version sincos(radians(), &s, &c); #else //For older GLIBC versions s = ::sin(radians()); c = ::cos(radians()); #endif #else //ANSI-compliant version s = ::sin(radians()); c = ::cos(radians()); #endif #ifdef PROFILE_SINCOS stop = std::clock(); seconds_in_trig += double(stop - start) / double(CLOCKS_PER_SEC); #endif #ifdef COUNT_DMS_SINCOS_CALLS if (!m_sinCosCalled) { m_sinCosCalled = true; ++dms_with_sincos_called; } if (m_sinDirty) m_sinDirty = false; else ++redundant_trig_function_calls; if (m_cosDirty) m_cosDirty = false; else ++redundant_trig_function_calls; trig_function_calls += 2; #endif } /** Overloaded equality operator */ inline bool operator==(const dms &a1, const dms &a2) { return a1.Degrees() == a2.Degrees(); } diff --git a/kstars/auxiliary/ksdssdownloader.h b/kstars/auxiliary/ksdssdownloader.h index 5dcd626ce..13f2edd36 100644 --- a/kstars/auxiliary/ksdssdownloader.h +++ b/kstars/auxiliary/ksdssdownloader.h @@ -1,134 +1,134 @@ /*************************************************************************** ksdssdownloader.h - K Desktop Planetarium ------------------- begin : Tue 05 Jan 2016 03:22:50 CST copyright : (c) 2016 by Akarsh Simha email : akarsh.simha@kdemail.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "ksdssimage.h" #include #include #include #include #include #include class FileDownloader; class SkyPoint; class dms; /** * @class KSDssDownloader * @short Helps download a DSS image * @author Akarsh Simha * * @note This object is designed to commit suicide (calls * QObject::deleteLater() )! Never allocate this using anything but * new -- do not allocate it on the stack! This is ideal for its * operation, as it deletes itself after downloading. */ class KSDssDownloader : public QObject { Q_OBJECT public: /** @short Constructor */ explicit KSDssDownloader(QObject *parent = nullptr); /** * @short Constructor that initiates a "standard" DSS download job, calls the downloadReady slot, and finally self destructs * @note Very important that if you create with this constructor, * the object will self-destruct. Avoid keeping pointers to it, or * things may segfault! */ KSDssDownloader(const SkyPoint *const p, const QString &destFileName, const std::function &slotDownloadReady, QObject *parent = nullptr); /** * @short Stateful single-download of a supplied URL. Use when the flexibility is required * @note Does not self-delete this object. Construct with default constructor, and delete as usual. * @param srcUrl source DSS URL to download * @param destFileName destination image file (will be of PNG format) * @param md DSS image metadata to write into image file * @note emits downloadComplete with success state when done */ void startSingleDownload(const QUrl srcUrl, const QString &destFileName, KSDssImage::Metadata &md); /** * @short High-level method to create a URL to obtain a DSS image for a given SkyPoint * @note If SkyPoint is a DeepSkyObject, this method automatically * decides the image size required to fit the object. * @note Moved from namespace KSUtils (--asimha, Jan 5 2016) */ static QString getDSSURL(const SkyPoint *const p, const QString &version = "all", struct KSDssImage::Metadata *md = nullptr); /** * @short High-level method to create a URL to obtain a DSS image for a given SkyPoint * @note This method includes an option to set the height, but uses default values for many parameters */ static QString getDSSURL(const SkyPoint *const p, float width, float height = 0, const QString &version = "all", struct KSDssImage::Metadata *md = nullptr); /** * @short Create a URL to obtain a DSS image for a given RA, Dec * @param ra The J2000.0 Right Ascension of the point * @param dec The J2000.0 Declination of the point * @param width The width of the image in arcminutes * @param height The height of the image in arcminutes - * @param type The image type, either gif or fits. - * @param version string describing which version to get + * @param type_ The image type, either gif or fits. + * @param version_ string describing which version to get * @param md If a valid pointer is provided, fill with metadata * @note This method resets height and width to fall within the range accepted by DSS * @note Moved from namespace KSUtils (--asimha, Jan 5 2016) * * @note Valid versions are: dss1, poss2ukstu_red, poss2ukstu_ir, * poss2ukstu_blue, poss1_blue, poss1_red, all, quickv, * phase2_gsc2, phase2_gsc1. Of these, dss1 uses POSS1 Red in the * north and POSS2/UKSTU Blue in the south. all uses the best of a * combined list of all plates. * */ static QString getDSSURL(const dms &ra, const dms &dec, float width = 0, float height = 0, const QString &type_ = "gif", const QString &version_ = "all", struct KSDssImage::Metadata *md = nullptr); /** @short Write image metadata into file */ static bool writeImageWithMetadata(const QString &srcFile, const QString &destFile, const KSDssImage::Metadata &md); signals: void downloadComplete(bool success); void downloadCanceled(); private slots: void downloadAttemptFinished(); void singleDownloadFinished(); void downloadError(const QString &errorString); private: void startDownload(const SkyPoint *const p, const QString &destFileName); void initiateSingleDownloadAttempt(QUrl srcUrl); bool writeImageFile(); QStringList m_VersionPreference; int m_attempt { 0 }; struct KSDssImage::Metadata m_AttemptData; QString m_FileName; QTemporaryFile m_TempFile; FileDownloader *downloadJob { nullptr }; }; diff --git a/kstars/auxiliary/schememanager.h b/kstars/auxiliary/schememanager.h index 85bb594c3..6bcc80811 100644 --- a/kstars/auxiliary/schememanager.h +++ b/kstars/auxiliary/schememanager.h @@ -1,453 +1,455 @@ /* ============================================================ * * This file is a part of digiKam project * http://www.digikam.org * * Date : 2004-08-02 * Description : colors scheme manager * * Copyright (C) 2006-2018 by Gilles Caulier * Copyright (C) 2007 by Matthew Woehlke * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * ============================================================ */ #pragma once #include #include #include #include #include class SchemeManagerPrivate; /** * A set of methods used to work with colors. * * SchemeManager currently provides access to the system color palette that the * user has selected (in the future, it is expected to do more). It greatly * expands on QPalette by providing five distinct "sets" with several color * choices each, covering background, foreground, and decoration colors. * * A SchemeManager instance represents colors corresponding to a "set", where a * set consists of those colors used to draw a particular type of element, such * as a menu, button, view, selected text, or tooltip. Each set has a distinct * set of colors, so you should always use the correct set for drawing and * never assume that a particular foreground for one set is the same as the * foreground for any other set. Individual colors may be quickly referenced by * creating an anonymous instance and invoking a lookup member. * * @note * The color palettes for the various states of a widget (active, inactive, * disabled) may be wildly different. Therefore, it is important to take the * state into account. This is why the SchemeManager constructor requires a * QPalette::ColorGroup as an argument. * * To facilitate working with potentially-varying states, two convenience API's * are provided. These are SchemeManager::adjustBackground and its sister * SchemeManager::adjustForeground, and the helper class KStatefulBrush. * * @see SchemeManager::ColorSet, SchemeManager::ForegroundRole, * SchemeManager::BackgroundRole, SchemeManager::DecorationRole, * SchemeManager::ShadeRole */ class SchemeManager { public: /** * This enumeration describes the color set for which a color is being * selected. * * Color sets define a color "environment", suitable for drawing all parts * of a given region. Colors from different sets should not be combined. */ enum ColorSet { /** * Views; for example, frames, input fields, etc. * * If it contains things that can be selected, it is probably a View. */ View, /** * Non-editable window elements; for example, menus. * * If it isn't a Button, View, or Tooltip, it is probably a Window. */ Window, /** * Buttons and button-like controls. * * In addition to buttons, "button-like" controls such as non-editable * dropdowns, scrollbar sliders, slider handles, etc. should also use * this role. */ Button, /** * Selected items in views. * * Note that unfocused or disabled selections should use the Window * role. This makes it more obvious to the user that the view * containing the selection does not have input focus. */ Selection, /** * Tooltips. * * The tooltip set can often be substituted for the view * set when editing is not possible, but the Window set is deemed * inappropriate. "What's This" help is an excellent example, another * might be pop-up notifications (depending on taste). */ Tooltip, /** * Complementary areas. * * Some applications want some areas to have a different color scheme. * Usually dark areas over a light theme. For instance the fullscreen UI * of a picture viewer, or the logout/lock screen of the plasma workspace * ask for a dark color scheme even on light themes. * @since 5.19 */ Complementary }; /** * This enumeration describes the background color being selected from the * given set. * * Background colors are suitable for drawing under text, and should never * be used to draw text. In combination with one of the overloads of * SchemeManager::shade, they may be used to generate colors for drawing * frames, bevels, and similar decorations. */ enum BackgroundRole { /** * Normal background. */ NormalBackground = 0, /** * Alternate background; for example, for use in lists. * * This color may be the same as BackgroundNormal, especially in sets * other than View and Window. */ AlternateBackground = 1, /** * Third color; for example, items which are new, active, requesting * attention, etc. * * Alerting the user that a certain field must be filled out would be a * good usage (although NegativeBackground could be used to the same * effect, depending on what you are trying to achieve). Unlike * ActiveText, this should not be used for mouseover effects. */ ActiveBackground = 2, /** * Fourth color; corresponds to (unvisited) links. * * Exactly what this might be used for is somewhat harder to qualify; * it might be used for bookmarks, as a 'you can click here' indicator, * or to highlight recent content (i.e. in a most-recently-accessed * list). */ LinkBackground = 3, /** * Fifth color; corresponds to visited links. * * This can also be used to indicate "not recent" content, especially * when a color is needed to denote content which is "old" or * "archival". */ VisitedBackground = 4, /** * Sixth color; for example, errors, untrusted content, etc. */ NegativeBackground = 5, /** * Seventh color; for example, warnings, secure/encrypted content. */ NeutralBackground = 6, /** * Eigth color; for example, success messages, trusted content. */ PositiveBackground = 7 }; /** * This enumeration describes the foreground color being selected from the * given set. * * Foreground colors are suitable for drawing text or glyphs (such as the * symbols on window decoration buttons, assuming a suitable background * brush is used), and should never be used to draw backgrounds. * * For window decorations, the following is suggested, but not set in * stone: * @li Maximize - PositiveText * @li Minimize - NeutralText * @li Close - NegativeText * @li WhatsThis - LinkText * @li Sticky - ActiveText */ enum ForegroundRole { /** * Normal foreground. */ NormalText = 0, /** * Second color; for example, comments, items which are old, inactive * or disabled. Generally used for things that are meant to be "less * important". InactiveText is not the same role as NormalText in the * inactive state. */ InactiveText = 1, /** * Third color; for example items which are new, active, requesting * attention, etc. May be used as a hover color for clickable items. */ ActiveText = 2, /** * Fourth color; use for (unvisited) links. May also be used for other * clickable items or content that indicates relationships, items that * indicate somewhere the user can visit, etc. */ LinkText = 3, /** * Fifth color; used for (visited) links. As with LinkText, may be used * for items that have already been "visited" or accessed. May also be * used to indicate "historical" (i.e. "old") items or information, * especially if InactiveText is being used in the same context to * express something different. */ VisitedText = 4, /** * Sixth color; for example, errors, untrusted content, deletions, * etc. */ NegativeText = 5, /** * Seventh color; for example, warnings, secure/encrypted content. */ NeutralText = 6, /** * Eigth color; for example, additions, success messages, trusted * content. */ PositiveText = 7 }; /** * This enumeration describes the decoration color being selected from the * given set. * * Decoration colors are used to draw decorations (such as frames) for * special purposes. Like color shades, they are neither foreground nor * background colors. Text should not be painted over a decoration color, * and decoration colors should not be used to draw text. */ enum DecorationRole { /** * Color used to draw decorations for items which have input focus. */ FocusColor, /** * Color used to draw decorations for items which will be activated by * clicking. */ HoverColor }; /** * This enumeration describes the color shade being selected from the given * set. * * Color shades are used to draw "3d" elements, such as frames and bevels. * They are neither foreground nor background colors. Text should not be * painted over a shade, and shades should not be used to draw text. */ enum ShadeRole { /** * The light color is lighter than dark() or shadow() and contrasts * with the base color. */ LightShade, /** * The midlight color is in between base() and light(). */ MidlightShade, /** * The mid color is in between base() and dark(). */ MidShade, /** * The dark color is in between mid() and shadow(). */ DarkShade, /** * The shadow color is darker than light() or midlight() and contrasts * the base color. */ ShadowShade }; public: /** * Construct a copy of another SchemeManager. */ SchemeManager(const SchemeManager&); // Don't use dtor with default keyword here because it breaks the PIMPL pattern and refactoring is needed virtual ~SchemeManager(); /** * Standard assignment operator */ SchemeManager& operator=(const SchemeManager&); /** * Construct a palette from given color set and state, using the colors * from the given KConfig (if null, the system colors are used). */ explicit SchemeManager(QPalette::ColorGroup, ColorSet = View, KSharedConfigPtr = KSharedConfigPtr()); /** * Retrieve the requested background brush. */ QBrush background(BackgroundRole = NormalBackground) const; /** * Retrieve the requested foreground brush. */ QBrush foreground(ForegroundRole = NormalText) const; /** * Retrieve the requested decoration brush. */ QBrush decoration(DecorationRole) const; /** * Retrieve the requested shade color, using * SchemeManager::background(SchemeManager::NormalBackground) * as the base color and the contrast setting from the KConfig used to * create this SchemeManager instance (the system contrast setting, if no * KConfig was specified). * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). */ QColor shade(ShadeRole) const; /** * Returns the contrast for borders. * @return the contrast (between 0 for minimum and 10 for maximum * contrast) */ static int contrast(); /** * Returns the contrast for borders as a floating point value. * @param config pointer to the config from which to read the contrast * setting (the default is to use KSharedConfig::openConfig()) * @return the contrast (between 0.0 for minimum and 1.0 for maximum * contrast) */ static qreal contrastF(const KSharedConfigPtr& config = KSharedConfigPtr()); /** * Retrieve the requested shade color, using the specified color as the * base color and the system contrast setting. * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). */ static QColor shade(const QColor&, ShadeRole); /** * Retrieve the requested shade color, using the specified color as the * base color and the specified contrast. * + * @param color The base color + * @param role The shade role * @param contrast Amount roughly specifying the contrast by which to * adjust the base color, between -1.0 and 1.0 (values between 0.0 and 1.0 * correspond to the value from SchemeManager::contrastF) * @param chromaAdjust (optional) Amount by which to adjust the chroma of * the shade (1.0 means no adjustment) * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). * */ static QColor shade(const QColor&, ShadeRole, qreal contrast, qreal chromaAdjust = 0.0); /** * Adjust a QPalette by replacing the specified QPalette::ColorRole with * the requested background color for all states. Using this method is * safer than replacing individual states, as it insulates you against * changes in QPalette::ColorGroup. * * @note Although it is possible to replace a foreground color using this * method, it's bad usability to do so. Just say "no". */ static void adjustBackground(QPalette&, BackgroundRole newRole = NormalBackground, QPalette::ColorRole color = QPalette::Base, ColorSet set = View, KSharedConfigPtr = KSharedConfigPtr()); /** * Adjust a QPalette by replacing the specified QPalette::ColorRole with * the requested foreground color for all states. Using this method is * safer than replacing individual states, as it insulates you against * changes in QPalette::ColorGroup. * * @note Although it is possible to replace a background color using this * method, it's bad usability to do so. Just say "no". */ static void adjustForeground(QPalette&, ForegroundRole newRole = NormalText, QPalette::ColorRole color = QPalette::Text, ColorSet set = View, KSharedConfigPtr = KSharedConfigPtr()); /** * Used to obtain the QPalette that will be used to set the application * palette from KDE Platform theme. * * @param config KConfig from which to load the colors * * @returns the QPalette */ static QPalette createApplicationPalette(const KSharedConfigPtr& config); private: QExplicitlySharedDataPointer d; }; diff --git a/kstars/ekos/auxiliary/serialportassistant.cpp b/kstars/ekos/auxiliary/serialportassistant.cpp index 9d13e6291..271c2cbfa 100644 --- a/kstars/ekos/auxiliary/serialportassistant.cpp +++ b/kstars/ekos/auxiliary/serialportassistant.cpp @@ -1,88 +1,88 @@ /* Ekos Serial Port Assistant tool Copyright (C) 2019 Jasem Mutlaq This application is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #include #include #include "serialportassistant.h" #include "ekos_debug.h" #include "kspaths.h" SerialPortAssistant::SerialPortAssistant(ProfileInfo *profile, QWidget *parent) : QDialog(parent), m_Profile(profile) { setupUi(this); QPixmap im; if (im.load(KSPaths::locate(QStandardPaths::GenericDataLocation, "wzserialportassistant.png"))) wizardPix->setPixmap(im); else if (im.load(QDir(QCoreApplication::applicationDirPath() + "/../Resources/data").absolutePath() + "/wzserialportassistant.png")) wizardPix->setPixmap(im); connect(nextB, &QPushButton::clicked, [&]() { serialPortWizard->setCurrentIndex(serialPortWizard->currentIndex()+1); }); } void SerialPortAssistant::addDevice(ISD::GDInterface *device) { qCDebug(KSTARS_EKOS) << "Serial Port Assistant new device" << device->getDeviceName(); addPage(device); } void SerialPortAssistant::addPage(ISD::GDInterface *device) { QWidget *devicePage = new QWidget(this); devices.append(device); QVBoxLayout *layout = new QVBoxLayout(devicePage); QLabel *deviceLabel = new QLabel(devicePage); deviceLabel->setText(QString("

%1

").arg(device->getDeviceName())); layout->addWidget(deviceLabel); QLabel *instructionsLabel = new QLabel(devicePage); - instructionsLabel->setText(i18n("To assign a permenant designation to the device, you need to unplug the device from stellarmate " + instructionsLabel->setText(i18n("To assign a permanent designation to the device, you need to unplug the device from stellarmate " "then replug it after 1 second. Click on the Start Scan to begin this procedure.")); instructionsLabel->setWordWrap(true); layout->addWidget(instructionsLabel); QHBoxLayout *actionsLayout = new QHBoxLayout(devicePage); QPushButton *startButton = new QPushButton(i18n("Start Scan"), devicePage); QPushButton *skipButton = new QPushButton(i18n("Skip Device"), devicePage); - QCheckBox *hardwareSlotC = new QCheckBox(i18n("Phsical Port Mapping"), devicePage); - hardwareSlotC->setToolTip(i18n("Assign the permenant name based on which physical port the device is plugged to in StellarMate. " - "This is useful to distinguish between two identifical USB adapters. The device must always be " + QCheckBox *hardwareSlotC = new QCheckBox(i18n("Physical Port Mapping"), devicePage); + hardwareSlotC->setToolTip(i18n("Assign the permanent name based on which physical port the device is plugged to in StellarMate. " + "This is useful to distinguish between two identical USB adapters. The device must always be " "plugged into the same port for this to work.")); actionsLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Preferred)); actionsLayout->addWidget(startButton); actionsLayout->addWidget(skipButton); actionsLayout->addWidget(hardwareSlotC); actionsLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Preferred)); layout->addLayout(actionsLayout); QHBoxLayout *animationLayout = new QHBoxLayout(devicePage); QLabel *smAnimation = new QLabel(devicePage); //smAnimation->setFixedSize(QSize(360,203)); QMovie *smGIF = new QMovie(":/videos/sm_animation.gif"); smAnimation->setMovie(smGIF); animationLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Preferred)); animationLayout->addWidget(smAnimation); animationLayout->addItem(new QSpacerItem(10,10, QSizePolicy::Preferred)); layout->addLayout(animationLayout); smGIF->start(); //smAnimation->hide(); serialPortWizard->insertWidget(serialPortWizard->count()-1, devicePage); } diff --git a/kstars/ekos/auxiliary/serialportassistant.ui b/kstars/ekos/auxiliary/serialportassistant.ui index aaed19c80..7cdafceaf 100644 --- a/kstars/ekos/auxiliary/serialportassistant.ui +++ b/kstars/ekos/auxiliary/serialportassistant.ui @@ -1,209 +1,209 @@ SerialPortAssistant 0 0 516 334 Serial Port Assistant 3 3 3 3 3 0 0 true 3 0 <html><head/><body><p>Welcome to StellarMate <span style=" font-weight:600;">Serial Port Assistant</span> tool.</p></body></html> Qt::Vertical 20 40 - <html><head/><body><p>This tool shall assign <span style=" font-style:italic;">permenant</span> names to your <span style=" font-weight:600;">Serial to USB</span> devices so that they are easier to connect to in the future.</p><p><br/></p><p>Click <span style=" font-weight:600;">Next</span> to continue.</p></body></html> + <html><head/><body><p>This tool shall assign <span style=" font-style:italic;">permanent</span> names to your <span style=" font-weight:600;">Serial to USB</span> devices so that they are easier to connect to in the future.</p><p><br/></p><p>Click <span style=" font-weight:600;">Next</span> to continue.</p></body></html> true Qt::Vertical 20 40 Qt::Vertical 20 99 - All devices are succesfully mapped. + All devices are successfully mapped. You can now connect to your equipment. Qt::Vertical 20 96 Close 6 10 10 10 10 Qt::Horizontal QSizePolicy::Expanding 56 11 &Next true true diff --git a/kstars/hips/healpix.cpp b/kstars/hips/healpix.cpp index bca73b277..4edf8d27f 100644 --- a/kstars/hips/healpix.cpp +++ b/kstars/hips/healpix.cpp @@ -1,443 +1,445 @@ /* ----------------------------------------------------------------------------- * * Copyright (C) 1997-2016 Krzysztof M. Gorski, Eric Hivon, Martin Reinecke, * Benjamin D. Wandelt, Anthony J. Banday, * Matthias Bartelmann, * Reza Ansari & Kenneth M. Ganga * * * This file is part of HEALPix. * * Based on work by Pavel Mraz from SkyTechX. * * Adapted to KStars by Jasem Mutlaq. * * HEALPix is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * HEALPix is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HEALPix; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * For more information about HEALPix see http://healpix.sourceforge.net * *---------------------------------------------------------------------------*/ #include "healpix.h" #include #include "hipsmanager.h" #include "skypoint.h" #include "kstarsdata.h" #include "geolocation.h" static const double twothird = 2.0/3.0; static const double twopi = 6.283185307179586476925286766559005768394; static const double inv_halfpi = 0.6366197723675813430755350534900574; static const int jrll[] = { 2,2,2,2,3,3,3,3,4,4,4,4 }; static const int jpll[] = { 1,3,5,7,0,2,4,6,1,3,5,7 }; static const short ctab[] = { #define Z(a) a,a+1,a+256,a+257 #define Y(a) Z(a),Z(a+2),Z(a+512),Z(a+514) #define X(a) Y(a),Y(a+4),Y(a+1024),Y(a+1028) X(0),X(8),X(2048),X(2056) #undef X #undef Y #undef Z }; static const short utab[]={ #define Z(a) 0x##a##0, 0x##a##1, 0x##a##4, 0x##a##5 #define Y(a) Z(a##0), Z(a##1), Z(a##4), Z(a##5) #define X(a) Y(a##0), Y(a##1), Y(a##4), Y(a##5) X(0),X(1),X(4),X(5) #undef X #undef Y #undef Z }; static short xoffset[] = { -1,-1, 0, 1, 1, 1, 0,-1 }; static short yoffset[] = { 0, 1, 1, 1, 0,-1,-1,-1 }; static short facearray[9][12] = { { 8, 9,10,11,-1,-1,-1,-1,10,11, 8, 9 }, // S { 5, 6, 7, 4, 8, 9,10,11, 9,10,11, 8 }, // SE { -1,-1,-1,-1, 5, 6, 7, 4,-1,-1,-1,-1 }, // E { 4, 5, 6, 7,11, 8, 9,10,11, 8, 9,10 }, // SW { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }, // center { 1, 2, 3, 0, 0, 1, 2, 3, 5, 6, 7, 4 }, // NE { -1,-1,-1,-1, 7, 4, 5, 6,-1,-1,-1,-1 }, // W { 3, 0, 1, 2, 3, 0, 1, 2, 4, 5, 6, 7 }, // NW { 2, 3, 0, 1,-1,-1,-1,-1, 0, 1, 2, 3 } }; // N static uchar swaparray[9][12] = { { 0,0,3 }, // S { 0,0,6 }, // SE { 0,0,0 }, // E { 0,0,5 }, // SW { 0,0,0 }, // center { 5,0,0 }, // NE { 0,0,0 }, // W { 6,0,0 }, // NW { 3,0,0 } }; // N static double fmodulo(double v1, double v2) { if (v1>=0) { return (v1getCurrentFrame() == HIPSManager::HIPS_EQUATORIAL_FRAME) { skyCoords[i].setRA0(ra/15.0); skyCoords[i].setDec0(de); } else { dms galacticLong(ra); dms galacticLat(de); skyCoords[i].GalacticToEquatorial1950(&galacticLong, &galacticLat); skyCoords[i].B1950ToJ2000(); skyCoords[i].setRA0(skyCoords[i].ra()); skyCoords[i].setDec0(skyCoords[i].dec()); } skyCoords[i].updateCoords(KStarsData::Instance()->updateNum(), false); skyCoords[i].EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat()); } } void HEALPix::boundaries(qint32 nside, qint32 pix, int step, QVector3D *out) { int ix, iy, fn; nest2xyf(nside, pix, &ix, &iy, &fn); double dc = 0.5 / nside; double xc = (ix + 0.5) / nside; double yc = (iy + 0.5) / nside; double d = 1. / (step * nside); for (int i = 0; i < step; ++i) { out[0] = toVec3(xc+dc-i*d, yc+dc, fn); out[1] = toVec3(xc-dc, yc+dc-i*d, fn); out[2] = toVec3(xc-dc+i*d, yc-dc, fn); out[3] = toVec3(xc+dc, yc-dc+i*d, fn); } } QVector3D HEALPix::toVec3(double fx, double fy, int face) { double jr = jrll[face] - fx - fy; double locz; double locsth; double locphi; bool lochave_sth = false; double nr; if (jr<1) { nr = jr; double tmp = nr*nr/3.; locz = 1 - tmp; if (locz >0.99) { locsth = sqrt(tmp*(2.-tmp)); lochave_sth=true; } } else if (jr>3) { nr = 4-jr; double tmp = nr*nr/3.; locz = tmp - 1; if (locz<-0.99) { locsth=sqrt(tmp*(2.-tmp)); lochave_sth=true; } } else { nr = 1; locz = (2-jr)*2./3.; } double tmp=jpll[face]*nr+fx-fy; if (tmp<0) tmp+=8; if (tmp>=8) tmp-=8; locphi = (nr<1e-15) ? 0 : (0.5* dms::PI/2.0 *tmp)/nr; double st = lochave_sth ? locsth : sqrt((1.0-locz)*(1.0+locz)); QVector3D out; out.setX(st * cos(locphi)); out.setY(st * sin(locphi)); out.setZ(locz); return out; } void HEALPix::nest2xyf(int nside, int pix, int *ix, int *iy, int *face_num) { int npface_ = nside * nside, raw; *face_num = pix / npface_; pix &= (npface_ - 1); raw = (pix&0x5555) | ((pix&0x55550000)>>15); *ix = ctab[raw&0xff] | (ctab[raw>>8]<<4); pix >>= 1; raw = (pix&0x5555) | ((pix&0x55550000)>>15); *iy = ctab[raw&0xff] | (ctab[raw>>8]<<4); } static int64_t spread_bits64 (int v) { return (int64_t)(utab[ v &0xff]) | ((int64_t)(utab[(v>> 8)&0xff])<<16) | ((int64_t)(utab[(v>>16)&0xff])<<32) | ((int64_t)(utab[(v>>24)&0xff])<<48); } static int xyf2nest (int nside, int ix, int iy, int face_num) { return (face_num*nside*nside) + (utab[ix&0xff] | (utab[ix>>8]<<16) | (utab[iy&0xff]<<1) | (utab[iy>>8]<<17)); } /* int static leadingZeros(qint32 value) { int leadingZeros = 0; while(value != 0) { value = value >> 1; leadingZeros++; } return (32 - leadingZeros); } */ /* static int ilog2(qint32 arg) { return 32 - leadingZeros(qMax(arg, 1)); } */ static int nside2order(qint32 nside) { { int i=0; while((nside>>(++i))>0); return --i; } } /** Returns the neighboring pixels of ipix. This method works in both RING and NEST schemes, but is considerably faster in the NEST scheme. + @param nside defines the size of the neighboring area @param ipix the requested pixel number. + @param result the result array @return array with indices of the neighboring pixels. The returned array contains (in this order) the pixel numbers of the SW, W, NW, N, NE, E, SE and S neighbor of ipix. If a neighbor does not exist (this can only happen for the W, N, E and S neighbors), its entry is set to -1. */ void HEALPix::neighbours(int nside, qint32 ipix, int *result) { int ix, iy, face_num; int order = nside2order(nside); nest2xyf(nside, ipix, &ix, &iy, &face_num); qint32 nsm1 = nside-1; if ((ix>0)&&(ix0)&&(iy=nside) { x-=nside; nbnum+=1; } if (y<0) { y+=nside; nbnum-=3; } else if (y>=nside) { y-=nside; nbnum+=3; } int f = facearray[nbnum][face_num]; if (f>=0) { int bits = swaparray[nbnum][face_num>>2]; if ((bits&1)>0) x=(int)(nside-x-1); if ((bits&2)>0) y=(int)(nside-y-1); if ((bits&4)>0) { int tint=x; x=y; y=tint; } result[i] = xyf2nest(nside, x,y,f); } else result[i]=-1; } } } int HEALPix::ang2pix_nest_z_phi (qint32 nside_, double z, double phi) { double za = fabs(z); double tt = fmodulo(phi,twopi) * inv_halfpi; /* in [0,4) */ int face_num, ix, iy; if (za<=twothird) /* Equatorial region */ { double temp1 = nside_*(0.5+tt); double temp2 = nside_*(z*0.75); int jp = (int)(temp1-temp2); /* index of ascending edge line */ int jm = (int)(temp1+temp2); /* index of descending edge line */ int ifp = jp/nside_; /* in {0,4} */ int ifm = jm/nside_; face_num = (ifp==ifm) ? (ifp|4) : ((ifp 2/3 */ { int ntt = (int)tt, jp, jm; double tp, tmp; if (ntt>=4) ntt=3; tp = tt-ntt; tmp = nside_*sqrt(3*(1-za)); jp = (int)(tp*tmp); /* increasing edge line index */ jm = (int)((1.0-tp)*tmp); /* decreasing edge line index */ if (jp>=nside_) jp = nside_-1; /* for points too close to the boundary */ if (jm>=nside_) jm = nside_-1; if (z >= 0) { face_num = ntt; /* in {0,3} */ ix = nside_ - jm - 1; iy = nside_ - jp - 1; } else { face_num = ntt + 8; /* in {8,11} */ ix = jp; iy = jm; } } return xyf2nest(nside_,ix,iy,face_num); } int HEALPix::getPix(int level, double ra, double dec) { int nside = 1 << level; double polar[2] = { 0, 0 }; if (HIPSManager::Instance()->getCurrentFrame() == HIPSManager::HIPS_EQUATORIAL_FRAME) { polar[0] = dec; polar[1] = ra; } else if (HIPSManager::Instance()->getCurrentFrame() == HIPSManager::HIPS_GALACTIC_FRAME) { static QMatrix4x4 gl(-0.0548762f, -0.873437f, -0.483835f, 0, 0.4941100f, -0.444830f, 0.746982f, 0, -0.8676660f, -0.198076f, 0.455984f, 0, 0, 0, 0, 1); double rcb = cos(dec); QVector3D xyz = QVector3D(rcb * cos(ra), rcb * sin(ra), sin(dec)); xyz = gl.mapVector(xyz); xyz2sph(xyz, polar[1], polar[0]); } return ang2pix_nest_z_phi(nside, sin(polar[0]), polar[1]); } void HEALPix::getPixChilds(int pix, int *childs) { childs[0] = pix * 4 + 0; childs[1] = pix * 4 + 1; childs[2] = pix * 4 + 2; childs[3] = pix * 4 + 3; } void HEALPix::xyz2sph(const QVector3D &vec, double &l, double &b) { double rho = vec.x()*vec.x() + vec.y()*vec.y(); if (rho > 0) { l = atan2(vec.y(), vec.x()); l -= floor(l / (M_PI*2)) * (M_PI*2); b = atan2(vec.z(), sqrt(rho)); } else { l = 0.0; if (vec.z() == 0.0) { b = 0.0; } else { b = (vec.z() > 0.0) ? M_PI/2. : -dms::PI/2.; } } } diff --git a/kstars/htmesh/HTMesh.h b/kstars/htmesh/HTMesh.h index b9a4ccfc1..0e089c219 100644 --- a/kstars/htmesh/HTMesh.h +++ b/kstars/htmesh/HTMesh.h @@ -1,174 +1,175 @@ /*************************************************************************** HTMesh.h - K Desktop Planetarium ------------------- begin : 2007-06-14 copyright : (C) 2007 James B. Bowlin email : bowlin@mindspring.com ***************************************************************************/ // FIXME? We are needlessly copying the trixel data into the buffer during // indexing. One way to fix this is to give HTMesh next() and hasNext() // methods. This would also involve moving the convex and the range off the // stack and back to the heap when the indexing methods are called for indexing // and not drawing. Let's wait. #ifndef HTMESH_H #define HTMESH_H #include #include "typedef.h" class SpatialIndex; class RangeConvex; class MeshIterator; class MeshBuffer; /** * @class HTMesh * HTMesh was originally intended to be a simple interface to the HTM * library for the KStars project that would hide some of the complexity. But * it has gained some complexity of its own. * * The most complex addition was the routine that performs an intersection on a * line segment, finding all the trixels that cover the line. Perhaps there is * an easier and faster way to do it. Right now we convert to cartesian * coordinates to take the cross product of the two input vectors in order to * create a perpendicular which is used to form a very narrow triangle that * contains the original line segment as one of its long legs. * * Error detection and prevention added a little bit more complexity. The raw * HTM library is vulnerable to misbehavior if the polygon intersection routines * are given duplicate consecutive points, including the first point of a * polygon duplicating the last point. We test for duplicated points now. If * they are found, we drop down to the intersection routine with one fewer * vertices, ending at the line segment. If the two ends of a line segment are * much close together than the typical edge of a trixel then we simply index * each point separately and the result set is consists of the union of these * two trixels. * * The final (I hope) level of complexity was the addition of multiple results * buffers. You can set the number of results buffers in the HTMesh * constructor. Since each buffer has to be able to hold one integer for each * trixel in the mesh, multiple buffers can quickly eat up memory. The default * is just one buffer and all routines that use the buffers default to using the * just the first buffer. * * NOTE: all Right Ascensions (ra) and Declinations (dec) are in degrees. */ class HTMesh { public: /** @short constructor. * @param level is passed on to the underlying SpatialIndex * @param buildLevel is also passed on to the SpatialIndex * @param numBuffers controls how many output buffers are created. Don't * use more than require because they eat up mucho RAM. The default is * just one output buffer. */ HTMesh(int level, int buildLevel, int numBuffers = 1); ~HTMesh(); /** @short returns the index of the trixel that contains the specified * point. */ Trixel index(double ra, double dec) const; /** NOTE: The intersect() routines below are all used to find the trixels * needed to cover a geometric object: circle, line, triangle, and * quadrilateral. Since the number of trixels needed can be large and is * not known a priori, you must construct a MeshIterator to iterate over * the trixels that are the result of any of these 4 calculations. * * The HTMesh is created with one or more output buffers used for storing * the results. You can specify which output buffer is to be used to hold * the results by supplying an optional integer bufNum parameter. */ /** *@short finds the trixels that cover the specified circle *@param ra Central ra in degrees *@param dec Central dec in degrees *@param radius Radius of the circle in degrees + *@param bufNum the output buffer to hold the results *@note You will need to supply unprecessed (ra, dec) in most * situations. Please see SkyMesh::aperture()'s code before * messing with this method. */ void intersect(double ra, double dec, double radius, BufNum bufNum = 0); /** @short finds the trixels that cover the specified line segment */ void intersect(double ra1, double dec1, double ra2, double dec2, BufNum bufNum = 0); /** @short find the trixels that cover the specified triangle */ void intersect(double ra1, double dec1, double ra2, double dec2, double ra3, double dec3, BufNum bufNum = 0); /** @short finds the trixels that cover the specified quadrilateral */ void intersect(double ra1, double dec1, double ra2, double dec2, double ra3, double dec3, double ra4, double dec4, BufNum bufNum = 0); /** @short returns the number of trixels in the result buffer bufNum. */ int intersectSize(BufNum bufNum = 0); /** @short returns the total number of trixels in the HTM. This number * is 8 * 4^level. */ int size() const { return numTrixels; } /** @short returns the mesh level. */ int level() const { return m_level; } /** @short sets the debug level which is used to print out intermediate * results in the line intersection routine. */ void setDebug(int debug) { htmDebug = debug; } /** @short returns a pointer to the MeshBuffer specified by bufNum. * Currently this is only used in the MeshIterator constructor. */ MeshBuffer *meshBuffer(BufNum bufNum = 0); void vertices(Trixel id, double *ra1, double *dec1, double *ra2, double *dec2, double *ra3, double *dec3); private: const char *name; SpatialIndex *htm; int m_level, m_buildLevel; int numTrixels, magicNum; // These store the result sets: MeshBuffer **m_meshBuffer; BufNum m_numBuffers; double degree2Rad; double edge, edge10, eps; int htmDebug; /** @short fills the specified buffer with the intersection results in the * RangeConvex. */ bool performIntersection(RangeConvex *convex, BufNum bufNum = 0); /** @short users can only use the allocated buffers */ inline bool validBufNum(BufNum bufNum) { if (bufNum < m_numBuffers) return true; fprintf(stderr, "%s: bufNum: %d >= numBuffers: %d\n", name, bufNum, m_numBuffers); return false; } /** @short used by the line intersection routine. Maybe there is a * simpler and faster approach that does not require this conversion. */ void toXYZ(double ra, double dec, double *x, double *y, double *z); }; #endif diff --git a/kstars/htmesh/SpatialIndex.h b/kstars/htmesh/SpatialIndex.h index 70ac69b32..d6b57dd23 100644 --- a/kstars/htmesh/SpatialIndex.h +++ b/kstars/htmesh/SpatialIndex.h @@ -1,150 +1,150 @@ #ifndef _SpatialIndex_h #define _SpatialIndex_h //# Filename: SpatialIndex.h //# //# SpatialIndex is the class for the sky indexing routines. //# //# Author: Peter Z. Kunszt, based on A. Szalay s code //# //# Date: October 15, 1998 //# //# Copyright (C) 2000 Peter Z. Kunszt, Alex S. Szalay, Aniruddha R. Thakar //# The Johns Hopkins University //# Modification History: //# //# Oct 18, 2001 : Dennis C. Dinge -- Replaced ValVec with std::vector //# Sept 9, 2002 : Gyorgy Fekete -- added setMaxlevel() //# #include #include #include #include #include #include #include //######################################################################## //# //# Spatial Index class //# /** @class SpatialIndex SpatialIndex is a quad tree of spherical triangles. The tree is built in the following way: Start out with 8 triangles on the sphere using the 3 main circles to determine them. Then, every triangle can be decomposed into 4 new triangles by drawing main circles between midpoints of its edges:
 
 .                            /\
 .                           /  \
 .                          /____\
 .                         /\    /\
 .                        /  \  /  \
 .                       /____\/____\
 
 
This is how the quad tree is built up to a certain level by decomposing every triangle again and again. */ class LINKAGE SpatialIndex { public: /** Constructor. Give the level of the index and optionally the level to build - i.e. the depth to keep in memory. if maxlevel - buildlevel > 0 , that many levels are generated on the fly each time the index is called. */ SpatialIndex(size_t maxlevel, size_t buildlevel = 5); /// NodeName conversion to integer ID static uint64 idByName(const char *); /** int32 conversion to a string (name of database). WARNING: if name is already allocated, a size of at least 17 is required. The conversion is done by directly calculating the name from a number. To calculate the name of a certain level, - the mechanism is that the name is given by (#of nodes in that + the mechanism is that the name is given by (\# of nodes in that level) + (id of node). So for example, for the first level, there are 8 nodes, and we get the names from numbers 8 through 15 giving S0,S1,S2,S3,N0,N1,N2,N3. The order is always ascending starting from S0000.. to N3333... */ static char *nameById(uint64 ID, char *name = nullptr); /** find the vector to the centroid of a triangle represented by the ID */ void pointById(SpatialVector &vector, uint64 ID) const; /** find a node by giving a vector. The ID of the node is returned. */ uint64 idByPoint(const SpatialVector &vector) const; /// return the actual vertex vectors void nodeVertex(const uint64 id, SpatialVector &v1, SpatialVector &v2, SpatialVector &v3) const; private: // STRUCTURES struct Layer { size_t level_; // layer level size_t nVert_; // number of vertices in this layer size_t nNode_; // number of nodes size_t nEdge_; // number of edges uint64 firstIndex_; // index of first node of this layer size_t firstVertex_; // index of first vertex of this layer }; struct QuadNode { uint64 index_; // its own index size_t v_[3]; // The three vertex vector indices size_t w_[3]; // The three middlepoint vector indices uint64 childID_[4]; // ids of children uint64 parent_; // id of the parent node (needed for sorting) uint64 id_; // numeric id -> name }; // FUNCTIONS // insert a new node_[] into the list. The vertex indices are given by // v1,v2,v3 and the id of the node is set. uint64 newNode(size_t v1, size_t v2, size_t v3, uint64 id, uint64 parent); // make new nodes in a new layer. void makeNewLayer(size_t oldlayer); // return the total number of nodes and vertices void vMax(size_t *nodes, size_t *vertices); // sort the index so that the leaf nodes are at the beginning void sortIndex(); // Test whether a vector v is inside a triangle v0,v1,v2. Input // triangle has to be sorted in a counter-clockwise direction. bool isInside(const SpatialVector &v, const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2) const; // VARIABLES size_t maxlevel_; // the depth of the Layer size_t buildlevel_; // the depth of the Layer stored uint64 leaves_; // number of leaf nodes uint64 storedleaves_; // number of stored leaf nodes std::vector nodes_; // the array of nodes std::vector layers_; // array of layers std::vector vertices_; uint64 index_; // the current index_ of vertices friend class SpatialEdge; friend class SpatialConvex; friend class RangeConvex; }; #endif diff --git a/kstars/indi/clientmanagerlite.h b/kstars/indi/clientmanagerlite.h index 8db49248a..fd14c04cb 100644 --- a/kstars/indi/clientmanagerlite.h +++ b/kstars/indi/clientmanagerlite.h @@ -1,261 +1,263 @@ /** ************************************************************************* clientmanagerlite.h - K Desktop Planetarium ------------------- begin : 10/07/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "baseclientqt.h" #include "indicommon.h" #include "indistd.h" #include #include #include #include class QFileDialog; class QQmlContext; using namespace INDI; class TelescopeLite; struct DeviceInfoLite { explicit DeviceInfoLite(INDI::BaseDevice *dev); ~DeviceInfoLite(); INDI::BaseDevice *device { nullptr }; /// Motion control std::unique_ptr telescope; }; /** * @class ClientManagerLite * * @author Artem Fedoskin * @version 1.0 */ class ClientManagerLite : public INDI::BaseClientQt { Q_OBJECT Q_PROPERTY(QString connectedHost READ connectedHost WRITE setConnectedHost NOTIFY connectedHostChanged) Q_PROPERTY(bool connected READ isConnected WRITE setConnected NOTIFY connectedChanged) /** * A wrapper for Options::lastServer(). Used to store last used server if user successfully * connected to some server at least once. **/ Q_PROPERTY(QString lastUsedServer READ getLastUsedServer WRITE setLastUsedServer NOTIFY lastUsedServerChanged) /** * A wrapper for Options::lastServer(). Used to store last used port if user successfully * connected to some server at least once. **/ Q_PROPERTY(int lastUsedPort READ getLastUsedPort WRITE setLastUsedPort NOTIFY lastUsedPortChanged) /** * A wrapper for Options::lastServer(). Used to store last Web Manager used port if user successfully * connected at least once. **/ Q_PROPERTY(int lastUsedWebManagerPort READ getLastUsedWebManagerPort WRITE setLastUsedWebManagerPort NOTIFY lastUsedWebManagerPortChanged) public: typedef enum { UPLOAD_CLIENT, UPLOAD_LOCAL, UPLOAD_BOTH } UploadMode; explicit ClientManagerLite(QQmlContext& main_context); virtual ~ClientManagerLite(); Q_INVOKABLE bool setHost(const QString &ip, unsigned int port); Q_INVOKABLE void disconnectHost(); /** * Get the profiles from Web Manager * * @param ip IP address * @param port Port number * * The process is async and the results are stored in @a webMProfiles. Once this * request finishes, the server status is queried from the server. */ Q_INVOKABLE void getWebManagerProfiles(const QString &ip, unsigned int port); /** * Start an INDI server with a Web Manager profile * * @param profile Profile name */ Q_INVOKABLE void startWebManagerProfile(const QString &profile); /** Stop the INDI server with an active Web Manager profile */ Q_INVOKABLE void stopWebManagerProfile(); /** Handle the errors of the async Web Manager requests */ Q_INVOKABLE void webManagerReplyError(QNetworkReply::NetworkError code); /** Do actions when async Web Manager requests are finished */ Q_INVOKABLE void webManagerReplyFinished(); Q_INVOKABLE TelescopeLite *getTelescope(); QString connectedHost() { return m_connectedHost; } void setConnectedHost(const QString &connectedHost); void setConnected(bool connected); /** * Set the INDI Control Page * * @param page Reference to the QML page */ void setIndiControlPage(QObject &page) { indiControlPage = &page; }; /** * @brief syncLED + * @param device device name + * @param property property name * @param name of Light which LED needs to be synced * @return color of state */ Q_INVOKABLE QString syncLED(const QString &device, const QString &property, const QString &name = ""); void buildTextGUI(INDI::Property *property); void buildNumberGUI(INDI::Property *property); void buildMenuGUI(INDI::Property *property); void buildSwitchGUI(INDI::Property *property, PGui guiType); void buildSwitch(bool buttonGroup, ISwitch *sw, INDI::Property *property, bool exclusive = false, PGui guiType = PG_BUTTONS); void buildLightGUI(INDI::Property *property); //void buildBLOBGUI(INDI::Property *property); Q_INVOKABLE void sendNewINDISwitch(const QString &deviceName, const QString &propName, const QString &name); Q_INVOKABLE void sendNewINDISwitch(const QString &deviceName, const QString &propName, int index); Q_INVOKABLE void sendNewINDINumber(const QString &deviceName, const QString &propName, const QString &numberName, double value); Q_INVOKABLE void sendNewINDIText(const QString &deviceName, const QString &propName, const QString &fieldName, const QString &text); bool isConnected() { return m_connected; } Q_INVOKABLE bool isDeviceConnected(const QString &deviceName); QList getDevices() { return m_devices; } Q_INVOKABLE QString getLastUsedServer(); Q_INVOKABLE void setLastUsedServer(const QString &server); Q_INVOKABLE int getLastUsedPort(); Q_INVOKABLE void setLastUsedPort(int port); Q_INVOKABLE int getLastUsedWebManagerPort(); Q_INVOKABLE void setLastUsedWebManagerPort(int port); /** * @brief saveDisplayImage * @return true if image was saved false otherwise */ Q_INVOKABLE bool saveDisplayImage(); void clearDevices(); private slots: void connectNewDevice(const QString& device_name); protected: virtual void newDevice(INDI::BaseDevice *dp); virtual void removeDevice(INDI::BaseDevice *dp); virtual void newProperty(INDI::Property *property); virtual void removeProperty(INDI::Property *property); virtual void newBLOB(IBLOB *bp); virtual void newSwitch(ISwitchVectorProperty *svp); virtual void newNumber(INumberVectorProperty *nvp); virtual void newMessage(INDI::BaseDevice *dp, int messageID); virtual void newText(ITextVectorProperty *tvp); virtual void newLight(ILightVectorProperty *lvp); virtual void serverConnected() {} virtual void serverDisconnected(int exit_code); signals: //Device void newINDIDevice(QString deviceName); void removeINDIDevice(QString deviceName); void deviceConnected(QString deviceName, bool isConnected); void newINDIProperty(QString deviceName, QString propName, QString groupName, QString type, QString label); void createINDIText(QString deviceName, QString propName, QString propLabel, QString fieldName, QString propText, bool read, bool write); void createINDINumber(QString deviceName, QString propName, QString propLabel, QString numberName, QString propText, bool read, bool write, bool scale); void createINDIButton(QString deviceName, QString propName, QString propText, QString switchName, bool read, bool write, bool exclusive, bool checked, bool checkable); void createINDIRadio(QString deviceName, QString propName, QString propText, QString switchName, bool read, bool write, bool exclusive, bool checked, bool enabled); void createINDIMenu(QString deviceName, QString propName, QString switchLabel, QString switchName, bool isSelected); void createINDILight(QString deviceName, QString propName, QString label, QString lightName); void removeINDIProperty(QString deviceName, QString groupName, QString propName); //Update signals void newINDISwitch(QString deviceName, QString propName, QString switchName, bool isOn); void newINDINumber(QString deviceName, QString propName, QString numberName, QString value); void newINDIText(QString deviceName, QString propName, QString fieldName, QString text); void newINDIMessage(QString message); void newINDILight(QString deviceName, QString propName); void newINDIBLOBImage(QString deviceName, bool isLoaded); void newLEDState(QString deviceName, QString propName); // to sync LED for properties void connectedHostChanged(QString); void connectedChanged(bool); void telescopeAdded(TelescopeLite *newTelescope); void telescopeRemoved(TelescopeLite *delTelescope); void telescopeConnected(TelescopeLite *telescope); void telescopeDisconnected(); void lastUsedServerChanged(); void lastUsedPortChanged(); void lastUsedWebManagerPortChanged(); private: bool processBLOBasCCD(IBLOB *bp); /// Qml context QQmlContext& context; QList m_devices; QString m_connectedHost; bool m_connected { false }; char BLOBFilename[MAXINDIFILENAME]; QImage displayImage; /// INDI Control Page QObject* indiControlPage; /// Manager for the JSON requests to the Web Manager QNetworkAccessManager manager; /// Network reply for querying profiles from the Web Manager std::unique_ptr webMProfilesReply; /// Network reply for Web Manager status std::unique_ptr webMStatusReply; /// Network reply to stop the active profile in the Web Manager std::unique_ptr webMStopProfileReply; /// Network reply to start a profile in the Web Manager std::unique_ptr webMStartProfileReply; /// Web Manager profiles QStringList webMProfiles; TelescopeLite *m_telescope { nullptr }; #ifdef ANDROID QString defaultImageType; QString defaultImagesLocation; #endif }; diff --git a/kstars/kstarslite/dialogs/detaildialoglite.h b/kstars/kstarslite/dialogs/detaildialoglite.h index 829552f44..a484a3beb 100644 --- a/kstars/kstarslite/dialogs/detaildialoglite.h +++ b/kstars/kstarslite/dialogs/detaildialoglite.h @@ -1,265 +1,267 @@ /*************************************************************************** detaildialoglite.h - K Desktop Planetarium ------------------- begin : Aug Jul 13 2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include #include /** * @class DetalDialogLite * @short Backend for Object details dialog in QML * A backend of details dialog declared in QML. Members of this class are the properties that are used * in QML. Whenever user clicks on some object the properties are updated with the info about this object * and Details dialog in QML is updated automatically as we use property binding there. * * @author Artem Fedoskin, Jason Harris, Jasem Mutlaq * @version 1.0 */ class DetailDialogLite : public QObject { Q_OBJECT //General Q_PROPERTY(QString name MEMBER m_name NOTIFY nameChanged) Q_PROPERTY(QString magnitude MEMBER m_magnitude NOTIFY magnitudeChanged) Q_PROPERTY(QString distance MEMBER m_distance NOTIFY distanceChanged) Q_PROPERTY(QString BVindex MEMBER m_BVindex NOTIFY BVindexChanged) Q_PROPERTY(QString angSize MEMBER m_angSize NOTIFY angSizeChanged) Q_PROPERTY(QString illumination MEMBER m_illumination NOTIFY illuminationChanged) Q_PROPERTY(QString typeInConstellation MEMBER m_typeInConstellation NOTIFY typeInConstellationChanged) Q_PROPERTY(QString thumbnail MEMBER m_thumbnail NOTIFY thumbnailChanged) //General advanced Q_PROPERTY(QString perihelion MEMBER m_perihelion NOTIFY perihelionChanged) Q_PROPERTY(QString orbitID MEMBER m_orbitID NOTIFY orbitIDChanged) Q_PROPERTY(QString NEO MEMBER m_NEO NOTIFY NEOChanged) Q_PROPERTY(QString diameter MEMBER m_diameter NOTIFY diameterChanged) Q_PROPERTY(QString rotation MEMBER m_rotation NOTIFY rotationChanged) Q_PROPERTY(QString earthMOID MEMBER m_earthMOID NOTIFY earthMOIDChanged) Q_PROPERTY(QString orbitClass MEMBER m_orbitClass NOTIFY orbitClassChanged) Q_PROPERTY(QString albedo MEMBER m_albedo NOTIFY albedoChanged) Q_PROPERTY(QString dimensions MEMBER m_dimensions NOTIFY dimensionsChanged) Q_PROPERTY(QString period MEMBER m_period NOTIFY periodChanged) //Position Q_PROPERTY(QString decLabel MEMBER m_decLabel NOTIFY decLabelChanged) Q_PROPERTY(QString dec MEMBER m_dec NOTIFY decChanged) Q_PROPERTY(QString RALabel MEMBER m_RALabel NOTIFY RALabelChanged) Q_PROPERTY(QString RA MEMBER m_RA NOTIFY RAChanged) Q_PROPERTY(QString az MEMBER m_az NOTIFY azChanged) Q_PROPERTY(QString airmass MEMBER m_airmass NOTIFY airmassChanged) Q_PROPERTY(QString HA MEMBER m_HA NOTIFY HAChanged) Q_PROPERTY(QString alt MEMBER m_alt NOTIFY altChanged) Q_PROPERTY(QString RA0 MEMBER m_RA0 NOTIFY RA0Changed) Q_PROPERTY(QString dec0 MEMBER m_dec0 NOTIFY dec0Changed) Q_PROPERTY(QString timeRise MEMBER m_timeRise NOTIFY timeRiseChanged) Q_PROPERTY(QString timeTransit MEMBER m_timeTransit NOTIFY timeTransitChanged) Q_PROPERTY(QString timeSet MEMBER m_timeSet NOTIFY timeSetChanged) Q_PROPERTY(QString azRise MEMBER m_azRise NOTIFY azRiseChanged) Q_PROPERTY(QString altTransit MEMBER m_altTransit NOTIFY altTransitChanged) Q_PROPERTY(QString azSet MEMBER m_azSet NOTIFY azSetChanged) //Links Q_PROPERTY(QStringList infoTitleList MEMBER m_infoTitleList NOTIFY infoTitleListChanged) Q_PROPERTY(QStringList imageTitleList MEMBER m_imageTitleList NOTIFY imageTitleListChanged) Q_PROPERTY(bool isLinksOn MEMBER m_isLinksOn NOTIFY isLinksOnChanged) //Log Q_PROPERTY(bool isLogOn MEMBER m_isLogOn NOTIFY isLogOnChanged) Q_PROPERTY(QString userLog MEMBER m_userLog NOTIFY userLogChanged) public: DetailDialogLite(); /** Connect SkyMapLite's signals to proper slots */ void initialize(); /** Set thumbnail to SkyMapLite::clickedObjectLite's thumbnail (if any) */ void setupThumbnail(); /** * @brief addLink adds new link to SkyObject + * @param url URL of the link + * @param desc description of the link * @param isImageLink true if it is a link to image. False if it is information link */ Q_INVOKABLE void addLink(const QString &url, const QString &desc, bool isImageLink); /** * @short Remove link from user's database * @param itemIndex - index of a link * @param isImage - true if it is a link on image, false if it is an info link */ Q_INVOKABLE void removeLink(int itemIndex, bool isImage); /** * @short Edit link's description and URL * @param itemIndex - index of a link * @param isImage - true if it is a link on image, false if it is an info link * @param desc - new description * @param url - new URL */ void editLink(int itemIndex, bool isImage, const QString &desc, const QString &url); /** * Update the local info_url and image_url files * @param type The URL type. 0 for Info Links, 1 for Images. * @param search_line The line to be search for in the local URL files * @param replace_line The replacement line once search_line is found. * @note If replace_line is empty, the function will remove search_line from the file */ void updateLocalDatabase(int type, const QString &search_line, const QString &replace_line = QString()); //We don't need bindings to URLs so let's just have getters /** * @param index - URL's index in SkyObject::ImageList() * @return URL to user added information about object */ Q_INVOKABLE QString getInfoURL(int index); /** * @param index - URL's index in SkyObject::ImageList() * @return URL to user added object image */ Q_INVOKABLE QString getImageURL(int index); public slots: /** Update properties that are shown on "General" tab */ void createGeneralTab(); /** Update properties that are shown on "Position" tab */ void createPositionTab(); /** Update properties that are shown on "Log" tab */ void createLogTab(); /** Update properties that are shown on "Links" tab */ void createLinksTab(); /** Save the User's text in the Log Tab to the userlog.dat file. */ void saveLogData(const QString &userLog); signals: //General void nameChanged(QString); void magnitudeChanged(QString); void distanceChanged(QString); void BVindexChanged(QString); void angSizeChanged(QString); void illuminationChanged(QString); void typeInConstellationChanged(QString); void thumbnailChanged(QString); //General advanced void perihelionChanged(QString); void orbitIDChanged(QString); void NEOChanged(QString); void diameterChanged(QString); void rotationChanged(QString); void earthMOIDChanged(QString); void orbitClassChanged(QString); void albedoChanged(QString); void dimensionsChanged(QString); void periodChanged(QString); //Position void decLabelChanged(); void decChanged(); void RALabelChanged(); void RAChanged(); void azChanged(); void airmassChanged(); void HAChanged(); void altChanged(); void RA0Changed(); void dec0Changed(); void timeRiseChanged(); void timeTransitChanged(); void timeSetChanged(); void azRiseChanged(); void altTransitChanged(); void azSetChanged(); //Links void infoTitleListChanged(); void imageTitleListChanged(); void isLinksOnChanged(); //Log void isLogOnChanged(); void userLogChanged(); private: //General QString m_name; QString m_magnitude; QString m_distance; QString m_BVindex; QString m_angSize; QString m_illumination; QString m_typeInConstellation; QString m_thumbnail; //General advanced QString m_perihelion; QString m_orbitID; QString m_NEO; QString m_diameter; QString m_rotation; QString m_earthMOID; QString m_orbitClass; QString m_albedo; QString m_dimensions; QString m_period; //Position QString m_decLabel; QString m_dec; QString m_RALabel; QString m_RA; QString m_az; QString m_airmass; QString m_HA; QString m_alt; QString m_RA0; QString m_dec0; QString m_timeRise; QString m_timeTransit; QString m_timeSet; QString m_azRise; QString m_altTransit; QString m_azSet; //Links bool m_isLinksOn { false }; QStringList m_infoTitleList; QStringList m_imageTitleList; //Log bool m_isLogOn { false }; QString m_userLog; }; diff --git a/kstars/kstarslite/skyitems/skynodes/crosshairnode.h b/kstars/kstarslite/skyitems/skynodes/crosshairnode.h index a41e148ae..0318a3e4c 100644 --- a/kstars/kstarslite/skyitems/skynodes/crosshairnode.h +++ b/kstars/kstarslite/skyitems/skynodes/crosshairnode.h @@ -1,65 +1,66 @@ /** ************************************************************************* crosshairnode.h - K Desktop Planetarium ------------------- begin : 18/07/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef CROSSHAIRNODE_H_ #define CROSSHAIRNODE_H_ #include "skynode.h" /** @class CrossHairNode * * @short Represents crosshair of telescope in SkyMapLite * @version 1.0 */ class EllipseNode; class LineNode; class LabelNode; class QSGFlatColorMaterial; class CrosshairNode : public SkyNode { public: /** * @short Constructor. Initializes lines, ellipses and labels. * @param baseDevice - pointer to telescope + * @param rootNode parent RootNode that instantiated this object */ CrosshairNode(INDI::BaseDevice *baseDevice, RootNode *rootNode); /** Destructor. **/ ~CrosshairNode(); /** @short Update position and visibility of crosshair based on the Alt, Az (or Ra and Dec) of telescope **/ virtual void update() override; virtual void hide() override; /** @short Set color of crosshair **/ void setColor(QColor color); private: EllipseNode *el1; EllipseNode *el2; QSGGeometryNode *lines; QSGFlatColorMaterial *material; LabelNode *label; LabelsItem *labelsItem; INDI::BaseDevice *bd; }; #endif diff --git a/kstars/kstarslite/skyitems/skynodes/deepskynode.h b/kstars/kstarslite/skyitems/skynodes/deepskynode.h index 9960fd328..833d727c9 100644 --- a/kstars/kstarslite/skyitems/skynodes/deepskynode.h +++ b/kstars/kstarslite/skyitems/skynodes/deepskynode.h @@ -1,99 +1,101 @@ /** ************************************************************************* deepskynode.h - K Desktop Planetarium ------------------- begin : 18/06/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "skynode.h" #include "../labelsitem.h" class PlanetItemNode; class SkyMapLite; class PointNode; class LabelNode; class QSGSimpleTextureNode; class DSOSymbolNode; /** * @class DeepSkyNode * * @short A SkyNode derived class used for displaying DeepSkyObjects. * * Keep in mind that DSO symbol is handled by DSOSymbolNode that has different parent from this node * but DeepSkyNode calls update routines of DSOSymbolNode. * @author Artem Fedoskin * @version 1.0 */ class RootNode; class DeepSkyObject; class DeepSkyNode : public SkyNode { public: /** * @short Constructor. * @param skyObject - DSOs that is represented by this node * @param symbol - DSOSymbolNode of this DSO + * @param labelType - type of label * @param trixel - trixelID, with which this node is indexed */ DeepSkyNode(DeepSkyObject *skyObject, DSOSymbolNode *symbol, LabelsItem::label_t labelType, short trixel = -1); /** @short Destructor. Call delete routines of label */ virtual ~DeepSkyNode(); /** * @short changePos changes the position of this node and rotate it according to m_angle * @param pos new position */ virtual void changePos(QPointF pos) override; /** * @short Update position and visibility of this node * @param drawImage - true if image (if exists) should be drawn * @param drawLabel - true if label should be drawn * @param pos - new position of the object. If default parameter is passed, the visibility and * position of node is calculated. * There is one case when we pass this parameter - in DeepSkyItem::updateDeepSkyNode() when * we check whether DeepSkyObject is visible or no and instantiate it accordingly. There is no * need to calculate the position again and we pass it as a parameter. */ void update(bool drawImage, bool drawLabel, QPointF pos = QPointF(-1, -1)); virtual void hide() override; /** * @short sets color of DSO symbol and label * To not increase the code for symbols we just recreate the symbol painted with desired color + * @param color the color to be set * @param symbolTrixel the TrixelNode to which symbol node should be appended */ void setColor(QColor color, TrixelNode *symbolTrixel); DeepSkyObject *dsObject() { return m_dso; } DSOSymbolNode *symbol() { return m_symbol; } private: QSGSimpleTextureNode *m_objImg { nullptr }; /// Trixel to which this object belongs. Used only in stars. By default -1 for all Trixel m_trixel { 0 }; LabelNode *m_label { nullptr }; LabelsItem::label_t m_labelType { LabelsItem::NO_LABEL }; DeepSkyObject *m_dso { nullptr }; DSOSymbolNode *m_symbol { nullptr }; float m_angle { 0 }; QPointF pos; }; diff --git a/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h b/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h index 26dede8dc..3e95c1b28 100644 --- a/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h +++ b/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h @@ -1,144 +1,151 @@ /*************************************************************************** fovsymbolnode.h - K Desktop Planetarium ------------------- begin : 20/08/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "../fovitem.h" #include #include class EllipseNode; class RectNode; /** * @class FOVSymbolBase * * FOVSymbolBase is a virtual class that should be subclassed by every type of FOV symbol. It is derived * from QSGTransformNode to provide transform matrix for updating coordinates of FOV symbol. * * @short A QSGTransformNode derived base class of every type of FOV symbol * @author Artem Fedoskin * @version 1.0 */ class FOVSymbolBase : public QSGTransformNode { public: /** @short updates geometry (position, size) of elements of this FOV symbol */ virtual void updateSymbol(QColor color, float pixelSizeX, float pixelSizeY) = 0; /** @short return type of this FOV symbol **/ FOVItem::Shape type() { return m_shape; } protected: /** @param shape of the symbol. Each subclass sets its own type. Returned in type() */ FOVSymbolBase(FOVItem::Shape shape); /* QImage m_image; //Not supported yet bool m_imageDisplay;*/ FOVItem::Shape m_shape; }; class SquareFOV : public FOVSymbolBase { public: SquareFOV(); virtual void updateSymbol(QColor color, float pixelSizeX, float pixelSizeY); private: RectNode *rect1 { nullptr }; RectNode *rect2 { nullptr }; QSGGeometryNode *lines { nullptr }; }; class CircleFOV : public FOVSymbolBase { public: CircleFOV(); virtual void updateSymbol(QColor color, float pixelSizeX, float pixelSizeY); private: EllipseNode *el { nullptr }; }; class CrosshairFOV : public FOVSymbolBase { public: CrosshairFOV(); virtual void updateSymbol(QColor color, float pixelSizeX, float pixelSizeY); private: QSGGeometryNode *lines { nullptr }; EllipseNode *el1 { nullptr }; EllipseNode *el2 { nullptr }; }; class BullsEyeFOV : public FOVSymbolBase { public: BullsEyeFOV(); virtual void updateSymbol(QColor color, float pixelSizeX, float pixelSizeY); private: EllipseNode *el1 { nullptr }; EllipseNode *el2 { nullptr }; EllipseNode *el3 { nullptr }; }; class SolidCircleFOV : public FOVSymbolBase { public: SolidCircleFOV(); virtual void updateSymbol(QColor color, float pixelSizeX, float pixelSizeY); private: EllipseNode *el { nullptr }; }; /** * @class FOVSymbolNode * * A SkyNode derived class used for displaying FOV symbol. FOVSymbolNade handles creation of FOVSymbolBase * and its update. * * @short A SkyNode derived class that is used for displaying FOV symbol * @author Artem Fedoskin * @version 1.0 */ class FOVSymbolNode : public SkyNode { public: /** * @short Constructor. Initialize m_symbol according to shape * @param name - name of the FOV symbol (used to switch it on/off through SkyMapLite from QML) + * @param a - width + * @param b - height + * @param xoffset - x offset + * @param yoffset - y offset + * @param rot - rotation + * @param shape - shape + * @param color - RGB color */ FOVSymbolNode(const QString &name, float a, float b, float xoffset, float yoffset, float rot, FOVItem::Shape shape = FOVItem::SQUARE, const QString &color = "#FFFFFF"); /** @short Update this FOV symbol according to the zoomFactor */ void update(float zoomFactor); QString getName() { return m_name; } private: QString m_name; QString m_color; float m_sizeX { 0 }; float m_sizeY { 0 }; float m_offsetX { 0 }; float m_offsetY { 0 }; float m_rotation { 0 }; float m_northPA { 0 }; SkyPoint m_center; FOVSymbolBase *m_symbol { nullptr }; }; diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h index de208923e..c955c30aa 100644 --- a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h +++ b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.h @@ -1,54 +1,58 @@ /** ************************************************************************* polynode.h - K Desktop Planetarium ------------------- begin : 22/06/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include #include class QSGFlatColorMaterial; class QSGGeometry; class QSGGeometryNode; /** * @class EllipseNode * @short QSGTransformNode derived node used to draw ellipses * * @author Artem Fedoskin * @version 1.0 */ class EllipseNode : public QSGTransformNode { public: explicit EllipseNode(const QColor &color = QColor(), int width = 1); void setColor(QColor color); void setLineWidth(int width); /** * @short Redraw ellipse with the given width, height and positions (x,y) + * @param x position by x + * @param y position by y + * @param width the width + * @param height the height * @param filled - if true the ellipse will be filled with color */ void updateGeometry(float x, float y, int width, int height, bool filled); private: QSGGeometryNode *m_geometryNode { nullptr }; QSGGeometry *m_geometry { nullptr }; QSGFlatColorMaterial *m_material { nullptr }; int m_width { -1 }; int m_height { -1 }; float m_x { -1 }; float m_y { -1 }; }; diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h index c6e381603..329c6e3c7 100644 --- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h +++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.h @@ -1,73 +1,75 @@ /** ************************************************************************* linenode.h - K Desktop Planetarium ------------------- begin : 05/06/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "linelist.h" #include "../../skyopacitynode.h" #include #include class QSGFlatColorMaterial; class SkyMapLite; class SkipHashList; /** * @class LineNode * * @short SkyOpacityNode derived class that draws lines from LineList * * @author Artem Fedoskin * @version 1.0 */ class LineNode : public SkyOpacityNode { public: /** * @short Constructor * @param lineList - lines that have to be drawn * @param skipList - lines that have to be skipped + * @param color - line color + * @param width - line width * @param drawStyle - not used currently */ LineNode(LineList *lineList, SkipHashList *skipList, QColor color, int width, Qt::PenStyle drawStyle); virtual ~LineNode(); void setColor(QColor color); void setWidth(int width); void setDrawStyle(Qt::PenStyle drawStyle); void setStyle(QColor color, int width, Qt::PenStyle drawStyle); /** * @short Update lines based on the visibility of line segments in m_lineList */ void updateGeometry(); inline LineList *lineList() { return m_lineList; } private: QSGGeometryNode *m_geometryNode { nullptr }; LineList *m_lineList { nullptr }; SkipHashList *m_skipList { nullptr }; QSGGeometry *m_geometry { nullptr }; QSGFlatColorMaterial *m_material { nullptr }; Qt::PenStyle m_drawStyle; QColor m_color; }; diff --git a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h index 8fd3a4715..38c82f4a7 100644 --- a/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h +++ b/kstars/kstarslite/skyitems/skynodes/pointsourcenode.h @@ -1,101 +1,102 @@ /** ************************************************************************* pointsourcenode.h - K Desktop Planetarium ------------------- begin : 16/05/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "skynode.h" #include "../labelsitem.h" class LabelNode; class PlanetItemNode; class PointNode; class RootNode; class SkyMapLite; /** * @class PointSourceNode * * A SkyNode derived class used for displaying PointNode with coordinates provided by SkyObject. * * @short A SkyNode derived class that represents stars and objects that are drawn as stars * @author Artem Fedoskin * @version 1.0 */ class PointSourceNode : public SkyNode { public: /** * @short Constructor * @param skyObject pointer to SkyObject that has to be displayed on SkyMapLite * @param parentNode pointer to the top parent node, which holds texture cache * @param spType spectral class of PointNode * @param size initial size of PointNode + * @param trixel trixelID, with which this node is indexed */ PointSourceNode(SkyObject *skyObject, RootNode *parentNode, LabelsItem::label_t labelType = LabelsItem::label_t::STAR_LABEL, char spType = 'A', float size = 1, short trixel = -1); virtual ~PointSourceNode(); /** @short Get the width of a star of magnitude mag */ float starWidth(float mag) const; /** * @short updatePoint initializes PointNode if not done that yet. Makes it visible and updates * its size. * By using this function we can save some memory because m_point is created only when this * PointSourceNode becomes visible. */ void updatePoint(); /** * @short changePos changes the position m_point * @param pos new position */ virtual void changePos(QPointF pos) override; /** * @short updatePos updates position of this node and its label. Initializes label if needed * The reason behind this function is that in StarItem we are already checking the visibility of star * to decide whether we need to create this node or no. So to avoid calculating the same thing twice * we set position of object directly. Also through this function StarItem sets the visibility of label * @param pos position of this node on SkyMapLite * @param drawLabel true if label has to be drawn */ void updatePos(QPointF pos, bool drawLabel); /** @short update updates coordinates of this node based on the visibility of its SkyObject */ virtual void update() override; /** * @short hides this node and its label. m_point is hided without explicitly doing this because * it is a child node of m_opacity inherited from SkyNode */ virtual void hide() override; private: PointNode *m_point { nullptr }; RootNode *m_rootNode { nullptr }; LabelNode *m_label { nullptr }; char m_spType { 0 }; float m_size { 0 }; LabelsItem::label_t m_labelType { LabelsItem::NO_LABEL }; /** * Trixel to which this object belongs. Used only in stars. By default -1 for * all other objects that are not indexed by SkyMesh */ short m_trixel { 0 }; QPointF pos; }; diff --git a/kstars/kstarslite/skyitems/staritem.h b/kstars/kstarslite/skyitems/staritem.h index 58b3d46c4..bdeba02a5 100644 --- a/kstars/kstarslite/skyitems/staritem.h +++ b/kstars/kstarslite/skyitems/staritem.h @@ -1,58 +1,59 @@ /** ************************************************************************* staritem.h - K Desktop Planetarium ------------------- begin : 15/06/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "skyitem.h" class SkyMesh; class SkyOpacityNode; class StarBlockFactory; class StarComponent; /** * @class StarItem * * @short Class that handles Stars * @author Artem Fedoskin * @version 1.0 */ class StarItem : public SkyItem { public: /** * @short Constructor. + * @param starComp star component * @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() */ virtual void update(); private: StarComponent *m_starComp { nullptr }; SkyMesh *m_skyMesh { nullptr }; StarBlockFactory *m_StarBlockFactory { nullptr }; SkyOpacityNode *m_stars { nullptr }; SkyOpacityNode *m_deepStars { nullptr }; SkyOpacityNode *m_starLabels { nullptr }; }; diff --git a/kstars/oal/execute.h b/kstars/oal/execute.h index 50953d615..c6d279843 100644 --- a/kstars/oal/execute.h +++ b/kstars/oal/execute.h @@ -1,137 +1,138 @@ /*************************************************************************** execute.h - description ------------------- begin : Friday July 21, 2009 copyright : (C) 2009 by Prakash Mohan email : prakash.mohan*@kdemail.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "ui_execute.h" #include "oal/oal.h" #include "oal/session.h" #include "skyobjects/skyobject.h" #include class GeoLocation; class SkyObject; /** * @class Execute * * Executes an observation session. */ class Execute : public QDialog { Q_OBJECT public: /** @short Default constructor */ Execute(); /** * @short This initializes the combo boxes, and sets up the * dateTime and geolocation from the OL */ void init(); public slots: /** * @short Function to handle the UI when the 'next' button is pressed * This calls the corresponding functions based on the currentIndex */ void slotNext(); /** Function to Save the session details */ bool saveSession(); /** * @short Function to save the user notes set for the current object in the target combo box */ void addTargetNotes(); void slotObserverAdd(); /** @short Function to add the current observation to the observation list */ bool addObservation(); /** * @short Function to handle the state of current observation, and hiding the execute window */ void slotEndSession(); /** @short Opens the location dialog for setting the current location */ void slotLocation(); /** @short Loads the sessionlist from the OL into the target combo box */ void loadTargets(); /** @short Sorts the target list using the scheduled time */ void sortTargetList(); /** * @short set the currentTarget when the user selection is changed in the target combo box */ void slotSetTarget(const QString &name); /** @short loads the equipment list from the global logObject into the comboBoxes */ void loadEquipment(); /** @short loads the observer list from the global logObject into the comboBoxes */ void loadObservers(); /** @short loads the observation edit page */ void loadObservationTab(); /** * @short get object name. If star has no name, generate a name based on catalog number. + * @param o sky object * @param translated set to true if the translated name is required. */ QString getObjectName(const SkyObject *o, bool translated = true); void selectNextTarget(); void loadCurrentItems(); void slotSetCurrentObjects(); void slotSlew(); void slotShowSession(); void slotShowTargets(); int findIndexOfTarget(QString); void slotAddObject(); void slotRemoveObject(); private: Ui::Execute ui; OAL::Session *currentSession { nullptr }; OAL::Log *logObject { nullptr }; OAL::Observer *currentObserver { nullptr }; OAL::Scope *currentScope { nullptr }; OAL::Eyepiece *currentEyepiece { nullptr }; OAL::Lens *currentLens { nullptr }; OAL::Filter *currentFilter { nullptr }; GeoLocation *geo { nullptr }; SkyObject *currentTarget { nullptr }; int nextSession { 0 }; int nextObservation { 0 }; int nextSite { 0 }; }; diff --git a/kstars/skycomponents/flagcomponent.h b/kstars/skycomponents/flagcomponent.h index d7b61ad37..912dfe214 100644 --- a/kstars/skycomponents/flagcomponent.h +++ b/kstars/skycomponents/flagcomponent.h @@ -1,185 +1,186 @@ /*************************************************************************** flagcomponent.h - K Desktop Planetarium ------------------- begin : Fri 16 Jan 2009 copyright : (C) 2009 by Jerome SONRIER email : jsid@emor3j.fr.eu.org ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "pointlistcomponent.h" #include #include #include #include class SkyPainter; /** * @class FlagComponent * @short Represents a flag on the sky map. * Each flag is composed by a SkyPoint where coordinates are stored, an * epoch and a label. This class also stores flag images and associates * each flag with an image. * When FlagComponent is created, it seeks all file names beginning with * "_flag" in the user directory and *consider* them as flag images. * * The file flags.dat stores coordinates, epoch, image name and label of each * flags and is read to init FlagComponent * * @author Jerome SONRIER * @version 1.1 */ class FlagComponent : public QObject, public PointListComponent { Q_OBJECT public: /** @short Constructor. */ explicit FlagComponent(SkyComposite *); virtual ~FlagComponent() override = default; void draw(SkyPainter *skyp) override; bool selected() override; void update(KSNumbers *num = nullptr) override; /** * @short Add a flag. * @param flagPoint Sky point in epoch coordinates * @param epoch Moment for which celestial coordinates are specified * @param image Image name * @param label Label of the flag * @param labelColor Color of the label */ void add(const SkyPoint &flagPoint, QString epoch, QString image, QString label, QColor labelColor); /** * @short Remove a flag. * @param index Index of the flag to be remove. */ void remove(int index); /** * @short Update a flag. * @param index index of the flag to be updated. + * @param flagPoint point of the flag. * @param epoch new flag epoch. * @param image new flag image. * @param label new flag label. * @param labelColor new flag label color. */ void updateFlag(int index, const SkyPoint &flagPoint, QString epoch, QString image, QString label, QColor labelColor); /** * @short Return image names. * @return the list of all image names */ QStringList getNames(); /** * @short Return the numbers of flags. * @return the size of m_PointList */ int size(); /** * @short Get epoch. * @return the epoch as a string * @param index Index of the flag */ QString epoch(int index); /** * @short Get label. * @return the label as a string * @param index Index of the flag */ QString label(int index); /** * @short Get label color. * @return the label color * @param index Index of the flag */ QColor labelColor(int index); /** * @short Get image. * @return the image associated with the flag * @param index Index of the flag */ QImage image(int index); /** * @short Get image name. * @return the name of the image associated with the flag * @param index Index of the flag */ QString imageName(int index); /** * @short Get images. * @return all images that can be use */ QList imageList(); /** * @short Get image. * @param index Index of the image in m_Images * @return an image from m_Images */ QImage imageList(int index); /** * @brief epochCoords return coordinates recorded in original epoch * @param index index of the flag * @return pair of RA/DEC in original epoch */ QPair epochCoords(int index); /** * @short Get list of flag indexes near specified SkyPoint with radius specified in pixels. * @param point central SkyPoint. * @param pixelRadius radius in pixels. */ QList getFlagsNearPix(SkyPoint *point, int pixelRadius); /** @short Load flags from flags.dat file. */ void loadFromFile(); /** @short Save flags to flags.dat file. */ void saveToFile(); private: // Convert from given epoch to J2000. If epoch is already J2000, do nothing void toJ2000(SkyPoint *p, QString epoch); /// List of epochs QStringList m_Epoch; /// RA/DEC stored in original epoch QList> m_EpochCoords; /// List of image index QList m_FlagImages; /// List of label QStringList m_Labels; /// List of label colors QList m_LabelColors; /// List of image names QStringList m_Names; /// List of flag images QList m_Images; }; diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h index c319aaa1c..609c9457b 100644 --- a/kstars/skymaplite.h +++ b/kstars/skymaplite.h @@ -1,693 +1,694 @@ /** ************************************************************************* skymaplite.h - K Desktop Planetarium ------------------- begin : 30/04/2016 copyright : (C) 2016 by Artem Fedoskin email : afedoskin3@gmail.com ***************************************************************************/ /** ************************************************************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "skyobjects/skypoint.h" #include "skyobjects/skyline.h" #include #include #include #include #include #include #include "kstarsdata.h" #include "kstarslite/skyitems/rootnode.h" #include class DeviceOrientation; class dms; class KStarsData; class SkyObject; class Projector; class SolarSystemSingleComponent; class PlanetsItem; class AsteroidsItem; class CometsItem; class PlanetMoonsComponent; class HorizonItem; class LinesItem; class SkyNode; class RootNode; class TelescopeLite; class SkyObjectLite; class SkyPointLite; class QSGTexture; /** @class SkyMapLite * *This is the main item that displays all SkyItems. After its instantiation it is reparanted *to an object with objectName SkyMapLiteWrapper in main.qml. To display SkyItems they are reparanted *to instance of SkyMapLite. * *SkyMapLite handles most user interaction events (both mouse and keyboard). * *@short Item for displaying sky objects; also handles user interaction events. *@author Artem Fedoskin *@version 1.0 */ class SkyMapLite : public QQuickItem { Q_OBJECT /** magnitude limit. Used in QML **/ Q_PROPERTY(double magLim READ getMagLim WRITE setMagLim NOTIFY magLimChanged) /** wrappers for clickedPoint and clickedObject. Used to set clicked object and point from QML **/ Q_PROPERTY(SkyPointLite *clickedPointLite READ getClickedPointLite NOTIFY pointLiteChanged) Q_PROPERTY(SkyObjectLite *clickedObjectLite READ getClickedObjectLite NOTIFY objectLiteChanged) /** list of FOVSymbols that are currently available **/ Q_PROPERTY(QStringList FOVSymbols READ getFOVSymbols NOTIFY symbolsFOVChanged) /** true if SkyMapLite is being panned **/ Q_PROPERTY(bool slewing READ getSlewing WRITE setSlewing NOTIFY slewingChanged) /** * @short true if SkyMapLite is centered on an object and only pinch-to-zoom needs to be available **/ Q_PROPERTY(bool centerLocked READ getCenterLocked WRITE setCenterLocked NOTIFY centerLockedChanged) Q_PROPERTY(bool automaticMode READ getAutomaticMode WRITE setAutomaticMode NOTIFY automaticModeChanged) Q_PROPERTY(double skyRotation READ getSkyRotation WRITE setSkyRotation NOTIFY skyRotationChanged) enum class SkyMapOrientation { Top0, Right90, Bottom180, Left270 }; protected: SkyMapLite(); /** Updates SkyMapLite by calling RootNode::update(), which in turn initiates update of all child nodes. **/ virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData); public: /** Creates instance of SkyMapLite (delete the old one if any) **/ static SkyMapLite *createInstance(); /** Bind size to parent's size and initialize star images **/ void initialize(QQuickItem *parent); static SkyMapLite *Instance() { return pinstance; } static bool IsSlewing() { return pinstance->isSlewing(); } /** Destructor. Clear star images.*/ ~SkyMapLite(); /** * @short skyNode will be deleted on the next call to updatePaintNode (currently used only in * StarNode(struct in StarBlock)) */ void deleteSkyNode(SkyNode *skyNode); /** @short Update the focus position according to current options. */ void updateFocus(); /** @short Retrieve the Focus point; the position on the sky at the *center of the skymap. *@return a pointer to the central focus point of the sky map */ SkyPoint *focus() { return &Focus; } /** @short retrieve the Destination position. * *The Destination is the point on the sky to which the focus will be moved. *@return a pointer to the destination point of the sky map */ SkyPoint *destination() { return &Destination; } /** @short retrieve the FocusPoint position. * *The FocusPoint stores the position on the sky that is to be *focused next. This is not exactly the same as the Destination *point, because when the Destination is set, it will begin slewing *immediately. * *@return a pointer to the sky point which is to be focused next. */ SkyPoint *focusPoint() { return &FocusPoint; } /** @short sets the central focus point of the sky map. *@param f a pointer to the SkyPoint the map should be centered on */ void setFocus(SkyPoint *f); /** @short sets the focus point of the skymap, using ra/dec coordinates * *@note This function behaves essentially like the above function. *It differs only in the data types of its arguments. * *@param ra the new right ascension *@param dec the new declination */ void setFocus(const dms &ra, const dms &dec); /** @short sets the focus point of the sky map, using its alt/az coordinates *@param alt the new altitude *@param az the new azimuth */ void setFocusAltAz(const dms &alt, const dms &az); /** @short sets the destination point of the sky map. *@note setDestination() emits the destinationChanged() SIGNAL, *which triggers the SLOT function SkyMap::slewFocus(). This *function iteratively steps the Focus point toward Destination, *repainting the sky at each step (if Options::useAnimatedSlewing()==true). *@param f a pointer to the SkyPoint the map should slew to */ void setDestination(const SkyPoint &f); /** @short sets the destination point of the skymap, using ra/dec coordinates. * *@note This function behaves essentially like the above function. *It differs only in the data types of its arguments. * *@param ra the new right ascension *@param dec the new declination */ void setDestination(const dms &ra, const dms &dec); /** @short sets the destination point of the sky map, using its alt/az coordinates. *@param alt the new altitude *@param az the new azimuth */ void setDestinationAltAz(const dms &alt, const dms &az); /** @short set the FocusPoint; the position that is to be the next Destination. *@param f a pointer to the FocusPoint SkyPoint. */ void setFocusPoint(SkyPoint *f) { if (f) FocusPoint = *f; } /** @short Retrieve the ClickedPoint position. * *When the user clicks on a point in the sky map, the sky coordinates of the mouse *cursor are stored in the private member ClickedPoint. This function retrieves *a pointer to ClickedPoint. *@return a pointer to ClickedPoint, the sky coordinates where the user clicked. */ SkyPoint *clickedPoint() { return &ClickedPoint; } /** @short Set the ClickedPoint to the skypoint given as an argument. *@param f pointer to the new ClickedPoint. */ void setClickedPoint(SkyPoint *f); /** @short Retrieve the object nearest to a mouse click event. * *If the user clicks on the sky map, a pointer to the nearest SkyObject is stored in *the private member ClickedObject. This function returns the ClickedObject pointer, *or nullptr if there is no CLickedObject. *@return a pointer to the object nearest to a user mouse click. */ SkyObject *clickedObject() const { return ClickedObject; } /** @short Set the ClickedObject pointer to the argument. *@param o pointer to the SkyObject to be assigned as the ClickedObject */ void setClickedObject(SkyObject *o); /** @short Retrieve the object which is centered in the sky map. * *If the user centers the sky map on an object (by double-clicking or using the *Find Object dialog), a pointer to the "focused" object is stored in *the private member FocusObject. This function returns a pointer to the *FocusObject, or nullptr if there is not FocusObject. *@return a pointer to the object at the center of the sky map. */ SkyObject *focusObject() const { return FocusObject; } /** @short Set the FocusObject pointer to the argument. *@param o pointer to the SkyObject to be assigned as the FocusObject */ void setFocusObject(SkyObject *o); /** @ Set zoom factor. *@param factor zoom factor */ void setZoomFactor(double factor); /** @short Call to set up the projector before update of SkyItems positions begins. */ void setupProjector(); /** @short Returns index for a Harvard spectral classification */ int harvardToIndex(char c); /** @short returns cache of star images * @return star images cache */ QVector> getImageCache(); /** * @short creates QImage from text and converts it to QSGTexture * @param text the text string * @param color text color * @param zoomFont if true zoom-dependent font from SkyLabeler will be used else standart * font is used * @return QSGTexture with text * @note font size is set in SkyLabeler::SkyLabeler() by initializing m_stdFont with default font */ QSGTexture *textToTexture(QString text, QColor color = QColor(255, 255, 255), bool zoomFont = false); /** * @short returns cached texture from textureCache. * * Use outside of scene graph rendering thread (e.g. not during call to updatePaintNode) * is prohibited! * @param size size of the star * @param spType spectral class * @return cached QSGTexture from textureCache */ QSGTexture *getCachedTexture(int size, char spType); /** @short called when SkyMapComposite finished loading all SkyComponents */ inline void loadingFinished() { m_loadingFinished = true; } /** @return true if the map is in slewing mode or clock is active **/ bool isSlewing() const; /** @return current magnitude limit **/ inline double getMagLim() { return m_magLim; } /** @short set magnitude limit **/ void setMagLim(double magLim); /** @short Convenience function for shutting off tracking mode. Just calls KStars::slotTrack() **/ void stopTracking(); /** Get the current projector. @return a pointer to the current projector. */ inline const Projector *projector() const { return m_proj; } /** * @short used in QML * @return type of current projection system */ Q_INVOKABLE uint projType() const; /** Set magnitude limit for size of stars. Used in StarItem **/ inline void setSizeMagLim(float sizeMagLim) { m_sizeMagLim = sizeMagLim; } /** Used in PointSourceNode **/ inline float sizeMagLim() const { return m_sizeMagLim; } static inline RootNode *rootNode() { return m_rootNode; } static inline void setRootNode(RootNode *root) { m_rootNode = root; } /** return limit of hides for the node to delete it **/ static double deleteLimit(); /** * @short adds FOV symbol to m_FOVSymbols * @param FOVName name of a FOV symbol + * @param initialState defines whether the state is initial */ Q_INVOKABLE void addFOVSymbol(const QString &FOVName, bool initialState = false); /** * @param index of FOVSymbol in m_FOVSymbols * @return true if FOV symbol with name FOVName should be drawn. */ bool isFOVVisible(int index); /** * @param index of FOVSymbol in m_FOVSymbols * @param visible defines whether the FOV symbol should be visible * @short updates visibility of FOV symbol according to visible */ Q_INVOKABLE void setFOVVisible(int index, bool visible); /** * @short this QList should be used as a model in QML to switch on/off FOV symbols **/ Q_INVOKABLE inline QStringList getFOVSymbols() { return m_FOVSymbols; } /** @short Initializes images of Stars and puts them in cache (copied from SkyQPainter)*/ void initStarImages(); /** * @short getter for clickedPointLite */ SkyPointLite *getClickedPointLite() { return m_ClickedPointLite; } /** * @short getter for clickedObjectLite */ SkyObjectLite *getClickedObjectLite() { return m_ClickedObjectLite; } /** * @short getter for centerLocked */ bool getCenterLocked() { return m_centerLocked; } /** * @short Proxy method for SkyMapDrawAbstract::drawObjectLabels() */ //inline void drawObjectLabels( QList< SkyObject* >& labelObjects ) { dynamic_cast(m_SkyMapDraw)->drawObjectLabels( labelObjects ); } /** * @return true if SkyMapLite is being slewed */ bool getSlewing() const { return m_slewing; } /** * @short sets whether SkyMapLite is being slewed */ void setSlewing(bool newSlewing); /** * @short sets whether SkyMapLite is centered on an object and locked(olny pinch-to-zoom is available) */ void setCenterLocked(bool centerLocked); /** True if automatic mode is on (SkyMapLite is controlled by smartphones accelerometer magnetometer) **/ bool getAutomaticMode() const { return m_automaticMode; } /** * @short switch automatic mode on/off according to isOn parameter */ Q_INVOKABLE void setAutomaticMode(bool automaticMode); double getSkyRotation() const { return m_skyRotation; } public slots: /** Called whenever wrappers' width or height are changed. Probably will be used to * update positions of items. */ void resizeItem(); /** Recalculates the positions of objects in the sky, and then repaints the sky map. */ void forceUpdate(); /** @short Left for compatibility reasons * @see forceUpdate() */ void forceUpdateNow() { forceUpdate(); } /** * @short Update the focus point and call forceUpdate() * @param now is saved for compatibility reasons */ void slotUpdateSky(bool now); /** Step the Focus point toward the Destination point. Do this iteratively, redrawing the Sky * Map after each step, until the Focus point is within 1 step of the Destination point. * For the final step, snap directly to Destination, and redraw the map. */ void slewFocus(); /** @short Center the display at the point ClickedPoint. * * The essential part of the function is to simply set the Destination point, which will emit * the destinationChanged() SIGNAL, which triggers the slewFocus() SLOT. Additionally, this * function performs some bookkeeping tasks, such updating whether we are tracking the new * object/position, adding a Planet Trail if required, etc. * * @see destinationChanged() * @see slewFocus() */ void slotCenter(); /** Checks whether the timestep exceeds a threshold value. If so, sets * ClockSlewing=true and sets the SimClock to ManualMode. */ void slotClockSlewing(); /** Zoom in one step. */ void slotZoomIn(); /** Zoom out one step. */ void slotZoomOut(); /** Set default zoom. */ void slotZoomDefault(); /** * @short centres skyObj in SkyMap and opens context drawer with skyObj * Used in FindDialogLite */ void slotSelectObject(SkyObject *skyObj); /** @short updates focus of SkyMapLite according to data from DeviceOrientation (Smartphone's sensors)*/ void updateAutomaticMode(); void setSkyRotation(double skyRotation); signals: /** Emitted by setDestination(), and connected to slewFocus(). Whenever the Destination * point is changed, slewFocus() will iteratively step the Focus toward Destination * until it is reached. * @see SkyMap::setDestination() * @see SkyMap::slewFocus() */ void destinationChanged(); /** Emitted when zoom level is changed. */ void zoomChanged(); /** Emitted when current object changed. */ void objectChanged(); /** Wrapper of ClickedObject for QML **/ void objectLiteChanged(); /** Wrapper of ClickedPoint for QML **/ void pointLiteChanged(); /** Emitted when pointing changed. (At least should) */ void positionChanged(); /** Emitted when position under mouse changed. */ void mousePointChanged(SkyPoint *); /** Emitted when a position is clicked */ void positionClicked(SkyPoint *); /** Emitted when user clicks on SkyMapLite (analogous to positionClicked but sends QPoint) */ void posClicked(QPointF pos); /** Emitted when magnitude limit is changed */ void magLimChanged(double magLim); /** Emitted when FOVSymbols list was changed (new value appended) **/ void symbolsFOVChanged(QStringList); /** Emitted when SkyMapLite is being slewed or slewing is finished **/ void slewingChanged(bool); void centerLockedChanged(bool); void automaticModeChanged(bool); /** Emitted when skyRotation used to rotate coordinates of SkyPoints is changed **/ void skyRotationChanged(double skyRotation); protected: /** Process keystrokes: * @li arrow keys Slew the map * @li +/- keys Zoom in and out * @li Space Toggle between Horizontal and Equatorial coordinate systems * @li 0-9 Go to a major Solar System body (0=Sun; 1-9 are the major planets, except 3=Moon) * @li [ Place starting point for measuring an angular distance * @li ] End point for Angular Distance; display measurement. * @li Escape Cancel Angular measurement * @li ,/< Step backward one time step * @li ./> Step forward one time step */ //virtual void keyPressEvent( QKeyEvent *e ); /** When keyRelease is triggered, just set the "slewing" flag to false, * and update the display (to draw objects that are hidden when slewing==true). */ //virtual void keyReleaseEvent( QKeyEvent *e ); /** Determine RA, Dec coordinates of clicked location. Find the SkyObject * which is nearest to the clicked location. * * If left-clicked: Set set mouseButtonDown==true, slewing==true; display * nearest object name in status bar. * If right-clicked: display popup menu appropriate for nearest object. */ virtual void mousePressEvent(QMouseEvent *e); /** set mouseButtonDown==false, slewing==false */ virtual void mouseReleaseEvent(QMouseEvent *e); /** Center SkyMap at double-clicked location */ virtual void mouseDoubleClickEvent(QMouseEvent *e); /** This function does several different things depending on the state of the program: * @li If Angle-measurement mode is active, update the end-ruler point to the mouse cursor, * and continue this function. * @li If we are defining a ZoomBox, update the ZoomBox rectangle, redraw the screen, * and return. * @li If dragging the mouse in the map, update focus such that RA, Dec under the mouse * cursor remains constant. * @li If just moving the mouse, simply update the curso coordinates in the status bar. */ virtual void mouseMoveEvent(QMouseEvent *e); /** Zoom in and out with the mouse wheel. */ virtual void wheelEvent(QWheelEvent *e); /** * @short this function handles zooming in and out using "pinch to zoom" gesture */ virtual void touchEvent(QTouchEvent *e); private slots: /** @short display tooltip for object under cursor. It's called by m_HoverTimer. * if mouse didn't moved for last HOVER_INTERVAL milliseconds. */ //void slotTransientLabel(); /** Set the shape of mouse cursor to a cross with 4 arrows. */ void setMouseMoveCursor(); private: /** @short Sets the shape of the default mouse cursor to a cross. */ void setDefaultMouseCursor(); /** @short Sets the shape of the mouse cursor to a magnifying glass. */ void setZoomMouseCursor(); /** Calculate the zoom factor for the given keyboard modifier */ double zoomFactor(const int modifier); /** calculate the magnitude factor (1, .5, .2, or .1) for the given * keyboard modifier. */ double magFactor(const int modifier); /** Decrease the magnitude limit by a step size determined by the * keyboard modifier. * @param modifier */ void decMagLimit(const int modifier); /** Increase the magnitude limit by a step size determined by the * keyboard modifier. * @param modifier */ void incMagLimit(const int modifier); /** Convenience routine to either zoom in or increase mag limit * depending on the Alt modifier. The Shift and Control modifiers * will adjust the size of the zoom or the mag step. * @param modifier */ void zoomInOrMagStep(const int modifier); /** Convenience routine to either zoom out or decrease mag limit * depending on the Alt modifier. The Shift and Control modifiers * will adjust the size of the zoom or the mag step. * @param modifier */ void zoomOutOrMagStep(const int modifier); /** * pointer to RootNode. Use it to universally access RootNode * @warning RootNode should be used solely during updatePaintNode! See Qt Quick Scene Graph documentation. **/ static RootNode *m_rootNode; static SkyMapLite *pinstance; static int starColorMode; /// True if SkyMapLite was initialized (star images were initialized etc.) bool isInitialized { false }; bool mouseButtonDown { false }; bool midMouseButtonDown { false }; /// True if mouseMoveEvent; needed by setMouseMoveCursor bool mouseMoveCursor { false }; bool m_slewing { false }; bool clockSlewing { false }; /// True if pinch to zoom or pinch to rotate is performed bool pinch { false }; /// If false only old pixmap will repainted with bitBlt() to save a lot of CPU usage bool computeSkymap { false }; double y0 { 0 }; int count { 0 }; KStarsData *data { nullptr }; /// True if SkyMapComposite has finished loading of SkyComponents bool m_loadingFinished { false }; /// Coordinates of point under cursor. It's update in function mouseMoveEvent SkyPoint m_MousePoint; SkyPoint Focus, ClickedPoint, FocusPoint, Destination; SkyObject *ClickedObject { nullptr }; SkyObject *FocusObject { nullptr }; SkyPointLite *m_ClickedPointLite { nullptr }; SkyObjectLite *m_ClickedObjectLite { nullptr }; bool m_centerLocked { false }; //SkyLine AngularRuler; //The line for measuring angles in the map QRect ZoomRect; //The manual-focus circle. /// Mouse should not move for that interval to display tooltip static const int HOVER_INTERVAL = 500; /// Timer for tooltips QTimer m_HoverTimer; bool m_objPointingMode { false }; bool m_fovCaptureMode { false }; Projector *m_proj { nullptr }; QQuickItem *m_SkyMapLiteWrapper { nullptr }; /// Holds SkyNodes that need to be deleted QLinkedList m_deleteNodes; /// Used in PointSourceNode float m_sizeMagLim { 10 }; /// Mag limit for all objects double m_magLim { 0 }; /// Used to notify zoom-dependent labels about font size change bool m_fontSizeChanged { false }; /// Used for drawing labels QPainter m_painter; /** * This timer is triggered every time user touches the screen with one finger. * If touch was released within 500 milliseconds than it is a tap, otherwise we pan. **/ QTimer m_tapBeganTimer; /// Good to keep the original ruler start-point for purposes of dynamic_cast const SkyPoint *m_rulerStartPoint; QStringList m_FOVSymbols; QList m_FOVSymVisible; /// Total number of sizes of stars. const int nStarSizes { 15 }; /// Total number of spectral classes (N.B. Must be in sync with harvardToIndex) const int nSPclasses { 7 }; /// Cache for star images. QVector> imageCache; /// Textures created from cached star images QVector> textureCache; bool clearTextures { false }; bool tapBegan { false }; QList m_newTelescopes; QList m_delTelescopes; bool m_automaticMode { false }; double m_skyRotation { 0 }; SkyMapOrientation m_skyMapOrientation { SkyMapOrientation::Top0 }; #if defined(Q_OS_ANDROID) QTimer automaticModeTimer; DeviceOrientation *m_deviceOrientation { nullptr }; #endif }; diff --git a/kstars/skyobjects/ksplanetbase.h b/kstars/skyobjects/ksplanetbase.h index da103c2de..91c82ba78 100644 --- a/kstars/skyobjects/ksplanetbase.h +++ b/kstars/skyobjects/ksplanetbase.h @@ -1,287 +1,288 @@ /*************************************************************************** ksplanetbase.h - K Desktop Planetarium ------------------- begin : Sun Jan 29 2002 copyright : (C) 2002 by Mark Hollomon email : mhh@mindspring.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include "trailobject.h" #include "kstarsdata.h" #include #include #include #include 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 { public: dms longitude; dms latitude; double radius; /**Constructor. */ explicit EclipticPosition(dms plong = dms(), dms plat = dms(), double prad = 0.0) : longitude(plong), latitude(plat), radius(prad) { } }; /** * @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 */ explicit KSPlanetBase(const QString &s = i18n("unnamed"), const QString &image_file = QString(), const QColor &c = Qt::white, double pSize = 0); /** Destructor (empty) */ ~KSPlanetBase() override = default; void init(const QString &s, const QString &image_file, const QColor &c, double pSize); //enum Planets { MERCURY=0, VENUS=1, MARS=2, JUPITER=3, SATURN=4, URANUS=5, NEPTUNE=6, PLUTO=7, SUN=8, MOON=9, UNKNOWN_PLANET }; enum Planets { MERCURY = 0, VENUS = 1, MARS = 2, JUPITER = 3, SATURN = 4, URANUS = 5, NEPTUNE = 6, SUN = 7, MOON = 8, EARTH_SHADOW = 9, UNKNOWN_PLANET }; static KSPlanetBase *createPlanet(int n); static QVector planetColor; virtual bool loadData() = 0; /** @return pointer to Ecliptic Longitude coordinate */ const dms &ecLong() const { return ep.longitude; } /** @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 */ void setEcLong(dms elong) { ep.longitude = elong; } /** * @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 */ const dms &helEcLong() const { return helEcPos.longitude; } /** @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) */ void EclipticToEquatorial(const CachingDms *Obliquity); /** * @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 */ const QImage &image() const { return m_image; } /** @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 */ 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 */ 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. */ 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() + * @param forceRecompute defines whether the data should be recomputed forcefully */ void updateCoords(const KSNumbers *num, bool includePlanets = true, const CachingDms *lat = nullptr, const CachingDms *LST = nullptr, bool forceRecompute = false) 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) */ void findPosition(const KSNumbers *num, const CachingDms *lat = nullptr, const CachingDms *LST = nullptr, const KSPlanetBase *Earth = nullptr); /** @return the Planet's position angle. */ double pa() const override { return PositionAngle; } /** * @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 */ double angSize() const { return AngularSize; } /** @short set the planet's angular size, in km. * @param size the planet's size, in km */ void setAngularSize(double size) { AngularSize = size; } /** @return the Planet's physical size, in km */ double physicalSize() const { return PhysicalSize; } /** @short set the planet's physical size, in km. * @param size the planet's size, in km */ void setPhysicalSize(double size) { PhysicalSize = size; } /** @return the phase angle of this planet */ inline dms phase() { return dms(Phase); } /** @return the color for the planet symbol */ QColor &color() { return m_Color; } /** @short Set the color for the planet symbol */ void setColor(const QColor &c) { m_Color = c; } /** @return true if the KSPlanet is one of the eight major planets */ bool isMajorPlanet() const; /** @return the pixel distance for offseting the object's name label */ double labelOffset() const override; protected: /** Big object. Planet, Moon, Sun. */ static const UID UID_SOL_BIGOBJ; /** Asteroids */ static const UID UID_SOL_ASTEROID; /** Comets */ static const UID UID_SOL_COMET; /** 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. */ 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. */ virtual void findMagnitude(const KSNumbers *num) = 0; /** * 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. */ virtual void findPhase(); virtual double findAngularSize() { return asin(physicalSize() / Rearth / AU_KM) * 60. * 180. / dms::PI; } // Geocentric ecliptic position, but distance to the Sun EclipticPosition ep; // Heliocentric ecliptic position referred to the equinox of the epoch // as obtained from VSOP. EclipticPosition helEcPos; double Rearth; double Phase; QImage m_image; 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. */ void localizeCoords(const KSNumbers *num, const CachingDms *lat, const CachingDms *LST); double PositionAngle, AngularSize, PhysicalSize; QColor m_Color; }; diff --git a/kstars/skyobjects/starobject.h b/kstars/skyobjects/starobject.h index 37779a449..83563cc82 100644 --- a/kstars/skyobjects/starobject.h +++ b/kstars/skyobjects/starobject.h @@ -1,316 +1,317 @@ /*************************************************************************** starobject.h - K Desktop Planetarium ------------------- begin : Tue Sep 18 2001 copyright : (C) 2001 by Thomas Kabelmann email : tk78@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once //#define PROFILE_UPDATECOORDS #include "skyobject.h" #include struct DeepStarData; class KSNumbers; class KSPopupMenu; struct StarData; /** * @class StarObject * * This is a subclass of SkyObject. It adds the Spectral type, and flags * for variability and multiplicity. * For stars, the primary name (n) is the latin name (e.g., "Betelgeuse"). The * secondary name (n2) is the genetive name (e.g., "alpha Orionis"). * @short subclass of SkyObject specialized for stars. * * @author Thomas Kabelmann * @version 1.0 */ class StarObject : public SkyObject { public: /** * @short returns the reindex interval (in centuries!) for the given * magnitude of proper motion (in milliarcsec/year). ASSUMING a * 25 arc-minute margin for proper motion. */ static double reindexInterval(double pm); /** * Constructor. Sets sky coordinates, magnitude, latin name, genetive name, and spectral type. * * @param r Right Ascension * @param d Declination * @param m magnitude * @param n common name * @param n2 genetive name * @param sptype Spectral Type * @param pmra Proper motion in RA direction [mas/yr] * @param pmdec Proper motion in Dec direction [mas/yr] * @param par Parallax angle [mas] * @param mult Multiplicity flag (false=dingle star; true=multiple star) * @param var Variability flag (true if star is a known periodic variable) * @param hd Henry Draper Number */ explicit StarObject(dms r = dms(0.0), dms d = dms(0.0), float m = 0.0, const QString &n = QString(), const QString &n2 = QString(), const QString &sptype = "--", double pmra = 0.0, double pmdec = 0.0, double par = 0.0, bool mult = false, bool var = false, int hd = 0); /** * Constructor. Sets sky coordinates, magnitude, latin name, genetive name, and * spectral type. Differs from above function only in data type of RA and Dec. * * @param r Right Ascension * @param d Declination * @param m magnitude * @param n common name * @param n2 genetive name * @param sptype Spectral Type * @param pmra Proper motion in RA direction [mas/yr] * @param pmdec Proper motion in Dec direction [mas/yr] * @param par Parallax angle [mas] * @param mult Multiplicity flag (false=dingle star; true=multiple star) * @param var Variability flag (true if star is a known periodic variable) * @param hd Henry Draper Number */ StarObject(double r, double d, float m = 0.0, const QString &n = QString(), const QString &n2 = QString(), const QString &sptype = "--", double pmra = 0.0, double pmdec = 0.0, double par = 0.0, bool mult = false, bool var = false, int hd = 0); StarObject *clone() const override; UID getUID() const override; /** Copy constructor */ StarObject(const StarObject &o); /** Destructor. (Empty) */ ~StarObject() override = default; /** * @short Initializes a StarObject to given data * * This is almost like the StarObject constructor itself, but it avoids * setting up name, gname etc for unnamed stars. If called instead of the * constructor, this method will be much faster for unnamed stars * * @param stardata Pointer to starData object containing required data (except name and gname) * @return Nothing */ void init(const StarData *stardata); /** * @short Initializes a StarObject to given data * * @param stardata Pointer to deepStarData object containing the available data * @return Nothing */ void init(const DeepStarData *stardata); /** * @short Sets the name, genetive name, and long name * * @param name Common name * @param name2 Genetive name */ void setNames(const QString &name, const QString &name2); /** @return true if the star has a name ("star" doesn't count) */ inline bool hasName() const { return (!Name.isEmpty() && Name != starString); } /** @return true if the star has a latin name ("star" or HD... doesn't count) */ inline bool hasLatinName() const { return (!Name.isEmpty() && Name != starString && Name != gname(false) && Name != gname(true) && !Name.startsWith("HD ")); } /** If star is unnamed return "star" otherwise return the name */ inline QString name(void) const override { return hasName() ? Name : starString; } /** If star is unnamed return "star" otherwise return the longname */ inline QString longname(void) const override { return hasLongName() ? LongName : starString; } /** * Returns entire spectral type string * @return Spectral Type string */ QString sptype(void) const; /** Returns just the first character of the spectral type string. */ char spchar() const; /** * Returns the genetive name of the star. * @return genetive name of the star */ QString gname(bool useGreekChars = true) const; /** * Returns the greek letter portion of the star's genetive name. * Returns empty string if star has no genetive name defined. * @return greek letter portion of genetive name */ QString greekLetter(bool useGreekChars = true) const; /** @return the genitive form of the star's constellation. */ QString constell(void) const; /** * Determine the current coordinates (RA, Dec) from the catalog * coordinates (RA0, Dec0), accounting for both precession and nutation. * * @param num pointer to KSNumbers object containing current values of * time-dependent variables. * @param includePlanets does nothing in this implementation (see KSPlanetBase::updateCoords()). * @param lat does nothing in this implementation (see KSPlanetBase::updateCoords()). * @param LST does nothing in this implementation (see KSPlanetBase::updateCoords()). + * @param forceRecompute defines whether the data should be recomputed forcefully. */ void updateCoords(const KSNumbers *num, bool includePlanets = true, const CachingDms *lat = nullptr, const CachingDms *LST = nullptr, bool forceRecompute = false) override; /** * @short Fills ra and dec with the coordinates of the star with the proper * motion correction but without precision and its friends. It is used * in StarComponent to re-index all the stars. * * @return true if we changed the coordinates, false otherwise * NOTE: ra and dec both in degrees. */ bool getIndexCoords(const KSNumbers *num, CachingDms &ra, CachingDms &dec); bool getIndexCoords(const KSNumbers *num, double *ra, double *dec); /** @short added for JIT updates from both StarComponent and ConstellationLines */ void JITupdate(); /** @short returns the magnitude of the proper motion correction in milliarcsec/year */ inline double pmMagnitude() const { double cosDec = dec0().cos(); return sqrt(cosDec * cosDec * pmRA() * pmRA() + pmDec() * pmDec()); } /** * @short returns the square of the magnitude of the proper motion correction in (milliarcsec/year)^2 * @note This method is faster when the square root need not be taken */ inline double pmMagnitudeSquared() const { double metric_weighted_pmRA = dec0().cos() * pmRA(); return (metric_weighted_pmRA * metric_weighted_pmRA + pmDec() * pmDec()); } /** * @short Set the Ra and Dec components of the star's proper motion, in milliarcsec/year. * Note that the RA component is multiplied by cos(dec). * @param pmra the new RA proper motion * @param pmdec the new Dec proper motion */ inline void setProperMotion(double pmra, double pmdec) { PM_RA = pmra; PM_Dec = pmdec; } /** @return the RA component of the star's proper motion, in mas/yr (multiplied by cos(dec)) */ inline double pmRA() const { return PM_RA; } /** @return the Dec component of the star's proper motion, in mas/yr */ inline double pmDec() const { return PM_Dec; } /** @short set the star's parallax angle, in milliarcsec */ inline void setParallax(double plx) { Parallax = plx; } /** @return the star's parallax angle, in milliarcsec */ inline double parallax() const { return Parallax; } /** @return the star's distance from the Sun in parsecs, as computed from the parallax. */ inline double distance() const { return 1000. / parallax(); } /** * @short set the star's multiplicity flag (i.e., is it a binary or multiple star?) * @param m true if binary/multiple star system */ inline void setMultiple(bool m) { Multiplicity = m; } /** @return whether the star is a binary or multiple starobject */ inline bool isMultiple() const { return Multiplicity; } /** @return the star's HD index */ inline int getHDIndex() const { return HD; } /** * @short set the star's variability flag * * @param v true if star is variable */ inline void setVariable(bool v) { Variability = v; } /** @return whether the star is a binary or multiple starobject */ inline bool isVariable() const { return Variability; } /** @short returns the name, the magnitude or both. */ QString nameLabel(bool drawName, bool drawMag) const; QString labelString() const override; /** * @return the pixel distance for offseting the star's name label * This takes the zoom level and the star's brightness into account. */ double labelOffset() const override; /** @return the Visual magnitude of the star */ inline float getVMag() const { return V; } /** @return the blue magnitude of the star */ inline float getBMag() const { return B; } /** * @return the B - V color index of the star, or a nonsense number * larger than 30 if it's not well defined */ inline float getBVIndex() const { return ((B < 30.0 && V < 30.0) ? B - V : 99.9); } void initPopupMenu(KSPopupMenu *pmenu) override; quint64 updateID { 0 }; quint64 updateNumID { 0 }; #ifdef PROFILE_UPDATECOORDS static double updateCoordsCpuTime; static unsigned int starsUpdated; #endif protected: // DEBUG EDIT. For testing proper motion, uncomment this, and related blocks // See starobject.cpp for further info. // static QVector Trail; // bool testStar; // END DEBUG private: double PM_RA { 0 }; double PM_Dec { 0 }; double Parallax { 0 }; bool Multiplicity { false }; bool Variability { false }; char SpType[2]; int HD { 0 }; // B and V magnitudes, separately. NOTE 1) This is kept separate from mag for a reason. // See init( const DeepStarData *); 2) This applies only to deep stars at the moment float B { 0 }; float V { 0 }; }; diff --git a/kstars/tools/altvstime.h b/kstars/tools/altvstime.h index ef5bca01f..82a291e50 100644 --- a/kstars/tools/altvstime.h +++ b/kstars/tools/altvstime.h @@ -1,209 +1,210 @@ /*************************************************************************** altvstime.h - description ------------------- begin : Mon Dec 23 2002 copyright : (C) 2002 by Pablo de Vicente email : vicente@oan.es ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include #include #include "ui_altvstime.h" class QCPAbstractPlottable; class QCPItemPixmap; class QCPRange; class QMouseEvent; class QPixmap; class GeoLocation; class KStarsDateTime; class SkyObject; class SkyPoint; class AltVsTimeUI : public QFrame, public Ui::AltVsTime { Q_OBJECT public: explicit AltVsTimeUI(QWidget *p = nullptr); }; /** * @class AltVsTime * @short the Altitude vs. Time Tool. * Plot the altitude as a function of time for any list of * objects, as seen from any location, on any date. * * @author Jason Harris */ class AltVsTime : public QDialog { Q_OBJECT public: /** Constructor */ explicit AltVsTime(QWidget *parent = nullptr); /** Destructor */ ~AltVsTime() override; /** * Determine the limits for the sideral time axis, using * the sidereal time at midnight for the current date * and location settings. */ void setLSTLimits(); /** * Set the AltVsTime Date according to the current Date * in the KStars main window. Currently, this is only * used in the ctor to initialize the Date. */ void showCurrentDate(); /** * @return a KStarsDateTime object constructed from the * current setting in the Date widget. */ KStarsDateTime getDate(); /** * Determine the time of sunset and sunrise for the current * date and location settings. Convert the times to doubles, * expressing the times as fractions of a full day. * Calls AVTPlotWidget::setSunRiseSetTimes() to send the * numbers to the plot widget. */ void computeSunRiseSetTimes(); /** * Parse a string as an epoch number. If the string can't * be parsed, return 2000.0. * @param eName the epoch string to be parsed * @return the epoch number */ double getEpoch(const QString &eName); /** * @short Add a SkyObject to the display. * Constructs a PLotObject representing the Alt-vs-time curve for the object. * @param o pointer to the SkyObject to be added * @param forceAdd if true, then the object will be added, even if there * is already a curve for the same coordinates. */ void processObject(SkyObject *o, bool forceAdd = false); /** * @short Determine the altitude coordinate of a SkyPoint, * given an hour of the day. * * This is called for every 30-minute interval in the displayed Day, * in order to construct the altitude curve for a given object. * @param p the skypoint whose altitude is to be found * @param hour the time in the displayed day, expressed in hours * @return the Altitude, expressed in degrees */ double findAltitude(SkyPoint *p, double hour); /** * @short get object name. If star has no name, generate a name based on catalog number. + * @param o sky object. * @param translated set to true if the translated name is required. */ QString getObjectName(const SkyObject *o, bool translated = true); void drawGradient(); public slots: /** @short Update the plot to reflec new Date and Location settings. */ void slotUpdateDateLoc(); /** @short Clear the list of displayed objects. */ void slotClear(); /** @short Show information from the curve as a tooltip. */ void plotMousePress(QCPAbstractPlottable *abstractPlottable, int dataIndex, QMouseEvent *event); /** @short Update the X axis on Zoom and Drag. */ void onXRangeChanged(const QCPRange &range); /** @short Update the Y axis on Zoom and Drag. */ void onYRangeChanged(const QCPRange &range); /** @short Compute the altitude for a certain time. */ void slotComputeAltitudeByTime(); /** @short Mark the rise time on the curve. */ void slotMarkRiseTime(); /** @short Mark the set time on the curve. */ void slotMarkSetTime(); /** @short Mark the transit time on the curve. */ void slotMarkTransitTime(); /** @short Draw the white vertical line on click. */ void mouseOverLine(QMouseEvent *event); /** @short Clear the edit boxes for specifying a new object. */ void slotClearBoxes(); /** * @short Add an object to the list of displayed objects, according * to the data entered in the edit boxes. */ void slotAddSource(); /** * @short Launch the Find Object window to select a new object for * the list of displayed objects. */ void slotBrowseObject(); /** @short Launch the Location dialog to choose a new location. */ void slotChooseCity(); /** * @short Move input keyboard focus to the next logical widget. * We need a separate slot for this because we are intercepting * Enter key events, which close the window by default, to * advance input focus instead (when the Enter events occur in * certain Edit boxes). */ void slotAdvanceFocus(); /** * Update the plot to highlight the altitude curve of the objects * which is highlighted in the listbox. */ void slotHighlight(int); /** @short Print plot widget */ void slotPrint(); private: /** @short find start of dawn, end of dusk, maximum and minimum elevation of the sun */ void setDawnDusk(); AltVsTimeUI *avtUI { nullptr }; GeoLocation *geo { nullptr }; QList pList; QList deleteList; int DayOffset { 0 }; int minAlt { 0 }; int maxAlt { 0 }; QCPItemPixmap *background { nullptr }; QPixmap *gradient { nullptr }; }; diff --git a/kstars/widgets/kshelplabel.h b/kstars/widgets/kshelplabel.h index 94cf3e59a..689923e08 100644 --- a/kstars/widgets/kshelplabel.h +++ b/kstars/widgets/kshelplabel.h @@ -1,73 +1,74 @@ /*************************************************************************** kshelplabel.h - Help label used to document astronomical terms ------------------- begin : Wed 1 Dec 2010 copyright : (C) 2010 by Valery Kharitonov email : kharvd@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef KSHELPLABEL_H #define KSHELPLABEL_H #include /** Label for displaying links to AstroInfo project * @author Valery Kharitonov */ class KSHelpLabel : public QLabel { Q_OBJECT Q_PROPERTY(QString anchor READ anchor WRITE setAnchor) Q_PROPERTY(QString text READ text WRITE setText) public: /** * Constructor. Creates clear label */ explicit KSHelpLabel(QWidget *parent = nullptr); /** * Constructor. Creates label with a text and help anchor. * @param text Text of the label * @param anchor Name of the section in the AstroInfo project (without 'ai-') + * @param parent Parent widget */ KSHelpLabel(const QString &text, const QString &anchor, QWidget *parent = nullptr); QString text() const { return m_cleanText; } void setText(const QString &text); void setAnchor(const QString &anchor); QString anchor() const { return m_anchor; } private slots: /** Open AstroInfo definition of the terms * @param term jargon term */ void slotShowDefinition(const QString &term); private: /** * Updates text with the new anchor */ void updateText(); /** * Anchor in AstroInfo project */ QString m_anchor; /** * String without markup */ QString m_cleanText; }; #endif // KSHELPLABEL_H diff --git a/kstars/widgets/moonphasecalendarwidget.h b/kstars/widgets/moonphasecalendarwidget.h index f042a151d..5698c2283 100644 --- a/kstars/widgets/moonphasecalendarwidget.h +++ b/kstars/widgets/moonphasecalendarwidget.h @@ -1,105 +1,106 @@ /*************************************************************************** moonphasecalendarwidget.h - K Desktop Planetarium ------------------- begin : Sat Jun 26 2010 copyright : (C) 2010 by Akarsh Simha email : akarshsimha@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #pragma once #include #include #include class KSMoon; class KSSun; class KStarsDateTime; class MoonPhaseCalendar : public QCalendarWidget { Q_OBJECT public: /** * Constructor * @param moon A reference to a (non-const) KSMoon object, that will be updated * @param sun A reference to a (non-const) KSSun object, that will be updated + * @param parent Parent widget */ explicit MoonPhaseCalendar(KSMoon &moon, KSSun &sun, QWidget *parent = nullptr); ~MoonPhaseCalendar(); /** @return a suggested size for the widget */ virtual QSize sizeHint() const; public slots: /** * Set the geometry of the moon phase calendar (overloaded from QWidget). * Resizes the cells so as to fill the space of the calendar. * @note This is called automatically by resize events. * @p x the x-position of the widget * @p y the y-position of the widget * @p w the width of the widget * @p h the height of the widget */ virtual void setGeometry(int x, int y, int w, int h); virtual void setGeometry(const QRect &r); protected: /** * Overrides KDateTable::paintEvent() to draw moon phases on the * calendar cells by calling this->paintCell() * @note Most of this code is copied from KDateTable::paintEvent() */ virtual void paintEvent(QPaintEvent *e); /** * Replaces KDateTable::paintCell() to draw moon phases on the calendar cells * @note Most of this code is copied from KDateTable::paintCell() */ void paintCell(QPainter *painter, int row, int col, const KColorScheme &colorScheme); /** * @short Loads the moon images, appropriately resized depending * on the current cell size. * * @note This method is very slow and one must avoid calling it more than once. */ void loadImages(); /** @short Computes the optimum moon image size */ void computeMoonImageSize(); private: /** * @short Computes the moon phase for the given date. * @param date Date / Time of the computation * @return the _integer_ phase for the given date */ unsigned short computeMoonPhase(const KStarsDateTime &date); QPixmap m_Images[36]; // Array storing moon images against integer phase double cellWidth { 0 }; double cellHeight { 0 }; int numWeekRows { 0 }; int numDayColumns { 0 }; int MoonImageSize { 0 }; bool imagesLoaded { false }; KSMoon &m_Moon; KSSun &m_Sun; };