00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2006 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: import_graphics_plugin.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.5 $ $Date: 2006/04/25 21:32:05 $ 00015 * 00016 ***************************************************************************/ 00017 00018 #ifndef IMPORT_GRAPHICS_PLUGIN_H 00019 #define IMPORT_GRAPHICS_PLUGIN_H 00020 00021 /* 00022 * API for C extensions to define a way to import low-level graphics primitives 00023 */ 00024 00025 #include "vmdplugin.h" 00026 00027 /* 00028 * Define a common plugin type to be used when registering the plugin. 00029 */ 00030 #define IMPORT_GRAPHICS_PLUGIN_TYPE "import graphics" 00031 00032 typedef enum { 00033 IMPORT_GRAPHICS_LINE_SOLID, IMPORT_GRAPHICS_LINE_DASHED 00034 } import_graphics_linestyle_t; 00035 00036 /* 00037 * Application-provided callbacks for specifying graphics primitives. 00038 * Items must be maintained in order by the application for the purpose of 00039 * coloring; see below. 00040 */ 00041 typedef struct { 00042 00043 /* 00044 * Draw a point at the specified location in 3-D space. 00045 */ 00046 int (* add_point)(void *, const float *x); 00047 int (* add_triangle)(void *, const float *x1, const float *x2, const float *x3); 00048 int (* add_trinorm)(void *, const float *x1, const float *x2, const float *x3, 00049 const float *n1, const float *n2, const float *n3); 00050 int (* add_line)(void *, const float *x, const float *y, int line_style, 00051 int width); 00052 int (* add_cylinder)(void *, const float *x, const float *y, float radius, 00053 int resolution, int filled); 00054 int (* add_sphere)(void *, const float *x, float rad, int resolution); 00055 int (* add_text)(void *, const float *x, const char *text, float size); 00056 /* 00057 * Color to use for subsequent primitives. If primitives are added before 00058 * any call to use_color, the application is free to do whatever it likes. 00059 */ 00060 int (* use_color)(void *, float r, float g, float b); 00061 00062 /* 00063 * Indicate whether the set of primitives is to be lit or not. Either all 00064 * or none of the primitives will be lit. 00065 */ 00066 int (* use_materials)(void *, int yes_no); 00067 } import_graphics_cb_t; 00068 00069 00070 /* 00071 * Main file reader API begins here. Any function in this struct may be NULL 00072 * if not implemented by the plugin; the application checks this to determine 00073 * what functionality is present in the plugin. 00074 */ 00075 typedef struct { 00076 /* 00077 * Required header 00078 */ 00079 vmdplugin_HEAD 00080 00081 /* 00082 * Filename extension for this file type. May be NULL if no filename 00083 * extension exists and/or is known. 00084 */ 00085 const char *filename_extension; 00086 00087 /* 00088 * Try to open the file for reading. Return an opaque handle, or NULL on 00089 * failure. filetype should be the name under which this plugin was 00090 * registered; this is provided so that plugins can provide the same 00091 * function pointer * to handle multiple file types. 00092 */ 00093 void *(* open_file_read)(const char *filepath, const char *filetype); 00094 00095 /* 00096 * Read data and return it to the application in the supplied 00097 * callbacks. The first void * is an opaque application handle which 00098 * should be passed to all the callbacks in import_cb_t. The second 00099 * void * is the plugin handle returned by open_file_read. 00100 */ 00101 int (* read_data)(void *, void *mydata, import_graphics_cb_t *); 00102 00103 /* 00104 * Close the file and release all data. The handle cannot be reused. 00105 */ 00106 void (* close_file_read)(void *); 00107 00108 } import_graphics_plugin_t; 00109 00110 #endif 00111