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 // We can draw the cache when two conditions are met.
53 // 1. It is not yet time to re-draw
54 // 2. Refresh time expired.
55 if (m_ElapsedTimer.elapsed() < HIPS_REDRAW_PERIOD && m_RefreshTimer.elapsed() > HIPS_REFRESH_PERIOD)
56 {
57 skyp->drawHips(true);
58 }
59 else
60 {
61 skyp->drawHips(false);
62 m_ElapsedTimer.restart();
63 }
64
65 // If focus object changes, we reset fresh timer to force drawing of uncached image.
66 if (SkyMap::Instance()->focusObject() && SkyMap::Instance()->focusObject()->name() != m_LastFocusedObjectName)
67 {
68 m_LastFocusedObjectName = SkyMap::Instance()->focusObject()->name();
69 m_RefreshTimer.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
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.
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
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 May 24 2024 11:49:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.