Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::Graph Class Reference

Class for drawing a graph having optional rulers and grid. More...

#include <Graph.h>

Collaboration diagram for sf::Graph:

Classes

struct  RulerInfo
 Holds information on the rulers. More...
 

Public Types

enum  EColor {
  cRulerText , cRulerLine , cGridLines , cRulerBackground ,
  cGraphBackground , cGraphForeground
}
 Colors enumeration of colors in the graph. More...
 

Public Member Functions

 Graph (const QPalette &palette={})
 
void setRuler (Draw::ERulerOrientation ro, double start, double stop, int digits, const QString &unit)
 Sets and thus enabling the ruler for the passed orientation.
 
void setGrid (Draw::EGridOrientation go, Draw::ERulerOrientation ro)
 Enables grid painting in the graph.
 
void setBounds (const QFontMetrics &fontMetrics, const QRect &bounds)
 Sets the bounding rectangle for the graph for painting in.
 
const QRect & paint (QPainter &painter, const QRect &bounds, const QRegion &region=null_ref< QRegion >())
 Paints the graph.
 
void paintPlotCross (QPainter &painter, const QString &text)
 Paints a cross with text in the plot area. Used when a plot can not be painted.
 
const QRect & getPlotArea () const
 Gets the remaining area to plot the graph after rulers and grid have been painted.
 
void setColor (EColor index, QColor color)
 Allows setting of individual indexed colors for the graph.
 

Public Attributes

bool _debug {false}
 Draws only area bounds contours when enabled.
 

Protected Member Functions

RulerInfogetRulerInfo (Draw::ERulerOrientation ro)
 Gets the ruler information by orientation.
 

Protected Attributes

QVector< QColor > _colors
 Holds the colors for painting the rulers en grid.
 
struct sf::Graph::RulerInfo _top
 
struct sf::Graph::RulerInfo _left
 
struct sf::Graph::RulerInfo _right
 
struct sf::Graph::RulerInfo _bottom
 
Draw::ERulerOrientation _horizontal {Draw::roNone}
 Holds which ruler information is responsible.
 
Draw::ERulerOrientation _vertical {Draw::roNone}
 
QRect _plotArea
 Holds the last calculated graph area rectangle.
 

Detailed Description

Class for drawing a graph having optional rulers and grid.

This class uses sf::Draw class for drawing a graph rulers and grid.

Use this class as a private class for a custom widget which produces a graph.

Member Enumeration Documentation

◆ EColor

Colors enumeration of colors in the graph.

Used by setColor function.

Enumerator
cRulerText 

Color of unit and values.

cRulerLine 

Color for lines of major and minor ticks.

cGridLines 

Color of the grid lines.

cRulerBackground 

Color of ruler background.

cGraphBackground 

Color of the graph area background.

cGraphForeground 

Color of the graph.

Constructor & Destructor Documentation

◆ Graph()

sf::Graph::Graph ( const QPalette &  palette = {})
explicit

Constructor passing a palette.

Member Function Documentation

◆ getPlotArea()

const QRect & sf::Graph::getPlotArea ( ) const

Gets the remaining area to plot the graph after rulers and grid have been painted.

Returns
Area rectangle to plot the actual graphic.

◆ getRulerInfo()

RulerInfo * sf::Graph::getRulerInfo ( Draw::ERulerOrientation  ro)
protected

Gets the ruler information by orientation.

Parameters
roruler orientation.
Returns
ruler information structure.

◆ paint()

const QRect & sf::Graph::paint ( QPainter &  painter,
const QRect &  bounds,
const QRegion &  region = null_ref< QRegion >() 
)

Paints the graph.

Paints the graph passing the passed boundaries and the optional region when handling an event.

Parameters
painterPainter instance.
boundsBoundaries to paint in.
regionRegion in case of an event.
Returns
Rectangle of the resulting graph area. Same value as getPlotArea() returns.

◆ paintPlotCross()

void sf::Graph::paintPlotCross ( QPainter &  painter,
const QString &  text 
)

Paints a cross with text in the plot area. Used when a plot can not be painted.

Parameters
painterPainter instance.
textText to paint in the middle in a rectangle.

◆ setBounds()

void sf::Graph::setBounds ( const QFontMetrics &  fontMetrics,
const QRect &  bounds 
)

Sets the bounding rectangle for the graph for painting in.

Paints the graph passing the passed boundaries and the optional region when handling an event.

Parameters
fontMetricsFor calculating the ruler widths and heights.
boundsBoundary to paint in.

◆ setColor()

void sf::Graph::setColor ( EColor  index,
QColor  color 
)

Allows setting of individual indexed colors for the graph.

Parameters
indexIndex of the color which is set.
colorThe specified color.

◆ setGrid()

void sf::Graph::setGrid ( Draw::EGridOrientation  go,
Draw::ERulerOrientation  ro 
)

Enables grid painting in the graph.

When painting this enables drawing grid for the passed orientation using the information of the passed ruler orientation.

Parameters
goGrid orientation
roruler orientation.

◆ setRuler()

void sf::Graph::setRuler ( Draw::ERulerOrientation  ro,
double  start,
double  stop,
int  digits,
const QString &  unit 
)

Sets and thus enabling the ruler for the passed orientation.

Parameters
roOrientation of the ruler.
startruler start value.
stopruler stop value.
digitsPrecision of the ruler values.
unitunit text of the ruler.

Member Data Documentation

◆ _bottom

struct sf::Graph::RulerInfo sf::Graph::_bottom
protected

◆ _colors

QVector<QColor> sf::Graph::_colors
protected

Holds the colors for painting the rulers en grid.

◆ _debug

bool sf::Graph::_debug {false}

Draws only area bounds contours when enabled.

◆ _horizontal

Draw::ERulerOrientation sf::Graph::_horizontal {Draw::roNone}
protected

Holds which ruler information is responsible.

◆ _left

struct sf::Graph::RulerInfo sf::Graph::_left
protected

◆ _plotArea

QRect sf::Graph::_plotArea
protected

Holds the last calculated graph area rectangle.

◆ _right

struct sf::Graph::RulerInfo sf::Graph::_right
protected

◆ _top

struct sf::Graph::RulerInfo sf::Graph::_top
protected

◆ _vertical

Draw::ERulerOrientation sf::Graph::_vertical {Draw::roNone}
protected

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