#include <grapher.h>
Public Types | |
typedef void(* | keyboard_function )(unsigned char key, GLint x, GLint y) |
Keyboard event handler typedef. | |
typedef void(* | click_function )(GLint button, GLint x, GLint y) |
Click even handler typedef. | |
typedef void(* | idle_function )(void) |
The idle function typedef. | |
Static Public Member Functions | |
static int | initialize (int argc, char **argv, short int options=AXES_ON|GRID_ON|X_LIN|Y_LIN, short int k_options=ZOOM_KEYS_ON|AXES_KEYS_ON|GRID_KEYS_ON|QUIT_KEYS_ON) |
Initialize the grapher. | |
static void | run () |
Enter the OpenGL main loop after initialization. | |
static void | redraw () |
User-requested redraw. | |
static void | add (primitive &p) |
Add a primitive to the plot. | |
static void | remove (primitive &p) |
Remove a primitive from the plot. | |
static void | add (point &p) |
Add a point to the plot. | |
static void | remove (point &p) |
Remove a point from the plot. | |
static void | set_keyboard_function (keyboard_function k) |
Set up a keyboard event handler. | |
static void | set_click_function (click_function c) |
Set up a click event handler. | |
static void | set_idle_function (idle_function i) |
Set the idle function handler. | |
static void | zoom (double scale) |
Zoom in / out by a scale. | |
static double | get_x_coord (GLint x) |
Transform a screen x coordinate to a world one. | |
static double | get_y_coord (GLint y) |
Transform a screen y coordinate to a world one. | |
static point | get_point (GLint x, GLint y) |
Returns the x, y point clicked on, in plot-space. |
You might think of this class as a container for all the graphing primitives you plan to plot
typedef void(* glot::grapher::click_function)(GLint button, GLint x, GLint y) |
Click even handler typedef.
button | - GLint button pressed | |
x | - GLint x coordinate | |
y | - GLint y coordinate |
typedef void(* glot::grapher::idle_function)(void) |
The idle function typedef.
See set_idle_funciton(...) for more details
typedef void(* glot::grapher::keyboard_function)(unsigned char key, GLint x, GLint y) |
Keyboard event handler typedef.
key | - unsigned char | |
x | - GLint x coordinate | |
y | - GLint y coordinate |
static void glot::grapher::add | ( | point & | p | ) | [static] |
static void glot::grapher::add | ( | primitive & | p | ) | [static] |
static point glot::grapher::get_point | ( | GLint | x, | |
GLint | y | |||
) | [static] |
Returns the x, y point clicked on, in plot-space.
Deprecation likely
static double glot::grapher::get_x_coord | ( | GLint | x | ) | [static] |
static double glot::grapher::get_y_coord | ( | GLint | y | ) | [static] |
static int glot::grapher::initialize | ( | int | argc, | |
char ** | argv, | |||
short int | options = AXES_ON|GRID_ON|X_LIN|Y_LIN , |
|||
short int | k_options = ZOOM_KEYS_ON|AXES_KEYS_ON|GRID_KEYS_ON|QUIT_KEYS_ON | |||
) | [static] |
Initialize the grapher.
argc | - same as argc used for OpenGL initialization | |
argv | - same as argv used for OpenGL initialization | |
options | - startup options | |
k_options | - the default keyboard actions options |
static void glot::grapher::redraw | ( | ) | [static] |
User-requested redraw.
If you create an event handler that will make some changes to the graph, you can make those changes and then request a redraw with this function.
static void glot::grapher::remove | ( | point & | p | ) | [static] |
static void glot::grapher::remove | ( | primitive & | p | ) | [static] |
static void glot::grapher::run | ( | ) | [static] |
Enter the OpenGL main loop after initialization.
In general, you will set up your event handlers, main code, etc., and then when you've gotten everything in place, you call grapher::run() to start the program's OpenGL portion.
static void glot::grapher::set_click_function | ( | click_function | c | ) | [static] |
Set up a click event handler.
c | - the function you'd like to handle click events |
static void glot::grapher::set_idle_function | ( | idle_function | i | ) | [static] |
Set the idle function handler.
Animation is done by setting the idle_function handler, and this provides the interface. This might be deprecated in favor of an option that just allows the user to turn on animation, which would consist of simply setting OpenGL's idle function to grapher's display function.
static void glot::grapher::set_keyboard_function | ( | keyboard_function | k | ) | [static] |
Set up a keyboard event handler.
k | - the function you'd like to handle key events |
The idea behind this is that these default behaviors are not the programmer's responsibility to code up as well. They are interface freebies.
Bitwise or options together from the set: ZOOM_KEYS_ON / ZOOM_KEYS_OFF AXES_KEYS_ON / AXES_KEYS_OFF GRID_KEYS_ON / GRID_KEYS_OFF
static void glot::grapher::zoom | ( | double | scale | ) | [static] |
Zoom in / out by a scale.
scale | - the scale by which to zoom |