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  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.useAltAz == m_previousViewParams.useAltAz
48  );
49  if (sameView && Options::isTracking() && SkyMap::IsFocused())
50  {
51  // We can draw the cache when two conditions are met.
52  // 1. It is not yet time to re-draw
53  // 2. Refresh time expired.
54  if (m_ElapsedTimer.elapsed() < HIPS_REDRAW_PERIOD && m_RefreshTimer.elapsed() > HIPS_REFRESH_PERIOD)
55  {
56  skyp->drawHips(true);
57  }
58  else
59  {
60  skyp->drawHips(false);
61  m_ElapsedTimer.restart();
62  }
63 
64  // If focus object changes, we reset fresh timer to force drawing of uncached image.
65  if (SkyMap::Instance()->focusObject() && SkyMap::Instance()->focusObject()->name() != m_LastFocusedObjectName)
66  {
67  m_LastFocusedObjectName = SkyMap::Instance()->focusObject()->name();
68  m_RefreshTimer.restart();
69  }
70  }
71  // When slewing or not tracking, render and draw immediately.
72  else
73  skyp->drawHips(false);
74 
75  m_previousViewParams = view;
76 #else
77  Q_UNUSED(skyp);
78 #endif
79 }
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
This is just a container that holds information needed to do projections.
Definition: projector.h:36
Draws things on the sky, without regard to backend.
Definition: skypainter.h:39
qint64 elapsed() const const
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Definition: skymap.h:262
HIPSComponent(SkyComposite *)
Constructor.
const Projector * projector() const
Get the current projector.
Definition: skymap.h:300
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-2023 The KDE developers.
Generated on Tue Sep 26 2023 03:55:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.