Kstars

shfovexporter.cpp
1 /*
2  SPDX-FileCopyrightText: 2011 Rafał Kułaga <[email protected]>
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 
17 ShFovExporter::ShFovExporter(PrintingWizard *wizard, SkyMap *map) : m_Map(map), m_ParentWizard(wizard)
18 {
19 }
20 
21 bool 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 
67 void 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 }
ShFovExporter(PrintingWizard *wizard, SkyMap *map)
Constructor.
Class representing Printing Wizard for KStars printed documents (currently only finder charts).
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition: skymap.cpp:996
bool exportPath()
Export FOV snapshots across calculated path.
QList< StarObject * > * computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__, QStringList *metadata_=nullptr)
Computes path for Star Hop.
Definition: starhopper.cpp:16
int size() const const
bool calculatePath(const SkyPoint &src, const SkyPoint &dest, double fov, double maglim)
Calculate path between source and destination SkyPoints.
const CachingDms & dec() const
Definition: skypoint.h:269
const T & at(int i) const const
Q_INVOKABLE SimClock * clock()
Definition: kstarsdata.h:217
bool isEmpty() const const
Q_SCRIPTABLE Q_NOREPLY void stop()
DBUS function to stop the SimClock.
Definition: simclock.cpp:104
T & last()
void slotCenter()
Center the display at the point ClickedPoint.
Definition: skymap.cpp:345
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:165
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
const CachingDms & ra() const
Definition: skypoint.h:263
const double & Degrees() const
Definition: dms.h:141
Highlights objects present in certain lists by drawing "target" symbols around them.
Canvas widget for displaying the sky bitmap; also handles user interaction events.
Definition: skymap.h:52
void forceUpdate(bool now=false)
Recalculates the positions of objects in the sky, and then repaints the sky map.
Definition: skymap.cpp:1186
void captureFov()
Capture current contents of FOV symbol.
std::unique_ptr< SkyObjectList > list
Pointer to list of objects to draw.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.