Public Member Functions

PlotArea Class Reference

#include <PlotArea.h>

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

List of all members.

Public Member Functions

 PlotArea ()
virtual ~PlotArea ()
Type type () const
void setBrush (QBrush brush)
QBrush brush () const
void setRect (double xLowerBound, double yLowerBound, double xUpperBound, double yUpperBound)
QRectF rect () const
void setXInterval (double lowerBound, double upperBound)
double xIntervalLowerBound () const
double xIntervalUpperBound () const
void setYInterval (double lowerBound, double upperBound)
double yIntervalLowerBound () const
double yIntervalUpperBound () const
virtual int rtti () const
virtual void draw (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &canvasRect) const

Constructor & Destructor Documentation

PlotArea::PlotArea (  ) 

  : QwtPlotItem( QwtText( "Area" ) )
{
  //qDebug( "PlotArea::PlotArea" );

  m_type = PlotArea::Rect;
  m_brush = QBrush( QColor( 255, 0, 0, 128 ) );
  m_xIntervalLowerBound = 0.0;
  m_xIntervalUpperBound = 0.0;
  m_yIntervalLowerBound = 0.0;
  m_yIntervalUpperBound = 0.0;

  setZ( 1000 );
}

PlotArea::~PlotArea (  )  [virtual]

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


Member Function Documentation

QBrush PlotArea::brush (  )  const [inline]

Referenced by PlotSelector::selectionBrush().

{ return m_brush; }

void PlotArea::draw ( QPainter painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRect canvasRect 
) const [virtual]

Reimplemented from QwtPlotItem.

{
  //qDebug( "PlotArea::draw" );

  painter->setBrush( m_brush );
  painter->setPen( QPen( Qt::NoPen ) );

  // Initial situation, don't draw
  if ( m_xIntervalLowerBound == 0.0
       && m_xIntervalUpperBound == 0.0
       && m_yIntervalLowerBound == 0.0
       && m_yIntervalUpperBound == 0.0 )
  {
    return;
  }

  if ( m_type == PlotArea::Rect )
  {
    int topLeftX = xMap.transform( m_rect.x() );
    int topLeftY = yMap.transform( m_rect.y() );
    int bottomRightX = xMap.transform( m_rect.bottomRight().x() );
    int bottomRightY = yMap.transform( m_rect.bottomRight().y() );
    // Always draw at least one pixel
    if ( topLeftX == bottomRightX )
    {
      bottomRightX += 1;
    }
    if ( topLeftY == bottomRightY )
    {
      bottomRightY += 1;
    }
    QRect rect( topLeftX, topLeftY, bottomRightX - topLeftX, topLeftY - bottomRightY );
    QwtPainter::drawRect( painter, rect );
  }
  else if ( m_type == PlotArea::XInterval )
  {
    int topLeftX = xMap.transform( m_xIntervalLowerBound );
    int bottomRightX = xMap.transform( m_xIntervalUpperBound );
    // Always draw at least one pixel
    if ( topLeftX == bottomRightX )
    {
      bottomRightX += 1;
    }
    QRect rect( topLeftX, canvasRect.y(), bottomRightX - topLeftX, canvasRect.height() );
    QwtPainter::drawRect( painter, rect );
  }
  else if ( m_type == PlotArea::YInterval )
  {
    int topLeftY = yMap.transform( m_yIntervalLowerBound );
    int bottomRightY = yMap.transform( m_yIntervalUpperBound );
    // Always draw at least one pixel
    if ( topLeftY == bottomRightY )
    {
      bottomRightY += 1;
    }
    QRect rect( canvasRect.y(), topLeftY, canvasRect.width(), bottomRightY - topLeftY );
    QwtPainter::drawRect( painter, rect );
  }
}

QRectF PlotArea::rect (  )  const [inline]

Referenced by draw(), and PlotSelector::rect().

{ return m_rect; }

int PlotArea::rtti (  )  const [virtual]

Reimplemented from QwtPlotItem.

{
  //qDebug( "PlotArea::rtti" );

  // Would have been better to append a type to the RttiValues enum
  return QwtPlotItem::Rtti_PlotUserItem + 1;
}

void PlotArea::setBrush ( QBrush  brush  )  [inline]

Referenced by PlotSelector::setSelectionBrush().

{ m_brush = brush; }

void PlotArea::setRect ( double  xLowerBound,
double  yLowerBound,
double  xUpperBound,
double  yUpperBound 
)

Referenced by PlotSelector::eventFilter().

{
  //qDebug( "PlotArea::setRect" );

  m_type = PlotArea::Rect;

  if ( xLowerBound > xUpperBound )
  {
    double temp = xLowerBound;
    xLowerBound = xUpperBound;
    xUpperBound = temp;
  }
  if ( yLowerBound > yUpperBound )
  {
    double temp = yLowerBound;
    yLowerBound = yUpperBound;
    yUpperBound = temp;
  }

  m_rect = QRectF( xLowerBound, yUpperBound,
                   xUpperBound - xLowerBound, yUpperBound - yLowerBound );
}

void PlotArea::setXInterval ( double  lowerBound,
double  upperBound 
)

Referenced by PlotSelector::eventFilter().

{
  //qDebug( "PlotArea::setXInterval" );

  m_type = PlotArea::XInterval;

  if ( lowerBound < upperBound )
  {
    m_xIntervalLowerBound = lowerBound;
    m_xIntervalUpperBound = upperBound;
  }
  else
  {
    m_xIntervalLowerBound = upperBound;
    m_xIntervalUpperBound = lowerBound;
  }
}

void PlotArea::setYInterval ( double  lowerBound,
double  upperBound 
)

Referenced by PlotSelector::eventFilter().

{
  //qDebug( "PlotArea::setYInterval" );

  m_type = PlotArea::YInterval;

  if ( lowerBound < upperBound )
  {
    m_yIntervalLowerBound = lowerBound;
    m_yIntervalUpperBound = upperBound;
  }
  else
  {
    m_yIntervalLowerBound = upperBound;
    m_yIntervalUpperBound = lowerBound;
  }
}

Type PlotArea::type (  )  const [inline]

{ return m_type; }

double PlotArea::xIntervalLowerBound (  )  const [inline]

Referenced by PlotSelector::xIntervalLowerBound().

{ return m_xIntervalLowerBound; }

double PlotArea::xIntervalUpperBound (  )  const [inline]

Referenced by PlotSelector::xIntervalUpperBound().

{ return m_xIntervalUpperBound; }

double PlotArea::yIntervalLowerBound (  )  const [inline]

Referenced by PlotSelector::yIntervalLowerBound().

{ return m_yIntervalLowerBound; }

double PlotArea::yIntervalUpperBound (  )  const [inline]

Referenced by PlotSelector::yIntervalUpperBound().

{ return m_yIntervalUpperBound; }


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