vtkQtChartMouseBox Class Reference

#include <vtkQtChartMouseBox.h>

List of all members.


Detailed Description

The vtkQtChartMouseBox class is used to draw a mouse box that can be used for zooming or selection.

To use the vtkQtChartMouseBox, code needs to be added to several key methods. The drag box interaction starts in the mouse press event. The box grows or shrinks in the mouse move event. In the mouse release event, the box is finalized and used for its intent (zoom, select, etc.).

In the mouse press event, the mouse location needs to be saved. The position should be in the mouse box's parent coordinates.

  void SomeClass::mousePressEvent(QMouseEvent *e)
  {
    this->mouseBox->setStartingPosition(e->pos());
    this->mouseBox->setVisible(true);
  }

In the mouse move event, the drag box needs to be updated. The point set in the mouse press event should remain unchanged until the mouse release event. If your class watches all mouse move events, make sure the box is only updated for drag events.

  void SomeClass::mouseMoveEvent(QMouseEvent *e)
  {
    this->mouseBox->adjustRectangle(e->pos());
  }

In the mouse release event, the drag box needs to be updated with the release location before using it. After using the box, it should be hidden.

  void SomeClass::mouseReleaseEvent(QMouseEvent *e)
  {
    this->mouseBox->adjustRectangle(e->pos());
    ...
    this->mouseBox->setVisible(false);
  }

Definition at line 82 of file vtkQtChartMouseBox.h.


Signals

void updateNeeded (const QRectF &area)

Public Member Functions

 vtkQtChartMouseBox (QGraphicsView *view)
 ~vtkQtChartMouseBox ()
bool isVisible () const
 Gets whether or not the mouse box is visible.
void setVisible (bool visible)
 Sets whether or not the mouse box is visible.
const QPointF & getStartingPosition () const
 Gets the mouse box starting position.
void setStartingPosition (const QPoint &start)
 Sets the mouse box starting position.
void adjustRectangle (const QPoint &current)
 Adjusts the boundary of the mouse box.
const QRectF & getRectangle () const
 Gets the current mouse box.

Constructor & Destructor Documentation

vtkQtChartMouseBox::vtkQtChartMouseBox ( QGraphicsView *  view  ) 

vtkQtChartMouseBox::~vtkQtChartMouseBox (  ) 


Member Function Documentation

bool vtkQtChartMouseBox::isVisible (  )  const [inline]

Gets whether or not the mouse box is visible.

Returns:
True if the mouse box should be painted.

Definition at line 94 of file vtkQtChartMouseBox.h.

void vtkQtChartMouseBox::setVisible ( bool  visible  ) 

Sets whether or not the mouse box is visible.

Parameters:
visible True if the mouse box should be painted.

const QPointF& vtkQtChartMouseBox::getStartingPosition (  )  const

Gets the mouse box starting position.

Returns:
A reference to the mouse box starting position.

void vtkQtChartMouseBox::setStartingPosition ( const QPoint &  start  ) 

Sets the mouse box starting position.

The starting position should be set before calling adjustRectangle. The starting position and adjustment positions should be in view coordinates.

Parameters:
start The original mouse press location in view coordinates.
See also:
vtkQtChartMouseBox::adjustRectangle(const QPointF &)

void vtkQtChartMouseBox::adjustRectangle ( const QPoint &  current  ) 

Adjusts the boundary of the mouse box.

The selection or zoom box should contain the original mouse down location and the current mouse location. This method is used to adjust the box based on the current mouse location.

Parameters:
current The current position of the mouse in view coordinates.

const QRectF& vtkQtChartMouseBox::getRectangle (  )  const

Gets the current mouse box.

Returns:
A reference to the mouse box.

void vtkQtChartMouseBox::updateNeeded ( const QRectF &  area  )  [signal]


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

Generated on Wed Aug 24 11:59:44 2011 for VTK by  doxygen 1.5.6