Public Member Functions | Protected Member Functions

PlotTracker Class Reference

#include <PlotTracker.h>

Inheritance diagram for PlotTracker:
Inheritance graph
[legend]
Collaboration diagram for PlotTracker:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PlotTracker (QwtPlotCanvas *canvas)
virtual ~PlotTracker ()
void enableDateTracker (bool flag)
void setBaseDate (QDate date)
void enableDateTimeTracker (bool flag)
void setBaseDateTime (QDateTime dateTime)

Protected Member Functions

virtual QwtText trackerText (const QwtDoublePoint &pos) const

Constructor & Destructor Documentation

PlotTracker::PlotTracker ( QwtPlotCanvas canvas  ) 

  : QwtPlotPicker( canvas )
{
  //qDebug( "PlotTracker::PlotTracker" );

  setTrackerMode( QwtPicker::AlwaysOn );

  m_dateTrackerEnabled = false;
  m_dateTimeTrackerEnabled = false;
}

PlotTracker::~PlotTracker (  )  [virtual]

{
  //qDebug( "PlotTracker::~PlotTracker" );
}


Member Function Documentation

void PlotTracker::enableDateTimeTracker ( bool  flag  )  [inline]
void PlotTracker::enableDateTracker ( bool  flag  )  [inline]
void PlotTracker::setBaseDate ( QDate  date  )  [inline]

Referenced by PlotWidget::setAxisDate().

{ m_baseDate = date; };

void PlotTracker::setBaseDateTime ( QDateTime  dateTime  )  [inline]

Referenced by PlotWidget::setAxisDateTime().

{ m_baseDateTime = dateTime; };

QwtText PlotTracker::trackerText ( const QwtDoublePoint &  pos  )  const [protected, virtual]

Reimplemented from QwtPlotPicker.

{
  //qDebug( "PlotTracker::trackerText" );

  QString text;

  // No date set or classic tracker
  if ( m_dateTrackerEnabled == false && m_dateTimeTrackerEnabled == false )
  {
    switch( rubberBand() )
    {
      case HLineRubberBand:
        text.sprintf( "%.4f", pos.y() );
        break;
      case VLineRubberBand:
        text.sprintf( "%.4f", pos.x() );
        break;
      default:
      {
        if ( plot()->axisEnabled( QwtPlot::yRight ) == true )
        {
          double rightAxisValue = plot()->invTransform( QwtPlot::yRight, plot()->transform(
              QwtPlot::yLeft, pos.y() ) );
          text.sprintf( "%.4f\n<- %.4f\n%.4f ->", pos.x(), pos.y(), rightAxisValue );
        }
        else
        {
          text.sprintf( "%.4f\n%.4f", pos.x(), pos.y() );
        }
      }
    }
  }
  else
  {
    QString dateTimeString;
    if ( m_dateTrackerEnabled == true )
    {
      // Date tracker
      QDate thisDate = m_baseDate.addDays( ( int )( floor( pos.x() / 86400.0 ) ) );
      dateTimeString = thisDate.toString( QLocale::system().dateFormat( QLocale::ShortFormat ) );
    }
    else
    {
      // DateTime tracker
      QDateTime thisDateTime = m_baseDateTime.addSecs( ( int )pos.x() );
      dateTimeString = thisDateTime.toString( QLocale::system().dateFormat( QLocale::ShortFormat )
                                              + " " + QLocale::system().timeFormat( QLocale::ShortFormat ) );
    }
    switch( rubberBand() )
    {
      case HLineRubberBand:
        text.sprintf( "%.4f", pos.y() );
        break;
      case VLineRubberBand:
        text = dateTimeString;
        break;
      default:
      {
        if ( plot()->axisEnabled( QwtPlot::yRight ) == true )
        {
          double rightAxisValue = plot()->invTransform( QwtPlot::yRight, plot()->transform( QwtPlot::yLeft, pos.y() ) );
          text = dateTimeString + "\n<- " + QString::number( pos.y() ) + "\n" + QString::number( rightAxisValue ) + " ->";
        }
        else
        {
          text = dateTimeString + "\n" + QString::number( pos.y() );
        }
      }
    }
  }
  return QwtText( text );
}


The documentation for this class was generated from the following files: