1 /*************************************************************************** 2 *cr 3 *cr (C) Copyright 1995-2006 The Board of Trustees of the 4 *cr University of Illinois 5 *cr All Rights Reserved 6 *cr 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * RCS INFORMATION: 11 * 12 * $RCSfile: import_graphics_plugin.h,v $ 13 * $Author: johns $ $Locker: $ $State: Exp $ 14 * $Revision: 1.5 $ $Date: 2006/04/25 21:32:05 $ 15 * 16 ***************************************************************************/ 17 18 #ifndef IMPORT_GRAPHICS_PLUGIN_H 19 #define IMPORT_GRAPHICS_PLUGIN_H 20 21 /* 22 * API for C extensions to define a way to import low-level graphics primitives 23 */ 24 25 #include "vmdplugin.h" 26 27 /* 28 * Define a common plugin type to be used when registering the plugin. 29 */ 30 #define IMPORT_GRAPHICS_PLUGIN_TYPE "import graphics" 31 32 typedef enum { 33 IMPORT_GRAPHICS_LINE_SOLID, IMPORT_GRAPHICS_LINE_DASHED 34 } import_graphics_linestyle_t; 35 36 /* 37 * Application-provided callbacks for specifying graphics primitives. 38 * Items must be maintained in order by the application for the purpose of 39 * coloring; see below. 40 */ 41 typedef struct { 42 43 /* 44 * Draw a point at the specified location in 3-D space. 45 */ 46 int (* add_point)(void *, const float *x); 47 int (* add_triangle)(void *, const float *x1, const float *x2, const float *x3); 48 int (* add_trinorm)(void *, const float *x1, const float *x2, const float *x3, 49 const float *n1, const float *n2, const float *n3); 50 int (* add_line)(void *, const float *x, const float *y, int line_style, 51 int width); 52 int (* add_cylinder)(void *, const float *x, const float *y, float radius, 53 int resolution, int filled); 54 int (* add_sphere)(void *, const float *x, float rad, int resolution); 55 int (* add_text)(void *, const float *x, const char *text, float size); 56 /* 57 * Color to use for subsequent primitives. If primitives are added before 58 * any call to use_color, the application is free to do whatever it likes. 59 */ 60 int (* use_color)(void *, float r, float g, float b); 61 62 /* 63 * Indicate whether the set of primitives is to be lit or not. Either all 64 * or none of the primitives will be lit. 65 */ 66 int (* use_materials)(void *, int yes_no); 67 } import_graphics_cb_t; 68 69 70 /* 71 * Main file reader API begins here. Any function in this struct may be NULL 72 * if not implemented by the plugin; the application checks this to determine 73 * what functionality is present in the plugin. 74 */ 75 typedef struct { 76 /* 77 * Required header 78 */ 79 vmdplugin_HEAD 80 81 /* 82 * Filename extension for this file type. May be NULL if no filename 83 * extension exists and/or is known. 84 */ 85 const char *filename_extension; 86 87 /* 88 * Try to open the file for reading. Return an opaque handle, or NULL on 89 * failure. filetype should be the name under which this plugin was 90 * registered; this is provided so that plugins can provide the same 91 * function pointer * to handle multiple file types. 92 */ 93 void *(* open_file_read)(const char *filepath, const char *filetype); 94 95 /* 96 * Read data and return it to the application in the supplied 97 * callbacks. The first void * is an opaque application handle which 98 * should be passed to all the callbacks in import_cb_t. The second 99 * void * is the plugin handle returned by open_file_read. 100 */ 101 int (* read_data)(void *, void *mydata, import_graphics_cb_t *); 102 103 /* 104 * Close the file and release all data. The handle cannot be reused. 105 */ 106 void (* close_file_read)(void *); 107 108 } import_graphics_plugin_t; 109 110 #endif 111 112