Stellarium  HEAD
Public Types | Public Slots | Public Member Functions | Protected Member Functions
AstroCalcChart Class Reference

This class extends QChart and encapsulates data for the Altitude vs. More...

#include <AstroCalcChart.hpp>

Public Types

enum  Series {
  AltVsTime , CurrentTime , TransitTime , SunElevation ,
  CivilTwilight , NauticalTwilight , AstroTwilight , Moon ,
  AzVsTime , MonthlyElevation , AngularSize1 , Declination1 ,
  Distance1 , Elongation1 , HeliocentricDistance1 , Magnitude1 ,
  PhaseAngle1 , Phase1 , RightAscension1 , TransitAltitude1 ,
  AngularSize2 , Declination2 , Distance2 , Elongation2 ,
  HeliocentricDistance2 , Magnitude2 , PhaseAngle2 , Phase2 ,
  RightAscension2 , TransitAltitude2 , LunarElongation , LunarElongationLimit ,
  pcDistanceAU , pcDistanceDeg
}
 

Public Slots

virtual void retranslate ()
 
void showToolTip (const QPointF &point, bool show)
 A slot to connect the hovered signal from a series to. More...
 

Public Member Functions

 AstroCalcChart (QSet< AstroCalcChart::Series > which)
 
void append (Series s, qint64 x, qreal y)
 Append one pair of data values to series s. x must be some QDateTime.toMSecsSinceEpoch()
 
void replace (Series s, int index, qreal x, qreal y)
 Replace one pair of data values to series s at position index.
 
void clear (Series s)
 Reset (delete and create new empty) series s.
 
int lengthOfSeries (Series s) const
 
void show (Series s)
 Activate series s. More...
 
void setYrange (Series series, qreal min, qreal max, bool strictMin=false)
 Set range of Y axis required by the Y values of series. More...
 
void setYrange (Series series, QPair< double, double > yRange, bool strictMin=false)
 Convenience function.
 
void setYrangeR (Series series, qreal min, qreal max)
 Set range of Y axis on the right side required by the Y values of series. Do not set buffers or logical limits here, these are determined in this function.
 
void setYrangeR (Series series, QPair< double, double > yRangeR)
 Convenience function.
 
QPair< double, double > findYRange (const Series series) const
 Find range of values for the respective series plot.
 
QPair< double, double > findYMax (const Series series) const
 Find x/y values where y=max for the respective series plot.
 
void setupAxes (const double jd, const int periods, const QString &englishName)
 Setup axes and appearance. More...
 
void drawTrivialLineX (Series s, const qreal x)
 Draw a 2-point vertical line at x which extends over the whole graph.
 
void drawTrivialLineY (Series s, const qreal y)
 Draw a 2-point horizontal line at y which extends over the whole graph.
 

Protected Member Functions

void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 Override. This sets the time from the click point to the main application.
 

Detailed Description

This class extends QChart and encapsulates data for the Altitude vs.

Time and the other line Charts in AstroCalcDialog. Most lines can be QSplineSeries, however the azimuth and magnitude lines must use QLineSeries to avoid a "spline tremor" at the 0/360° transition or where some moon enters the shadow of its planet.

Additional features:

The correct sequence of use:

The time coordinate is displayed using a QDateTimeAxis. Given slight differences between QDateTime and Stellarium's understanding of timezones etc., we must circumvent Qt's automatic handling of local timezones and work as if the time axis would display UTC dates, however, the actual data are in our own timezone frame. This requires manipulation of the x values: From the data which are computed in JD, plot them in UT+zoneOffset. Clicked time is delivered as "UT" and must add zoneOffset as well.

Note
We are using QDateTime here. Currently we have no handling for years before 1AD. Qt has no year zero, we have it. Qt time scaling may also show use pf Proleptic Gregorian calendars. We must expect to see a few weird dates before 1AD or even before 1582.

Member Function Documentation

◆ lengthOfSeries()

int AstroCalcChart::lengthOfSeries ( Series  s) const
Returns
length of series s. If chart does not contain s, returns -1.

◆ setupAxes()

void AstroCalcChart::setupAxes ( const double  jd,
const int  periods,
const QString &  englishName 
)

Setup axes and appearance.

Call this at the end of drawing, just before display but after all series have been activated with show().

  • englishName used for details in the two-graph charts. Use an empty string otherwise.

◆ setYrange()

void AstroCalcChart::setYrange ( Series  series,
qreal  min,
qreal  max,
bool  strictMin = false 
)

Set range of Y axis required by the Y values of series.

Do not set buffers or logical limits here, these are determined in this function.

  • strictMin: The altVsTime plot may require strict minimum setting without buffer. Use false (default) for other plots.

◆ show()

void AstroCalcChart::show ( Series  s)

Activate series s.

It must have been filled using append(s, ., .) before. Make sure to call setupAxes() after calling show!

◆ showToolTip

void AstroCalcChart::showToolTip ( const QPointF &  point,
bool  show 
)
slot

A slot to connect the hovered signal from a series to.

It shows the value of the series in a Tooltip on mouse-over.

Note
it only shows values of a point where the mouse is over. The vertical lines for "now" and "transit" are currently unavailable.