7#include "kspopupmenu.h"
9#include "config-kstars.h"
12#include "kstarsdata.h"
14#include "skyobjects/skyobject.h"
15#include "skyobjects/starobject.h"
16#include "skyobjects/trailobject.h"
17#include "skyobjects/catalogobject.h"
18#include "skyobjects/ksmoon.h"
19#include "skyobjects/satellite.h"
20#include "skyobjects/supernova.h"
21#include "skycomponents/constellationboundarylines.h"
22#include "skycomponents/flagcomponent.h"
23#include "skycomponents/skymapcomposite.h"
24#include "skyobjectuserdata.h"
25#include "tools/whatsinteresting/wiview.h"
26#include "catalogsdb.h"
27#include "observinglist.h"
30#include "indi/indilistener.h"
31#include "indi/guimanager.h"
32#include "indi/driverinfo.h"
33#include "indi/indistd.h"
34#include "indi/indidevice.h"
35#include "indi/indigroup.h"
36#include "indi/indiproperty.h"
37#include "indi/indielement.h"
38#include "indi/indimount.h"
39#include <basedevice.h>
42#include <KLocalizedString>
44#include <QWidgetAction>
51 if (m > -30 && m < 90)
52 return QString(
"%1<sup>m</sup>").
arg(m, 0,
'f', 2);
87 return isRaise ?
i18n(
"Rise time: %1", time) :
88 i18nc(
"the time at which an object falls below the horizon",
89 "Set time: %1", time);
92 return isRaise ?
i18n(
"No rise time: Circumpolar") :
93 i18n(
"No set time: Circumpolar");
95 return isRaise ?
i18n(
"No rise time: Never rises") :
96 i18n(
"No set time: Never rises");
106 return i18n(
"Transit time: %1",
114 :
QMenu(
KStars::Instance()), m_CurrentFlagIdx(-1), m_EditActionMapping(nullptr),
115 m_DeleteActionMapping(nullptr)
121 if (m_EditActionMapping)
123 delete m_EditActionMapping;
126 if (m_DeleteActionMapping)
128 delete m_DeleteActionMapping;
135 SkyObject o(SkyObject::TYPE_UNKNOWN, nullObj->
ra(), nullObj->
dec());
145void KSPopupMenu::slotEditFlag()
147 if (m_CurrentFlagIdx != -1)
153void KSPopupMenu::slotDeleteFlag()
155 if (m_CurrentFlagIdx != -1)
161void KSPopupMenu::slotEditFlag(
QAction *action)
163 int idx = m_EditActionMapping->
value(action, -1);
176void KSPopupMenu::slotDeleteFlag(
QAction *action)
178 int idx = m_DeleteActionMapping->
value(action, -1);
196 if (star->
name() !=
"star")
212 initPopupMenu(star, name,
i18n(
"star"),
215 if (star->
name() !=
"star")
230 QString name = getObjectName(obj);
234 .
arg(magToStr(obj->
mag()))
240 float b = obj->
b() > 0 ? obj->
b() : obj->
a();
244 initPopupMenu(obj, name, typeName, info);
256void KSPopupMenu::createMoonMenu(
KSMoon *moon)
266 QString velocity, altitude, range;
273 addFancyLabel(satellite->
name());
274 addFancyLabel(satellite->
id());
275 addFancyLabel(
i18n(
"satellite"));
276 addFancyLabel(KStarsData::Instance()
278 ->constellationBoundary()
279 ->constellationName(satellite));
283 addFancyLabel(
i18n(
"Velocity: %1 km/s", velocity), -2);
284 addFancyLabel(
i18n(
"Altitude: %1 km", altitude), -2);
285 addFancyLabel(
i18n(
"Range: %1 km", range), -2);
295 i18n(
"Angular Distance To... ["), ks->
map(),
296 SLOT(slotBeginAngularDistance()));
298 i18n(
"Starhop from here to... "), ks->
map(),
299 SLOT(slotBeginStarHop()));
301 SLOT(slotCopyTLE()));
306 SLOT(slotRemoveObjectLabel()));
309 SLOT(slotAddObjectLabel()));
318 float mag = supernova->
mag();
330 initPopupMenu(supernova, name,
i18n(
"supernova"), info);
334 QString info,
bool showDetails,
bool showObsList,
338 SkyMap *map = SkyMap::Instance();
341 bool showLabel = (name !=
i18n(
"star") && !name.
isEmpty());
345 Name =
i18n(
"Empty sky");
350 addFancyLabel(KStarsData::Instance()
352 ->constellationBoundary()
353 ->constellationName(obj));
358 addFancyLabel(riseSetTimeLabel(o,
true), -2);
359 addFancyLabel(riseSetTimeLabel(o,
false), -2);
360 addFancyLabel(transitTimeLabel(o), -2);
365 if (map->isInObjectPointingMode() && obj->
type() != 21)
367 addAction(
i18n(
"Select this object"), map, SLOT(slotObjectSelected()));
377 initFlagActions(obj);
383 i18n(
"Angular Distance To... ["), map,
384 SLOT(slotBeginAngularDistance()));
386 i18n(
"Starhop from here to... "), map, SLOT(slotBeginStarHop()));
391 i18nc(
"Show Detailed Information Dialog",
"Details"), map,
395 SLOT(slotCopyCoordinates()));
400 if (
map->isObjectLabeled(obj))
403 SLOT(slotRemoveObjectLabel()));
408 SLOT(slotAddObjectLabel()));
414 if (data->observingList()->
contains(obj))
416 i18n(
"Remove From Observing WishList"), data->observingList(),
417 SLOT(slotRemoveObject()));
420 data->observingList(), SLOT(slotAddObject()));
427 addAction(
i18n(
"Remove Trail"), map, SLOT(slotRemovePlanetTrail()));
429 addAction(
i18n(
"Add Trail"), map, SLOT(slotAddPlanetTrail()));
438 addAction(
i18n(
"View in XPlanet"), map, SLOT(slotStartXplanetViewer()));
444 this, SLOT(slotViewInWI()));
447void KSPopupMenu::initFlagActions(
SkyObject *obj)
457 SLOT(slotAddFlag()));
459 SLOT(slotAddFlagRaw()));
462 else if (flags.
size() == 1)
466 SLOT(slotEditFlag()));
468 SLOT(slotDeleteFlag()));
470 m_CurrentFlagIdx = flags.
first();
482 SLOT(slotEditFlag(
QAction *)));
484 SLOT(slotDeleteFlag(
QAction *)));
486 if (m_EditActionMapping)
488 delete m_EditActionMapping;
491 if (m_DeleteActionMapping)
493 delete m_DeleteActionMapping;
499 foreach (
int idx, flags)
505 if (flagLabel.
size() > 35)
507 flagLabel = flagLabel.
left(35);
514 m_EditActionMapping->
insert(editAction, idx);
519 m_DeleteActionMapping->
insert(deleteAction, idx);
531 const auto &user_data = KStarsData::Instance()->
getUserData(obj->
name());
532 const auto &image_list = user_data.images();
533 const auto &website_list = user_data.websites();
534 for (
const auto &res : std::list <
535 std::tuple<QString, SkyObjectUserdata::LinkList, SkyObjectUserdata::Type >>
537 {
i18n(
"Image Resources"), image_list, SkyObjectUserdata::Type::image },
538 {
i18n(
"Web Links"), website_list, SkyObjectUserdata::Type::website }
541 const auto &
title = std::get<0>(res);
542 const auto &list = std::get<1>(res);
543 const auto &type = std::get<2>(res);
549 for (
const auto &entry : list)
553 if (type == SkyObjectUserdata::Type::website)
555 i18nc(
"Image/info menu item (should be translated)",
557 ks->
map(), SLOT(slotInfo()));
560 i18nc(
"Image/info menu item (should be translated)",
562 ks->
map(), SLOT(slotImage()));
577 if (object->getCatalog().mut &&
578 manager.get_object(object->getObjectId()).first)
581 SLOT(slotRemoveCustomObject()));
598void KSPopupMenu::addINDI()
601 if (INDIListener::Instance()->
size() == 0)
604 for (
auto &oneDevice : INDIListener::devices())
606 if (!(oneDevice->getDriverInterface() & INDI::BaseDevice::TELESCOPE_INTERFACE))
610 auto mount = oneDevice->getMount();
614 QMenu *mountMenu =
new QMenu(mount->getDeviceName());
618 if (mount->canGoto() || mount->canSync())
620 if (mount->canGoto())
623 i18nc(
"Move mount to target",
"Goto"));
626 [mount] { mount->Slew(SkyMap::Instance()->clickedPoint()); });
628 if (
mount->canSync())
632 i18nc(
"Synchronize mount to target",
"Sync"));
635 [mount] {
mount->Sync(SkyMap::Instance()->clickedPoint()); });
641 if (
mount->canAbort())
650 if (
mount->canPark())
666 if (clickedObject && clickedObject->
type() == SkyObject::SATELLITE &&
667 (
mount->canTrackSatellite()))
676 [mount, sat, currentTime, currentTimePlusOne]
678 mount->setSatelliteTLEandTrack(sat->
tle(), currentTime,
684 if (
mount->canCustomPark())
687 i18n(
"Goto && Set As Parking Position"));
690 [mount] {
mount->setCustomParking(); });
696 [mount] {
mount->find(); });
701void KSPopupMenu::addFancyLabel(
const QString &name,
int deltaFontSize)
707 if (deltaFontSize != 0)
710 font.setPointSize(
font.pointSize() + deltaFontSize);
718void KSPopupMenu::slotViewInWI()
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
const CatalogsDB::Catalog getCatalog() const
Get information about the catalog that this objects stems from.
Manages the catalog database and provides an interface to provide an interface to query and modify th...
QString label(int index)
Get label.
QList< int > getFlagsNearPix(SkyPoint *point, int pixelRadius)
Get list of flag indexes near specified SkyPoint with radius specified in pixels.
QImage image(int index)
Get image.
Provides necessary information about the Moon.
QString phaseName() const
KStarsData is the backbone of KStars.
const SkyObjectUserdata::Data & getUserData(const QString &name)
Get a reference to the user data of an object with the name name.
const KStarsDateTime & ut() const
SkyMapComposite * skyComposite()
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
KStarsDateTime addSecs(double s) const
This is the main window for KStars.
static KStars * Instance()
void slotToggleWIView()
action slot: toggle What's Interesting window
KStarsData * data() const
bool contains(const SkyObject *o, bool session=false)
Represents an artificial satellites.
This is the canvas on which the sky is painted.
SkyObject * clickedObject() const
Retrieve the object nearest to a mouse click event.
bool isObjectLabeled(SkyObject *o)
void slotEditFlag(int flagIdx)
Open Flag Manager window with selected flag focused and ready to edit.
void slotDeleteFlag(int flagIdx)
Delete selected flag.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
virtual SkyObject * clone() const
Create copy of object.
QString translatedName() const
virtual QString name(void) const
QString translatedName2() const
QString translatedLongName() const
bool isSolarSystem() const
virtual QString longname(void) const
QTime transitTime(const KStarsDateTime &dt, const GeoLocation *geo) const
The same iteration technique described in riseSetTime() is used here.
QTime riseSetTime(const KStarsDateTime &dt, const GeoLocation *geo, bool rst, bool exact=true) const
Determine the time at which the point will rise or set.
static QString typeName(const int t)
The sky coordinates of a point in the sky.
const CachingDms & dec() const
const CachingDms & ra() const
void setAlt(dms alt)
Sets Alt, the Altitude.
void setAz(dms az)
Sets Az, the Azimuth.
This is a subclass of SkyObject.
QString name(void) const override
If star is unnamed return "star" otherwise return the name.
QString sptype(void) const
Returns entire spectral type string.
Represents the supernova object.
float getRedShift() const
provides a SkyObject with an attachable Trail
const double & Degrees() const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
KIOCORE_EXPORT SimpleJob * mount(bool ro, const QByteArray &fstype, const QString &dev, const QString &point, JobFlags flags=DefaultFlags)
QString name(StandardAction id)
QString label(StandardShortcut id)
void setData(const QVariant &data)
void triggered(bool checked)
iterator insert(const Key &key, const T &value)
T value(const Key &key) const const
QIcon fromTheme(const QString &name)
bool isEmpty() const const
qsizetype size() const const
QString toString(QDate date, FormatType format) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QPixmap fromImage(QImage &&image, Qt::ImageConversionFlags flags)
QString & append(QChar ch)
QString arg(Args &&... args) const const
bool isEmpty() const const
QString left(qsizetype n) const const
QString number(double n, char format, int precision)
QString & setNum(double n, char format, int precision)
qsizetype size() const const
QByteArray toLocal8Bit() const const
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QTime addSecs(int s) const const
bool isValid(int h, int m, int s, int ms)
QString name
The catalog mame.