Stacked Graphs
Geometry & Aesthetics
 All Classes Functions Variables Enumerations
Signals | Public Member Functions | Protected Member Functions | List of all members
GraphScene Class Reference

A QGraphicsScene subclass which is responsible for the creation, drawing and rendering of a stacked graph. More...

#include <graphscene.h>

Signals

void redrawRequired ()
 

Public Member Functions

 GraphScene (QWidget *parent)
 
void CreateStackedGraph (DataSet &data)
 Creates a stacked graph out of the given dataset. More...
 
QVector< GraphLayouter * > GetLayouts () const
 Returns the available layouts.
 
QVector< GraphSorter * > GetSorters () const
 Returns the available sorters.
 
void SetLayout (GraphLayouter *const layouter)
 Sets the layouter to use in the CreateStackedGraph method. More...
 
void SetSorter (GraphSorter *const sorter)
 Sets the sorter to use in the CreateStackedGraph method. More...
 
void SetInterpolationMode (GraphLayouter::InterpolationMode const interpMode)
 Sets the interpolation method to be used by the GraphLayouter when layouting the graph. More...
 
void SetSortingAttribute (GraphSorter::SortingAttribute const sortAttribute)
 Sets the sorting attribute to be used by the GraphSorter when sorting the dataset. More...
 
void SetColoringAttribute (GraphColorizer::ColoringAttribute const colorAttribute)
 Sets the coloring attribute to be used by the GraphColorizer when assigning colors to the graph layers. More...
 
void SetLabeling (bool enabled)
 Determines if the layers should show their labels. More...
 
void SetColors (QColor const beginColor, QColor const endColor)
 Sets the colors which define the start and end color of the linearly interpolated color gradient used to define the stacked graphs layer colors. More...
 
void Set2DColoring (bool enable)
 Sets a flag which enables 2D coloring: alpha value of color changes according to the layours sum value.
 
QImage GetBitmap (int width, int height, bool keepAspect)
 Renders the current graph into a QImage. More...
 

Protected Member Functions

void mousePressEvent (QGraphicsSceneMouseEvent *ev) override
 

Detailed Description

A QGraphicsScene subclass which is responsible for the creation, drawing and rendering of a stacked graph.

Call CreateStackedGraph to create the graph with the currently set attributes. GetBitmap can be used for exporting.

Member Function Documentation

void GraphScene::CreateStackedGraph ( DataSet data)

Creates a stacked graph out of the given dataset.

This function puts together the results of the current GraphSorter, GraphLabeler and GraphColorizer to create a visual representation of the data set. Labelling is also optionally performed using a brute-force algorithm.

Parameters
datathe DataSet to use.
QImage GraphScene::GetBitmap ( int  width,
int  height,
bool  keepAspect 
)

Renders the current graph into a QImage.

Parameters
widthThe pixel-width of the image
heigthThe pixel-height of the image
keepAspectIf true, the aspect ratio of the graph is kept as it is in the application. If false, it uses the ratio of the image.
Returns
a QImage of the graph
void GraphScene::SetColoringAttribute ( GraphColorizer::ColoringAttribute const  colorAttribute)

Sets the coloring attribute to be used by the GraphColorizer when assigning colors to the graph layers.

Parameters
colorAttributethe attribute used to calculate appropriate colors
void GraphScene::SetColors ( QColor const  beginColor,
QColor const  endColor 
)

Sets the colors which define the start and end color of the linearly interpolated color gradient used to define the stacked graphs layer colors.

Parameters
colorthe color to set
void GraphScene::SetInterpolationMode ( GraphLayouter::InterpolationMode const  interpMode)

Sets the interpolation method to be used by the GraphLayouter when layouting the graph.

Parameters
interpModethe interpolation mode
void GraphScene::SetLabeling ( bool  enabled)

Determines if the layers should show their labels.

The algorithm used for sizing and positioning the labels is based on a simple brute-force method, and may not give the best results in most cases. If no label can fit in a given layer, it gets no label at all.

Parameters
enabledif true, draw labels
void GraphScene::SetLayout ( GraphLayouter *const  layouter)

Sets the layouter to use in the CreateStackedGraph method.

Parameters
layoutthe layouter
void GraphScene::SetSorter ( GraphSorter *const  sorter)

Sets the sorter to use in the CreateStackedGraph method.

Parameters
sorterthe sorter
void GraphScene::SetSortingAttribute ( GraphSorter::SortingAttribute const  sortAttribute)

Sets the sorting attribute to be used by the GraphSorter when sorting the dataset.

Parameters
sortAttributethe attribute used to sort the dataset

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