libelec
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
|
Go to the source code of this file.
Functions | |
libelec_vis_t * | libelec_vis_new (const elec_sys_t *sys, double pos_scale, double font_sz) |
void | libelec_vis_destroy (libelec_vis_t *vis) |
bool | libelec_vis_is_open (libelec_vis_t *vis) |
void | libelec_vis_open (libelec_vis_t *vis) |
void | libelec_vis_close (libelec_vis_t *vis) |
void | libelec_vis_set_offset (libelec_vis_t *vis, vect2_t offset) |
vect2_t | libelec_vis_get_offset (const libelec_vis_t *vis) |
This file contains a simple visualizer for libelec networks. This is using X-Plane's XPLM SDK for window handling, compositing and mouse interaction.
To create a new visualizer, use libelec_vis_new(), passing it a handle to an initialized and started elec_sys_t. On shutdown, you must call libelec_vis_destroy() before stopping and destroying the referenced electrical system. You can open the window using libelec_vis_open() if it was closed by the user (use libelec_vis_is_open() to check).
libelec_drawing.h
and implementing your own window handling and interaction layers.Definition in file libelec_vis.h.
void libelec_vis_close | ( | libelec_vis_t * | vis | ) |
Closes the libelec_vis_t window, if open, otherwise does nothing. Closing the window stops the renderer thread and deinitializes the renderer's framebuffer, so removes essentially all CPU, RAM and VRAM footprint that the visualizer had while open. As such, you don't need to immediately perform a libelec_vis_destroy() as soon as the window is closed. You can delay that until simulator shutdown. This will help preserve the window's position and size, if the user moved and/or resized it.
Definition at line 492 of file libelec_vis.c.
void libelec_vis_destroy | ( | libelec_vis_t * | vis | ) |
Destroys a previously created libelec_vis_t. You must call this before destroying the underlying elec_sys_t handle.
Definition at line 412 of file libelec_vis.c.
vect2_t libelec_vis_get_offset | ( | const libelec_vis_t * | vis | ) |
Definition at line 444 of file libelec_vis.c.
bool libelec_vis_is_open | ( | libelec_vis_t * | vis | ) |
Definition at line 454 of file libelec_vis.c.
libelec_vis_t* libelec_vis_new | ( | const elec_sys_t * | sys, |
double | pos_scale, | ||
double | font_sz | ||
) |
Creates a window showing a visualization of an electrical network. This is using the drawing routines within libelec_drawing.h
to draw an image of the network, as well as implement mouse interaction for panning & zooming around in the network.
sys | The electrical system to display. This must have been previously initialized using libelec_new(). The visualizer keeps a reference to the system, so you must NOT destroy the elec_sys_t before the visualizer. |
pos_scale | A scaling multiplier applied to all GUI_POS stanzas in the network layout configuration file. This lets you use abstract size units in the config file and then scale them up as you see fit. |
font_sz | Default font size to be used for all drawing. This sets the default header and title sizes, and is also used as a baseline for smaller font scales for things such as subscripts. |
Definition at line 365 of file libelec_vis.c.
void libelec_vis_open | ( | libelec_vis_t * | vis | ) |
Opens the libelec_vis_t window. The window will automatically switch to VR positioning mode, if the user is in VR (or return back to 2D mode, if they have exited VR).
Definition at line 467 of file libelec_vis.c.
void libelec_vis_set_offset | ( | libelec_vis_t * | vis, |
vect2_t | offset | ||
) |
Sets the panning offset of the contents of the rendering. Initially this is (0,0), but if your network layout is better centered on another position, you can use this function to pre-pan the view to that offset after creating the visualizer.
offset | The visual offset to set in pixels. |
Definition at line 434 of file libelec_vis.c.