Main page

HistoGUI user guide

HistoGUI can be easily implemented into any c++ project, allowing for simple interactive plotting. This details some of the commands in the HistoGUI class - although as it is ever evolving, this list may be slightly out of date.

Functions

Redefineable functions


General points

HistoGUI interfaces with X11 functions directly to plot data. The data and plotting functions are held within a HistoGUI class object. The class is entirely public, so data can be directly accessed, however it is recommended to populate using the commands listed here.

Show()

Starts the GUI - at this point the code will enter the GUI loop.

Close()

Gracefully closes the GUI object.

Help()

Prints GUI commands to the terminal - useful for reference by new users.

HelpCode()

Prints some useful coding info to the terminal - not that useful tbh.

MakeHist1D(int nBins, double lowBin, double highBin)

Constructs a 1D histogram defined by the number of bins nBins, the low value lowBin, and the high value highBin.

MakeHist2D(int nBins_X, double lowBin_X, double highBin_X, int nBins_Y, double lowBin_Y, double highBin_Y)

Constructs a 2D histogram defined by the number of bins in both axis nBins_X / nBins_Y, the low value lowBin_X / lowBin_Y, and the high value highBin_X / highBin_Y.

Fill(double val)

Fill the 1D histogram. i.e. incriment the bin value that corresponds to x = val. This does it safely ensuring no memory errors.

Fill(double valX, double valY)

Fill the 2D histogram. i.e. incriment the bin value that corresponds to x = valX and y = valY. This does it safely ensuring no memory errors.

SetAxisTitles(char* xAxis, char* yAxis)

Set the axis titles. The same for both 1D and 2D histograms.

SetProjectionAxisTitle(char* zAxis)

Set the z axis title. This is only shown when projecting a 2D histogram.

SetAutoRefresh(bool a, long milisec)

Sets whether the plot will auto refresh (a = true: refresh on), and the time inbetween refresh calls. The auto refresh can also be toggled in the GUI with a keypress of s. Returns milisec.

SetAdditive(bool in = true)

This sets the hitmaps to be always additive i.e. the canvas is not cleared during a refresh. This improves drawing aesthetics quite a lot.

Init()

Initalizes the GUI objects. Is necessary for the GUI to start.

Loop()

Starts the GUI and enters a loop.

SetData(std::vector<double> a, std::vector<double>b)

[Depreciated - used MakeHist1D & Fill] Loops across the vectors supplied and populates a 1D histogram with bin low edges defined by a and bin content defined by b.

Also can take std::vector<float> for b.


SetData2D(std::vector<double> a, std::vector<double> b, std::vector< std::vector<double> > c)

[Depreciated - use MakeHist2D & Fill] Loops across the vectors provided and populates a 2D histogram with X bin low edges defined by a, Y bin low edges defined by b, and teh content of the bins supplied by c.

c must be a vector of vectors containing nXbin vectors, each with nYbin elements. This allows for the data to be accessed as c[x][y] = z.


Set2D(bool a)

Specifies that the data to be drawn is 2D. Important as the vectors used for 1D histograms are the same as those used for the axis bins in 2D histograms.

DrawCrosshairs(int mouse_x, int mouse_y)

Is called when the GUI is clicked. This is a virtual int function so can be redefined if you want to exacute some code that requires mouse position information.

Refresh()

As default this function does not do anything. It allows for the user to execute code that acts upon the plotted data without exiting the GUI. Allowing for example, live plotting.