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 <[email protected]>
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  double newZoom = Options::zoomFactor();
42  if (std::abs(newZoom - m_LastZoom) == 0. && Options::isTracking() && SkyMap::IsFocused())
43  {
44  // We can draw the cache when two conditions are met.
45  // 1. It is not yet time to re-draw
46  // 2. Refresh time expired.
47  if (m_ElapsedTimer.elapsed() < HIPS_REDRAW_PERIOD && m_RefreshTimer.elapsed() > HIPS_REFRESH_PERIOD)
48  {
49  skyp->drawHips(true);
50  }
51  else
52  {
53  skyp->drawHips(false);
54  m_ElapsedTimer.restart();
55  }
56 
57  // If focus object changes, we reset fresh timer to force drawing of uncached image.
58  if (SkyMap::Instance()->focusObject() && SkyMap::Instance()->focusObject()->name() != m_LastFocusedObjectName)
59  {
60  m_LastFocusedObjectName = SkyMap::Instance()->focusObject()->name();
61  m_RefreshTimer.restart();
62  }
63  }
64  // When slewing or not tracking, render and draw immediately.
65  else
66  skyp->drawHips(false);
67 
68  m_LastZoom = newZoom;
69 #else
70  Q_UNUSED(skyp);
71 #endif
72 }
virtual QString name(void) const
Definition: skyobject.h:145
virtual bool drawHips(bool useCache=false)=0
drawMosaicPanel Draws mosaic panel in planning or operation mode.
qint64 restart()
bool selected() override
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
qint64 elapsed() const const
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Definition: skymap.h:261
HIPSComponent(SkyComposite *)
Constructor.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 8 2022 04:13:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.