Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
view.h File Reference
#include <gl/framebuffer.h>
#include <gl/trackball.h>
#include <gl/utils.h>
#include "utils.h"
#include "input.h"
#include "vertexbuffer.h"
#include "draw.h"
#include "parse.h"
#include "draw_get.h"
Include dependency graph for view.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cexpr
 
struct  _bview
 

Typedefs

typedef void(* MapFunc) (coord *)
 
typedef struct _bview bview
 
typedef voidpointer
 

Functions

static scalar get_cexpr (cexpr *cache, const char *expr)
 
static cexpradd_cexpr (cexpr *cache, int maxlen, const char *expr, scalar s)
 
static void free_cexpr (cexpr *cache)
 
bviewbview_new ()
 The allocator method.
 
void bview_destroy (bview *p)
 The destructor method.
 
static void destroy_view ()
 The current view needs to be destroyed when we exit Basilisk.
 
bviewget_view ()
 
static void redraw (bool clear=true)
 The main drawing function.
 
bviewdraw ()
 This is called by graphics primitives before drawing.
 
static trace pointer compose_image (bview *view)
 
bool load (FILE *fp=NULL, char *file=NULL, Array *buf=NULL)
 
static void bview_draw (bview *view)
 
trace bool save (char *file=NULL, char *format="ppm", char *opt=NULL, FILE *fp=NULL, float lw=0, int sort=0, int options=0, FILE *checksum=NULL, bview *view=NULL)
 
static charremove_blanks (char *line)
 
bool process_line (char *line)
 

Variables

static bview_view = NULL
 For the moment there is a single (static) current view.
 

Typedef Documentation

◆ bview

Definition at line 171 of file view.h.

◆ MapFunc

typedef void(* MapFunc) (coord *)

The <em>bview</em> class

Contains the definition of the current view.

Definition at line 139 of file view.h.

◆ pointer

Helper function for parallel image composition

compose_image() returns an image buffer made by composition of the framebuffer images on each of the MPI processes.

Definition at line 321 of file view.h.

Function Documentation

◆ add_cexpr()

static cexpr * add_cexpr ( cexpr cache,
int  maxlen,
const char expr,
scalar  s 
)
static

Definition at line 96 of file view.h.

References c, free(), realloc(), s, strdup(), and x.

Referenced by compile_expression().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bview_destroy()

void bview_destroy ( bview p)

The destructor method.

Definition at line 214 of file view.h.

References free(), free_cexpr(), p, and x.

Referenced by destroy_view().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bview_draw()

static void bview_draw ( bview view)
static

Definition at line 447 of file view.h.

References enable_fpe(), glFinish, view(), and x.

Referenced by save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bview_new()

bview * bview_new ( )

The allocator method.

Definition at line 176 of file view.h.

References enable_fpe(), p, qcalloc, and x.

Referenced by get_view().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compose_image()

static trace pointer compose_image ( bview view)
static

Definition at line 325 of file view.h.

References _bview::fb, view(), and x.

Referenced by save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_view()

static void destroy_view ( )
static

The current view needs to be destroyed when we exit Basilisk.

This is done by adding this callback to the free_solver() lists of destructors.

Definition at line 232 of file view.h.

References _view, assert, and bview_destroy().

Referenced by get_view().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw()

bview * draw ( )

This is called by graphics primitives before drawing.

Definition at line 302 of file view.h.

References get_view(), GL_PROJECTION, glMatrixMode, glTranslatef, redraw(), view(), and x.

Referenced by clear(), and translate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_cexpr()

static void free_cexpr ( cexpr cache)
static

Definition at line 122 of file view.h.

References c, free(), and s.

Referenced by bview_destroy(), and process_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_cexpr()

static scalar get_cexpr ( cexpr cache,
const char expr 
)
static

Definition at line 78 of file view.h.

References c, and x.

Referenced by compile_expression().

Here is the caller graph for this function:

◆ get_view()

bview * get_view ( )

Definition at line 238 of file view.h.

References _view, bview_new(), destroy_view(), and free_solver_func_add().

Referenced by clear(), compile_expression(), draw(), process_line(), redraw(), save(), and vertex_buffer_glBegin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

bool load ( FILE fp = NULL,
char file = NULL,
Array buf = NULL 
)

User functions

Drawing user functions are defined in [draw.h]().

<em>load()</em>: read drawing commands from a file or buffer

The commands are calls of user functions. They can be read from a file defined by fp or file, or from the memory buffer buf.

Besides the load(), save() and drawing functions defined in [draw.h](), valid drawing commands also include:

restore() dump() input_gfs()

Definition at line 719 of file view.h.

References buf, file, fp, i, line, process_line(), s, and x.

Referenced by gladLoadGLLoader(), load_GL_VERSION_1_0(), load_GL_VERSION_1_1(), load_GL_VERSION_1_2(), load_GL_VERSION_1_3(), load_GL_VERSION_1_4(), load_GL_VERSION_1_5(), load_GL_VERSION_2_0(), load_GL_VERSION_2_1(), load_GL_VERSION_3_0(), load_GL_VERSION_3_1(), load_GL_VERSION_3_2(), load_GL_VERSION_3_3(), load_GL_VERSION_4_0(), load_GL_VERSION_4_1(), load_GL_VERSION_4_2(), load_GL_VERSION_4_3(), and process_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_line()

bool process_line ( char line)

The [draw_get.h]() file is generated automatically by [params.awk]() and contains parsing commands for the functions defined in [draw.h]().

Definition at line 645 of file view.h.

References all, calloc(), clear(), fields_stats(), file, free_cexpr(), get_view(), input_gfs(), line, list, load(), mystrtok(), parse_params(), pstring, remove_blanks(), restriction, s, save(), view(), and x.

Referenced by display_command(), and load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ redraw()

static void redraw ( bool  clear = true)
static

The main drawing function.

Definition at line 249 of file view.h.

References clear(), get_view(), GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_MODELVIEW, GL_PROJECTION, glClear, glClearColor, glLoadIdentity, glMatrixMode, glMultMatrixf, glScalef, glTranslatef, L0, m(), max, view(), and x.

Referenced by draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_blanks()

static char * remove_blanks ( char line)
static

Implementation of the <em>load()</em> function.

The functions below parse a text file and perform the corresponding function calls.

Definition at line 627 of file view.h.

References line, s, and x.

Referenced by process_line().

Here is the caller graph for this function:

◆ save()

trace bool save ( char file = NULL,
char format = "ppm",
char opt = NULL,
FILE fp = NULL,
float  lw = 0,
int  sort = 0,
int  options = 0,
FILE checksum = NULL,
bview view = NULL 
)

<em>save()</em>: saves drawing to a file in various formats

The file to write to is given either using its name file or the file pointer fp. If neither is specified, the default is stdout.

If file is used, options for 'convert' or 'ffmpeg' can be given in opt*.

The format to use is given either explicitly using format, or, if a file* name is given, using the file name extension (i.e. *.ppm*, .bv*, etc.). If neither is specified, the default is "ppm".

For vector graphics, the base line width can be specified using lw*. The default is one.

The recognised file formats are:

"ppm": Portable PixMap format. A basic uncompressed image format. "png", "jpg": Compressed image formats. Will only work if the convert* command from ImageMagick is installed on the system. "mp4", "gif", "ogv": Compressed animation formats. Will only work if ffmpeg is installed on the system.

The following formats are no longer supported, but this could be fixed later:

"bv": Basilisk View format. Saves all Basilisk function calls necessary to reproduce the figure. Use together with load(). "gnu": Gnuplot format. Saves a vector graphics (3D) representation of the objects. "obj": Wavefront 3D object format. Can be read by a number of 3D visualisation tools. "kml": Keyhole Markup Language. Can be used with Google Earth and other GIS. "ps", "eps", "tex", "pdf", "svg", "pgf": the various vector graphics formats supported by gl2ps.

Note that MPI-parallel output is only implemented for the "ppm" format at the moment. Other animation and image formats will be automatically converted to PPM when using MPI.

Definition at line 503 of file view.h.

References a32_hash(), a32_hash_add(), a32_hash_init(), assert, bview_draw(), close_image(), compose_image(), fflush(), file, fp, get_view(), is_animation(), open_image(), s, sizeof(), view(), which(), and x.

Referenced by process_line().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _view

bview* _view = NULL
static

For the moment there is a single (static) current view.

Definition at line 225 of file view.h.

Referenced by destroy_view(), get_view(), and translate().