Avogadro
1.1.0
|
Generic data plotting widget. More...
#include <avogadro/plotwidget.h>
Public Types | |
enum | Axis { LeftAxis = 0, BottomAxis, RightAxis, TopAxis } |
enum | Direction { None = 0, Left, Down, Right, Up } |
Public Slots | |
void | setShowGrid (bool show) |
void | setObjectToolTipShown (bool show) |
bool | saveImage (const QString &filename, double width, double height, double dpi, bool optimizeFontSize) |
void | selectPoint (PlotPoint *point) |
void | selectPoints (const QList< PlotPoint * > &points) |
void | clearAndSelectPoint (PlotPoint *point) |
void | clearAndSelectPoints (const QList< PlotPoint * > &points) |
void | clearSelection () |
void | setPointFollowMouse (bool b) |
void | setJailedInDefaults (bool b) |
void | setLabelShiftDirection (Direction dir, float priority=2.0) |
Signals | |
void | pointClicked (double x, double y) |
void | pointClicked (const QList< PlotPoint * > &pl) |
void | pointClicked (PlotPoint *) |
void | mouseOverPoint (double x, double y) |
Public Member Functions | |
PlotWidget (QWidget *parent=0) | |
Constructor. | |
virtual | ~PlotWidget () |
Destructor. | |
virtual QSize | minimumSizeHint () const |
virtual QSize | sizeHint () const |
void | setLimits (double x1, double x2, double y1, double y2) |
void | setLimits (QRectF &rect) |
void | scaleLimits (PlotObject *po=NULL) |
void | setDefaultLimits (double x1, double x2, double y1, double y2) |
void | setDefaultLimits (QRectF &rect) |
void | unsetDefaultLimits () |
void | setSecondaryLimits (double x1, double x2, double y1, double y2) |
Reset the secondary data limits, which control the values displayed along the top and right axes. | |
void | clearSecondaryLimits () |
QRectF | dataRect () const |
QRectF | defaultDataRect () const |
QRectF | secondaryDataRect () const |
QRect | pixRect () const |
void | addPlotObject (PlotObject *object) |
void | addPlotObjects (const QList< PlotObject * > &objects) |
QList< PlotObject * > | plotObjects () const |
void | removeAllPlotObjects () |
void | resetPlotMask () |
void | resetPlot () |
void | replacePlotObject (int i, PlotObject *o) |
QColor | backgroundColor () const |
QColor | foregroundColor () const |
QColor | gridColor () const |
void | setBackgroundColor (const QColor &bg) |
void | setForegroundColor (const QColor &fg) |
void | setGridColor (const QColor &gc) |
void | setFontSize (int pointSize) |
void | setFont (QFont font) |
QFont | getFont () |
bool | isGridShown () const |
bool | isObjectToolTipShown () const |
bool | antialiasing () const |
void | setAntialiasing (bool b) |
int | leftPadding () const |
int | rightPadding () const |
int | topPadding () const |
int | bottomPadding () const |
void | setLeftPadding (int padding) |
Set the number of pixels to the left of the plot area. Set this to -1 to revert to automatic determination of padding values. | |
void | setRightPadding (int padding) |
Set the number of pixels to the right of the plot area. Set this to -1 to revert to automatic determination of padding values. | |
void | setTopPadding (int padding) |
Set the number of pixels above the plot area. Set this to -1 to revert to automatic determination of padding values. | |
void | setBottomPadding (int padding) |
Set the number of pixels below the plot area. Set this to -1 to revert to automatic determination of padding values. | |
void | setDefaultPaddings () |
Revert all four padding values to -1, so that they will be automatically determined. | |
QPointF | mapToWidget (const QPointF &p) const |
Map a coordinate. | |
QPointF | mapToData (const QPointF &p) const |
Map a coordinate. | |
QPointF | mapFrameToData (const QPointF &p) const |
Map a coordinate. | |
void | maskRect (const QRectF &r, float value=1.0) |
void | maskAlongLine (const QPointF &p1, const QPointF &p2, float value=1.0) |
void | placeLabel (QPainter *painter, PlotPoint *pp) |
PlotAxis * | axis (Axis type) |
const PlotAxis * | axis (Axis type) const |
Protected Member Functions | |
virtual bool | event (QEvent *) |
virtual void | mouseMoveEvent (QMouseEvent *event) |
virtual void | mousePressEvent (QMouseEvent *event) |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) |
virtual void | mouseReleaseEvent (QMouseEvent *event) |
virtual void | wheelEvent (QWheelEvent *event) |
virtual void | paintEvent (QPaintEvent *) |
virtual void | resizeEvent (QResizeEvent *) |
virtual void | drawAxes (QPainter *p) |
void | setPixRect () |
QList< PlotPoint * > | pointsUnderPoint (const QPoint &p) const |
PlotPoint * | pointNearestPoint (const QPoint &p) const |
Properties | |
int | leftPadding |
int | rightPadding |
int | topPadding |
int | bottomPadding |
QColor | backgroundColor |
QColor | foregroundColor |
QColor | gridColor |
bool | grid |
bool | objectToolTip |
Generic data plotting widget.
*Widget for drawing plots. The basic idea behind PlotWidget is that *you don't have to worry about any transformation from your data's *natural units to screen pixel coordinates; this is handled internally *by the widget. *Data to be plotted are represented by one or more instances of *PlotObject. PlotObject contains a list of QPointFs to be plotted
(again, in the data's natural units), as well as information about how *the data are to be rendered in the plot (i.e., as separate points or *connected by lines? With what color and point style? etc). See *PlotObject for more information.
*PlotWidget automatically adds axis labels with tickmarks and tick *labels. These are encapsulated in the PlotAxis class. All you have *to do is set the limits of the plotting area in data units, and *PlotWidget wil figure out the optimal positions and labels for the *tickmarks on the axes.
*Use setDefaultLimits() to set the limits that a double click will restore. *This will also call setLimits() to update the plot. Not using *setDefaultLimits() or calling unsetDefaultLimits() will disable double *click.restoration.
*Example of usage:
PlotWidget *kpw = new PlotWidget( parent ); // setting our limits for the plot kpw->setDefaultLimits( 1.0, 5.0, 1.0, 25.0 ); // creating a plot object whose points are connected by red lines ... PlotObject *kpo = new PlotObject( Qt::red, PlotObject::Lines ); // ... adding some points to it ... for ( float x = 1.0; x <= 5.0; x += 0.1 ) kpo->addPoint( x, x*x ); // ... and adding the object to the plot widget kpw->addPlotObject( kpo );
The four directions for label shift.
Avogadro::PlotWidget::PlotWidget | ( | QWidget * | parent = 0 | ) | [explicit] |
Constructor.
parent | the parent widget |
References minimumSizeHint(), QWidget::resize(), QWidget::setAttribute(), setDefaultPaddings(), and QWidget::setMinimumSize().
void Avogadro::PlotWidget::addPlotObject | ( | PlotObject * | object | ) |
Add an item to the list of PlotObjects to be plotted.
object | the PlotObject to be added |
References QWidget::update().
void Avogadro::PlotWidget::addPlotObjects | ( | const QList< PlotObject * > & | objects | ) |
Add more than one PlotObject at one time.
objects | the list of PlotObjects to be added |
References QWidget::update().
bool Avogadro::PlotWidget::antialiasing | ( | ) | const |
PlotAxis * Avogadro::PlotWidget::axis | ( | Axis | type | ) |
type
, or 0 if no axis has been set. References QHash::value().
Referenced by clearSecondaryLimits(), drawAxes(), resetPlot(), saveImage(), and setSecondaryLimits().
const PlotAxis * Avogadro::PlotWidget::axis | ( | Axis | type | ) | const |
type
, or 0 if no axis has been set. References QHash::value().
QColor Avogadro::PlotWidget::backgroundColor | ( | ) | const |
The default color is black.
Referenced by paintEvent(), and saveImage().
int Avogadro::PlotWidget::bottomPadding | ( | ) | const |
Referenced by drawAxes(), and setPixRect().
void Avogadro::PlotWidget::clearAndSelectPoint | ( | PlotPoint * | point | ) | [slot] |
Just like selectPoint(), but clears selection first.
point | PlotPoint to be highlighted |
References clearSelection(), QWidget::update(), Avogadro::PlotPoint::x(), and Avogadro::PlotPoint::y().
void Avogadro::PlotWidget::clearAndSelectPoints | ( | const QList< PlotPoint * > & | points | ) | [slot] |
Just like selectPoints(), but clears selection first.
points | QList of PlotPoints to be highlighted |
References QList::at(), clearSelection(), QList::size(), and QWidget::update().
Unset the secondary limits, so the top and right axes show the same tickmarks as the bottom and left axes (no tickmark labels will be drawn for the top and right axes in this case)
References axis(), RightAxis, Avogadro::PlotAxis::setTickMarks(), TopAxis, and QWidget::update().
Referenced by resetPlot().
void Avogadro::PlotWidget::clearSelection | ( | ) | [slot] |
Clear out the selected points
References QWidget::update().
Referenced by clearAndSelectPoint(), and clearAndSelectPoints().
QRectF Avogadro::PlotWidget::dataRect | ( | ) | const |
Referenced by mouseMoveEvent(), mouseReleaseEvent(), and wheelEvent().
QRectF Avogadro::PlotWidget::defaultDataRect | ( | ) | const |
Referenced by mouseDoubleClickEvent(), mouseMoveEvent(), setJailedInDefaults(), and unsetDefaultLimits().
void Avogadro::PlotWidget::drawAxes | ( | QPainter * | p | ) | [protected, virtual] |
Draws the plot axes and axis labels.
References Avogadro::PlotAxis::areTickLabelsShown(), axis(), BottomAxis, bottomPadding(), QPainter::drawLine(), QPainter::drawText(), foregroundColor(), gridColor(), QRectF::height(), QRect::height(), QString::isEmpty(), Avogadro::PlotAxis::isVisible(), Avogadro::PlotAxis::label(), LeftAxis, leftPadding(), Avogadro::PlotAxis::majorTickMarks(), Avogadro::PlotAxis::minorTickMarks(), QWidget::palette(), pixRect(), QPainter::restore(), RightAxis, QPainter::rotate(), QPainter::save(), secondaryDataRect(), QPainter::setBrush(), QPainter::setClipping(), QPalette::setColor(), QWidget::setGeometry(), QPainter::setPen(), Avogadro::PlotAxis::tickLabel(), TopAxis, QPainter::translate(), QRect::width(), QRectF::width(), QRectF::x(), and QRectF::y().
Referenced by paintEvent().
bool Avogadro::PlotWidget::event | ( | QEvent * | e | ) | [protected, virtual] |
Generic event handler.
Reimplemented from QFrame.
References QEvent::accept(), QWidget::contentsRect(), QList::count(), QList::front(), QHelpEvent::globalPos(), leftPadding(), pointsUnderPoint(), QHelpEvent::pos(), QToolTip::showText(), QRect::topLeft(), topPadding(), and QEvent::type().
QColor Avogadro::PlotWidget::foregroundColor | ( | ) | const |
The default color is white.
Referenced by drawAxes(), and saveImage().
Get the current font
QColor Avogadro::PlotWidget::gridColor | ( | ) | const |
bool Avogadro::PlotWidget::isGridShown | ( | ) | const |
bool Avogadro::PlotWidget::isObjectToolTipShown | ( | ) | const |
int Avogadro::PlotWidget::leftPadding | ( | ) | const |
Padding values are set to -1 by default; if unchanged, this function will try to guess a good value, based on whether ticklabels and/or axis labels need to be drawn.
Referenced by drawAxes(), event(), mapFrameToData(), paintEvent(), and setPixRect().
QPointF Avogadro::PlotWidget::mapFrameToData | ( | const QPointF & | p | ) | const |
Map a coordinate.
p | from the frame's pixel rect to the data rect. Used mainly when drawing. |
p | the point to be converted, in pixels |
References leftPadding(), topPadding(), QPointF::x(), and QPointF::y().
Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
QPointF Avogadro::PlotWidget::mapToData | ( | const QPointF & | p | ) | const |
Map a coordinate.
p | from the physical pixel rect to the data rect. Used mainly when drawing. |
p | the point to be converted, in pixels |
References QPointF::x(), and QPointF::y().
QPointF Avogadro::PlotWidget::mapToWidget | ( | const QPointF & | p | ) | const |
Map a coordinate.
p | from the data rect to the physical pixel rect. Used mainly when drawing. |
p | the point to be converted, in natural data units |
References QPointF::x(), and QPointF::y().
Referenced by Avogadro::PlotObject::draw(), mouseMoveEvent(), mousePressEvent(), placeLabel(), pointNearestPoint(), and pointsUnderPoint().
void Avogadro::PlotWidget::maskAlongLine | ( | const QPointF & | p1, |
const QPointF & | p2, | ||
float | value = 1.0 |
||
) |
Indicate that object labels should try to avoid the line joining the two given points (in pixel coordinates).
p1 | the starting point for the line |
p2 | the ending point for the line |
value | Allows you to determine how strongly the line should be avoided. Larger values are avoided more strongly. |
References QColor::red(), QColor::rgba(), QColor::setAlpha(), QColor::setRed(), QPointF::toPoint(), QWidget::x(), QPointF::x(), QWidget::y(), and QPointF::y().
Referenced by Avogadro::PlotObject::draw().
void Avogadro::PlotWidget::maskRect | ( | const QRectF & | r, |
float | value = 1.0 |
||
) |
Indicate that object labels should try to avoid the given rectangle in the plot. The rectangle is in pixel coordinates.
r | the rectangle defining the region in the plot that text labels should avoid (in pixel coordinates) |
value | Allows you to determine how strongly the rectangle should be avoided. Larger values are avoided more strongly. |
References QRect::bottom(), QRect::intersected(), QRect::left(), QColor::red(), QColor::rgba(), QRect::right(), QColor::setAlpha(), QColor::setRed(), QRect::top(), and QRectF::toRect().
Referenced by Avogadro::PlotObject::draw(), and placeLabel().
QSize Avogadro::PlotWidget::minimumSizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Referenced by PlotWidget().
void Avogadro::PlotWidget::mouseDoubleClickEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Mouse handler.
Reimplemented from QWidget.
References QMouseEvent::buttons(), defaultDataRect(), QRectF::height(), QRectF::isNull(), setLimits(), QRectF::width(), QRectF::x(), and QRectF::y().
void Avogadro::PlotWidget::mouseMoveEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Mouse handler.
Reimplemented from QWidget.
References QMouseEvent::button(), QMouseEvent::buttons(), dataRect(), defaultDataRect(), QWidget::height(), QRectF::height(), mapFrameToData(), mapToWidget(), mouseOverPoint(), pixRect(), pointNearestPoint(), QMouseEvent::pos(), QMouseEvent::posF(), setLimits(), QWidget::update(), QRectF::width(), QWidget::width(), QPointF::x(), QRectF::x(), Avogadro::PlotPoint::x(), QRectF::y(), QPointF::y(), and Avogadro::PlotPoint::y().
void Avogadro::PlotWidget::mouseOverPoint | ( | double | x, |
double | y | ||
) | [signal] |
Get the point in data units from a mouseover. Use setMouseTracking(true) to enable.
x | X value |
y | Y value |
Referenced by mouseMoveEvent().
void Avogadro::PlotWidget::mousePressEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Mouse handler.
Reimplemented from QWidget.
References QMouseEvent::buttons(), mapFrameToData(), mapToWidget(), pointClicked(), pointNearestPoint(), pointsUnderPoint(), QMouseEvent::pos(), QMouseEvent::posF(), QPointF::x(), and QPointF::y().
void Avogadro::PlotWidget::mouseReleaseEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Mouse handler.
Reimplemented from QWidget.
References QMouseEvent::button(), dataRect(), QWidget::height(), mapFrameToData(), QMouseEvent::posF(), setLimits(), QWidget::width(), QWidget::x(), QPointF::x(), QWidget::y(), and QPointF::y().
void Avogadro::PlotWidget::paintEvent | ( | QPaintEvent * | e | ) | [protected, virtual] |
The paint event handler, executed when update() or repaint() is called.
Reimplemented from QFrame.
References backgroundColor(), QPainter::begin(), Avogadro::PlotObject::draw(), drawAxes(), QPainter::drawLine(), QPainter::end(), QPainter::fillRect(), QPointF::isNull(), leftPadding(), QPainter::pen(), QWidget::rect(), QPainter::resetMatrix(), resetPlotMask(), QPainter::setClipping(), QPainter::setClipRect(), QPainter::setFont(), QPainter::setPen(), setPixRect(), QPainter::setRenderHint(), QPen::setStyle(), QPen::setWidth(), topPadding(), QPainter::translate(), QPointF::x(), and QPointF::y().
QRect Avogadro::PlotWidget::pixRect | ( | ) | const |
Referenced by Avogadro::PlotObject::draw(), drawAxes(), mouseMoveEvent(), resetPlotMask(), and wheelEvent().
void Avogadro::PlotWidget::placeLabel | ( | QPainter * | painter, |
PlotPoint * | pp | ||
) |
Place an object label optimally in the plot. This function will attempt to place the label as close as it can to the point to which the label belongs, while avoiding overlap with regions of the plot that have been masked.
painter | Pointer to the painter on which to draw the label |
pp | pointer to the PlotPoint whose label is to be drawn. |
References QList::append(), QList::contains(), QPainter::device(), QPainter::drawLine(), QPainter::drawRoundRect(), QPainter::drawText(), QPainter::font(), Avogadro::PlotPoint::label(), QRectF::left(), mapToWidget(), maskRect(), QRectF::moveLeft(), QRectF::moveTop(), QPainter::pen(), QWidget::pos(), Avogadro::PlotPoint::position(), QPainter::setBrush(), QPen::setColor(), QPainter::setPen(), QList::size(), QRectF::top(), QPointF::toPoint(), QRectF::width(), QPointF::x(), and QPointF::y().
Referenced by Avogadro::PlotObject::draw().
QList< PlotObject * > Avogadro::PlotWidget::plotObjects | ( | ) | const |
void Avogadro::PlotWidget::pointClicked | ( | double | x, |
double | y | ||
) | [signal] |
Get the point in data units selected by a left click.
x | X value |
y | Y value |
Referenced by mousePressEvent().
void Avogadro::PlotWidget::pointClicked | ( | const QList< PlotPoint * > & | pl | ) | [signal] |
Get a list of points in data units within 4 pixels of a left click.
pl | List of PlotPoints |
void Avogadro::PlotWidget::pointClicked | ( | PlotPoint * | ) | [signal] |
Get the nearest point to a left click event.
p | PlotPoint nearest click location |
PlotPoint * Avogadro::PlotWidget::pointNearestPoint | ( | const QPoint & | p | ) | const [protected] |
p | The screen position from which to check for plot points. |
References mapToWidget(), Avogadro::PlotObject::points(), Avogadro::PlotPoint::position(), QWidget::rect(), and QRect::width().
Referenced by mouseMoveEvent(), and mousePressEvent().
QList< PlotPoint * > Avogadro::PlotWidget::pointsUnderPoint | ( | const QPoint & | p | ) | const [protected] |
p | The screen position from which to check for plot points. |
References mapToWidget(), Avogadro::PlotObject::points(), and Avogadro::PlotPoint::position().
Referenced by event(), and mousePressEvent().
Remove and delete all items from the list of PlotObjects
References QWidget::update().
void Avogadro::PlotWidget::replacePlotObject | ( | int | i, |
PlotObject * | o | ||
) |
Replace an item in the PlotObject list.
i | the index of the item to be replaced |
o | pointer to the replacement PlotObject |
References QWidget::update().
void Avogadro::PlotWidget::resetPlot | ( | ) |
Clear the object list, reset the data limits, and remove axis labels
References axis(), BottomAxis, clearSecondaryLimits(), LeftAxis, resetPlotMask(), RightAxis, Avogadro::PlotAxis::setLabel(), Avogadro::PlotAxis::setTickLabelsShown(), and TopAxis.
void Avogadro::PlotWidget::resetPlotMask | ( | ) |
Reset the mask used for non-overlapping labels so that all regions of the plot area are considered empty.
References pixRect(), QColor::rgb(), QColor::setAlpha(), and QWidget::size().
Referenced by paintEvent(), resetPlot(), and resizeEvent().
void Avogadro::PlotWidget::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
The resize event handler, called when the widget is resized.
Reimplemented from QWidget.
References resetPlotMask(), and setPixRect().
int Avogadro::PlotWidget::rightPadding | ( | ) | const |
Referenced by setPixRect().
bool Avogadro::PlotWidget::saveImage | ( | const QString & | filename, |
double | width, | ||
double | height, | ||
double | dpi, | ||
bool | optimizeFontSize | ||
) | [slot] |
Save the plot to an image.
filename | name of the file. Format will be guess from the file extension |
width | width of the image in meters |
height | height of the image in meters |
dpi | resolution of the image in dots per inch |
optimizeFontSize | set this to true to automatically determine a appropriate font size |
References Avogadro::PlotAxis::areTickLabelsShown(), axis(), backgroundColor(), QPainter::begin(), BottomAxis, Avogadro::PlotObject::drawImage(), QPainter::drawLine(), QPainter::drawText(), QPainter::end(), QImage::fill(), QPainter::fillRect(), QPainter::font(), foregroundColor(), gridColor(), QRectF::height(), QWidget::height(), QRect::height(), QString::isEmpty(), Avogadro::PlotAxis::isVisible(), Avogadro::PlotAxis::label(), LeftAxis, Avogadro::PlotAxis::majorTickMarks(), Avogadro::PlotAxis::minorTickMarks(), QWidget::palette(), QImage::rect(), QPainter::restore(), RightAxis, QPainter::rotate(), QImage::save(), QPainter::save(), secondaryDataRect(), QPainter::setBrush(), QPainter::setClipping(), QPainter::setClipRect(), QPalette::setColor(), QImage::setDotsPerMeterX(), QImage::setDotsPerMeterY(), QPainter::setFont(), QWidget::setGeometry(), QPainter::setPen(), QFont::setPixelSize(), QPainter::setRenderHint(), Avogadro::PlotAxis::tickLabel(), TopAxis, QPainter::translate(), QRect::width(), QRectF::width(), QRectF::x(), and QRectF::y().
void Avogadro::PlotWidget::scaleLimits | ( | PlotObject * | po = NULL | ) |
Determine the limits of the plot by examining the PlotPoints. Omit PlotPoint *po to examine all PlotObjects.
po | the PlotObject to be used for scaling. Omit to look at all PlotObjects. |
References QList::first(), QList::isEmpty(), Avogadro::PlotObject::points(), setDefaultLimits(), Avogadro::PlotPoint::x(), and Avogadro::PlotPoint::y().
Referenced by drawAxes(), and saveImage().
void Avogadro::PlotWidget::selectPoint | ( | PlotPoint * | point | ) | [slot] |
Mark the indicated point with a yellow circle.
point | PlotPoint to be highlighted |
References QWidget::update(), Avogadro::PlotPoint::x(), and Avogadro::PlotPoint::y().
void Avogadro::PlotWidget::selectPoints | ( | const QList< PlotPoint * > & | points | ) | [slot] |
Mark the indicated points with yellow circles.
points | QList of PlotPoints to be highlighted |
References QList::at(), QList::size(), and QWidget::update().
void Avogadro::PlotWidget::setAntialiasing | ( | bool | b | ) |
Toggle antialiased drawing.
b | if true, the plot graphics will be antialiased. |
References QWidget::update().
void Avogadro::PlotWidget::setBackgroundColor | ( | const QColor & | bg | ) |
Set the background color
bg | the new background color |
Reimplemented from QWidget.
References QWidget::update().
void Avogadro::PlotWidget::setDefaultLimits | ( | double | x1, |
double | x2, | ||
double | y1, | ||
double | y2 | ||
) |
Set the default data limits for the plot. These are used for restoring the limits to a "normal" setting when the widget is double clicked. Calling this will also update the plot to the new limits specified.
x1 | the minimum X value in data units |
x2 | the maximum X value in data units |
y1 | the minimum Y value in data units |
y2 | the maximum Y value in data units |
References setLimits().
Referenced by scaleLimits().
void Avogadro::PlotWidget::setFont | ( | QFont | font | ) |
Set the font
font | the new font as QFont |
References QWidget::font(), and QWidget::update().
void Avogadro::PlotWidget::setFontSize | ( | int | pointSize | ) |
Set the font size
pointSize | the new font size in pt |
void Avogadro::PlotWidget::setForegroundColor | ( | const QColor & | fg | ) |
void Avogadro::PlotWidget::setGridColor | ( | const QColor & | gc | ) |
void Avogadro::PlotWidget::setJailedInDefaults | ( | bool | b | ) | [slot] |
Don't permit moving away from default limits
References defaultDataRect(), QRectF::height(), setLimits(), QRectF::width(), QRectF::x(), and QRectF::y().
void Avogadro::PlotWidget::setLimits | ( | double | x1, |
double | x2, | ||
double | y1, | ||
double | y2 | ||
) |
Set new data limits for the plot.
x1 | the minimum X value in data units |
x2 | the maximum X value in data units |
y1 | the minimum Y value in data units |
y2 | the maximum Y value in data units |
References QWidget::update().
Referenced by mouseDoubleClickEvent(), mouseMoveEvent(), mouseReleaseEvent(), setDefaultLimits(), setJailedInDefaults(), and wheelEvent().
void Avogadro::PlotWidget::setLimits | ( | QRectF & | rect | ) |
Set new data limits for the plot.
rect | rectangle containing all possible values of X and Y in data units |
References QWidget::update().
void Avogadro::PlotWidget::setObjectToolTipShown | ( | bool | show | ) | [slot] |
Toggle the display of a tooltip for point objects.
show | whether show the tooltip. |
References QWidget::show().
void Avogadro::PlotWidget::setPixRect | ( | ) | [protected] |
Synchronize the PixRect with the current widget size and padding settings.
References bottomPadding(), QWidget::contentsRect(), QRect::height(), leftPadding(), rightPadding(), topPadding(), and QRect::width().
Referenced by paintEvent(), and resizeEvent().
void Avogadro::PlotWidget::setPointFollowMouse | ( | bool | b | ) | [slot] |
Highlight the point nearest the mouse with a blue circle.
References QWidget::setMouseTracking(), and QWidget::update().
void Avogadro::PlotWidget::setSecondaryLimits | ( | double | x1, |
double | x2, | ||
double | y1, | ||
double | y2 | ||
) |
Reset the secondary data limits, which control the values displayed along the top and right axes.
All data points are plotted using the coordinates defined by setLimits(), so this function is only useful for showing alternate tickmark labels along the top and right edges. For example, if you were plotting temperature on the X-axis, you could use Centigrade units for the primary (bottom) axis, using setLimits( 0.0, 100.0, 0.0, 1.0 ). If you also wanted to show Farenheit units along the secondary (top) axis, you would additionally use setSecondaryLimits( 32.0, 212.0, 0.0, 1.0 ). The data added to the plot would have x-coordinates in Centigrade degrees.
x1 | the minimum X value in secondary data units |
x2 | the maximum X value in secondary data units |
y1 | the minimum Y value in secondary data units |
y2 | the maximum Y value in secondary data units |
References axis(), RightAxis, Avogadro::PlotAxis::setTickMarks(), TopAxis, and QWidget::update().
void Avogadro::PlotWidget::setShowGrid | ( | bool | show | ) | [slot] |
Toggle whether grid lines are drawn at major tickmarks.
show | if true, grid lines will be drawn. |
References QWidget::show(), and QWidget::update().
QSize Avogadro::PlotWidget::sizeHint | ( | ) | const [virtual] |
int Avogadro::PlotWidget::topPadding | ( | ) | const |
Referenced by event(), mapFrameToData(), paintEvent(), and setPixRect().
Clears the default limits and disables double click restoration.
References defaultDataRect().
void Avogadro::PlotWidget::wheelEvent | ( | QWheelEvent * | event | ) | [protected, virtual] |
Wheel handler for zooming.
Reimplemented from QWidget.
References dataRect(), QWidget::height(), QRectF::height(), pixRect(), QWidget::pos(), setLimits(), QRectF::width(), QWidget::width(), QPointF::x(), QPoint::x(), QRectF::x(), QPoint::y(), QPointF::y(), and QRectF::y().