File indexing completed on 2024-04-21 14:46:47

0001 /*
0002     SPDX-FileCopyrightText: 2016 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     Based on Samikshan Bairagya GSoC work.
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #include "supernova.h"
0010 
0011 #include <typeinfo>
0012 #ifndef KSTARS_LITE
0013 #include "kspopupmenu.h"
0014 #endif
0015 
0016 Supernova::Supernova(const QString &sName, dms ra, dms dec, const QString &type, const QString &hostGalaxy,
0017                      const QString &date, float sRedShift, float sMag, const QDateTime& _discoveryDate)
0018     : SkyObject(SkyObject::SUPERNOVA, ra, dec, sMag, sName), type(type), hostGalaxy(hostGalaxy), date(date),
0019       redShift(sRedShift)
0020 {
0021     this->discoveryDate = _discoveryDate;
0022 }
0023 
0024 Supernova *Supernova::clone() const
0025 {
0026     Q_ASSERT(typeid(this) == typeid(static_cast<const Supernova *>(this))); // Ensure we are not slicing a derived class
0027     return new Supernova(*this);
0028 }
0029 
0030 void Supernova::initPopupMenu(KSPopupMenu *pmenu)
0031 {
0032 #ifdef KSTARS_LITE
0033     Q_UNUSED(pmenu)
0034 #else
0035     pmenu->createSupernovaMenu(this);
0036 #endif
0037 }
0038 
0039 QString Supernova::url() {
0040     // usually names are like "SN 2023xyz" or "AT 2023xyz"
0041     QString basename;
0042     if (!(name().startsWith("19") || name().startsWith("20")))
0043         basename = name().mid(3);
0044     else
0045         basename = name();
0046 
0047     return "https://www.wis-tns.org/object/" + basename;
0048 }