7#include "simplefovexporter.h"
10#include "kstarsdata.h"
12#include "skyqpainter.h"
14#include "skymapcomposite.h"
15#include "kstars/Options.h"
18 : m_KSData(
KStarsData::Instance()), m_Map(
KStars::Instance()->map()), m_StopClock(false), m_OverrideFovShape(false),
19 m_DrawFovSymbol(false), m_PrevClockState(false), m_PrevSlewing(false), m_PrevPoint(nullptr), m_PrevZoom(0)
26 pExportFov(point, fov, pd);
32 pExportFov(
nullptr, fov, pd);
43 int dx = (m_Map->width() - pd->
width()) / 2;
44 int dy = (m_Map->height() - pd->
height()) / 2;
47 m_KSData->skyComposite()->draw(&painter);
48 m_Map->getSkyMapDrawAbstract()->drawOverlays(painter,
false);
58 for (
int i = 0; i < points.
size(); i++)
68 Q_ASSERT(points.
size() == pds.
size());
72 for (
int i = 0; i < points.
size(); i++)
92 if (pd->
height() > m_Map->height() || pd->
width() > m_Map->width())
100 int regionX(0), regionY(0);
101 double fovSizeX(0), fovSizeY(0);
102 if (fov->sizeX() > fov->sizeY())
110 regionY = 0.5 * (pd->
height() - fovSizeY);
120 regionX = 0.5 * (pd->
width() - fovSizeX);
124 if (fov->shape() == FOV::SQUARE)
134 m_Map->setZoomFactor(zoom);
136 SkyQPainter painter(m_Map, pd);
139 painter.drawSkyBackground();
141 if (!m_OverrideFovShape)
143 painter.setClipRegion(region);
146 int dx = (m_Map->width() - pd->
width()) / 2;
147 int dy = (m_Map->height() - pd->
height()) / 2;
148 painter.translate(-dx, -dy);
150 m_KSData->skyComposite()->draw(&painter);
151 m_Map->getSkyMapDrawAbstract()->drawOverlays(painter,
false);
154 painter.resetTransform();
158 fov->
draw(painter, zoom);
162void SimpleFovExporter::saveState(
bool savePos)
165 m_PrevClockState = m_KSData->clock()->isActive();
166 if (m_StopClock && m_PrevClockState)
168 m_KSData->clock()->stop();
172 m_PrevSlewing = Options::useAnimatedSlewing();
175 Options::setUseAnimatedSlewing(
false);
179 m_PrevPoint = savePos ? m_Map->focusPoint() :
nullptr;
180 m_PrevZoom = Options::zoomFactor();
183void SimpleFovExporter::restoreState(
bool restorePos)
188 Options::setUseAnimatedSlewing(
true);
194 m_Map->setClickedPoint(m_PrevPoint);
198 m_Map->setZoomFactor(m_PrevZoom);
201 if (m_StopClock && m_PrevClockState)
203 m_KSData->clock()->start();
A simple class encapsulating a Field-of-View symbol.
void draw(QPainter &p, float zoomFactor)
draw the FOV symbol on a QPainter
KStarsData is the backbone of KStars.
This is the main window for KStars.
static double calculatePixelSize(float degrees, double zoomLevel)
Calculate pixel size of given angular length at given zoom level.
SimpleFovExporter()
Constructor.
static double calculateZoomLevel(int pixelSize, float degrees)
Calculate zoom level at which given angular length will occupy given length in pixels.
void exportFov(SkyPoint *point, FOV *fov, QPaintDevice *pd)
Paint FOV representation on passed QPaintDevice subclass.
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
void slotCenter()
Center the display at the point ClickedPoint.
The sky coordinates of a point in the sky.
The QPainter-based painting backend.
void drawSkyBackground() override
Draw the sky background.
void begin() override
Begin painting.
QAction * zoom(const QObject *recvr, const char *slot, QObject *parent)
const_reference at(qsizetype i) const const
qsizetype size() const const
T value(qsizetype i) const const
void translate(const QPoint &offset)