Kstars

shfovexporter.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Rafał Kułaga <rl.kulaga@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "Options.h"
8
9#include "shfovexporter.h"
10#include "starhopper.h"
11#include "targetlistcomponent.h"
12#include "kstarsdata.h"
13#include "skymapcomposite.h"
14#include "skymap.h"
15#include "printingwizard.h"
16
17ShFovExporter::ShFovExporter(PrintingWizard *wizard, SkyMap *map) : m_Map(map), m_ParentWizard(wizard)
18{
19}
20
21bool ShFovExporter::calculatePath(const SkyPoint &src, const SkyPoint &dest, double fov, double maglim)
22{
23 m_Src = src;
24 m_Dest = dest;
25
26 auto list = m_StarHopper.computePath(src, dest, fov, maglim);
27 m_skyObjList = KSUtils::castStarObjListToSkyObjList(list);
28 delete list;
29
30 m_Path = *m_skyObjList;
31 if (m_Path.isEmpty())
32 {
33 return false;
34 }
35
36 return true;
37}
38
40{
41 KStarsData::Instance()->clock()->stop();
42
43 if (m_Path.isEmpty())
44 {
45 return false;
46 }
47
48 // Show path on SkyMap
49 TargetListComponent *t = KStarsData::Instance()->skyComposite()->getStarHopRouteList();
50
51 t->list.reset(m_skyObjList);
52
53 // Update SkyMap now
54 m_Map->forceUpdate(true);
55
56 // Capture FOV snapshots
57 centerBetweenAndCapture(m_Src, *m_Path.at(0));
58 for (int i = 0; i < m_Path.size() - 1; i++)
59 {
60 centerBetweenAndCapture(*m_Path.at(i), *m_Path.at(i + 1));
61 }
62 centerBetweenAndCapture(*m_Path.last(), m_Dest);
63
64 return true;
65}
66
67void ShFovExporter::centerBetweenAndCapture(const SkyPoint &ptA, const SkyPoint &ptB)
68{
69 // Calculate RA and Dec coordinates of point between ptA and ptB
70 dms ra(ptA.ra().Degrees() + 0.5 * (ptB.ra().Degrees() - ptA.ra().Degrees()));
71 dms dec(ptA.dec().Degrees() + 0.5 * (ptB.dec().Degrees() - ptA.dec().Degrees()));
72 SkyPoint between(ra, dec);
73
74 // Center SkyMap
75 m_Map->setClickedPoint(&between);
76 m_Map->slotCenter();
77
78 // Capture FOV snapshot
79 m_ParentWizard->captureFov();
80}
Class representing Printing Wizard for KStars printed documents (currently only finder charts).
void captureFov()
Capture current contents of FOV symbol.
bool calculatePath(const SkyPoint &src, const SkyPoint &dest, double fov, double maglim)
Calculate path between source and destination SkyPoints.
bool exportPath()
Export FOV snapshots across calculated path.
ShFovExporter(PrintingWizard *wizard, SkyMap *map)
Constructor.
This is the canvas on which the sky is painted.
Definition skymap.h:54
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition skymap.cpp:1012
void forceUpdate(bool now=false)
Recalculates the positions of objects in the sky, and then repaints the sky map.
Definition skymap.cpp:1177
void slotCenter()
Center the display at the point ClickedPoint.
Definition skymap.cpp:380
The sky coordinates of a point in the sky.
Definition skypoint.h:45
QList< StarObject * > * computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__, QStringList *metadata_=nullptr)
Computes path for Star Hop.
Highlights objects present in certain lists by drawing "target" symbols around them.
std::unique_ptr< SkyObjectList > list
Pointer to list of objects to draw.
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
const_reference at(qsizetype i) const const
bool isEmpty() const const
T & last()
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.