Kstars

hipscomponent.cpp
1/* HiPS : Hierarchical Progressive Surveys
2 HiPS is the hierarchical tiling mechanism which allows one to access, visualize and browse seamlessly image, catalogue and cube data.
3
4 The KStars HiPS compoenent is used to load and overlay progress surveys from various online catalogs.
5
6 SPDX-FileCopyrightText: 2017 Jasem Mutlaq <mutlaqja@ikarustech.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#include "hipscomponent.h"
12
13#include "Options.h"
14#include "skypainter.h"
15#include "skymap.h"
16
18{
19 m_ElapsedTimer.start();
20 m_RefreshTimer.start();
21}
22
24{
25 return Options::showHIPS();
26}
27
29{
30
31#if !defined(KSTARS_LITE)
32 if ( (SkyMap::IsSlewing() && !Options::hIPSPanning()) || !selected())
33 return;
34
35 // If we are tracking and we currently have a focus object or point
36 // Then no need for re-render every update cycle since that is CPU intensive
37 // Draw the cached HiPS image for 5000ms. When this expires, render the image again and
38 // restart the timer.
39
40 // Keep track of zoom level and redraw if changes.
41 ViewParams view = SkyMap::Instance()->projector()->viewParams();
42 bool sameView = (
43 view.width == m_previousViewParams.width &&
44 view.height == m_previousViewParams.height &&
45 view.zoomFactor == m_previousViewParams.zoomFactor &&
46 view.rotationAngle == m_previousViewParams.rotationAngle &&
47 view.mirror == m_previousViewParams.mirror &&
48 view.useAltAz == m_previousViewParams.useAltAz
49 );
50 if (sameView && Options::isTracking() && SkyMap::IsFocused())
51 {
52 // If focus object changes, we reset fresh timer to force drawing of uncached image.
53 if (SkyMap::Instance()->focusObject() && SkyMap::Instance()->focusObject()->name() != m_LastFocusedObjectName)
54 {
55 m_LastFocusedObjectName = SkyMap::Instance()->focusObject()->name();
56 m_RefreshTimer.restart();
57 }
58
59 // We can draw the cache when two conditions are met.
60 // 1. It is not yet time to re-draw
61 // 2. Refresh time expired.
62 if (m_ElapsedTimer.elapsed() < HIPS_REDRAW_PERIOD && m_RefreshTimer.elapsed() > HIPS_REFRESH_PERIOD)
63 {
64 skyp->drawHips(true);
65 }
66 else
67 {
68 skyp->drawHips(false);
69 m_ElapsedTimer.restart();
70 }
71 }
72 // When slewing or not tracking, render and draw immediately.
73 else
74 skyp->drawHips(false);
75
76 m_previousViewParams = view;
77#else
78 Q_UNUSED(skyp);
79#endif
80}
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
HIPSComponent(SkyComposite *)
Constructor.
bool selected() override
SkyComponent represents an object on the sky map.
SkyComposite is a kind of container class for SkyComponent objects.
const Projector * projector() const
Get the current projector.
Definition skymap.h:300
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Definition skymap.h:262
virtual QString name(void) const
Definition skyobject.h:146
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
virtual bool drawHips(bool useCache=false)=0
drawMosaicPanel Draws mosaic panel in planning or operation mode.
This is just a container that holds information needed to do projections.
Definition projector.h:37
qint64 elapsed() const const
qint64 restart()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.