00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "config.h"
00025 #include "FileRenderList.h"
00026 #include "VMDApp.h"
00027 #include "CmdRender.h"
00028 #include "CommandQueue.h"
00029 #include "Scene.h"
00030 #include "DisplayDevice.h"
00031 #include "TextEvent.h"
00032 #include "Inform.h"
00033 #include <stdlib.h>
00034
00035
00036
00037
00038 #include "ArtDisplayDevice.h"
00039 #include "GelatoDisplayDevice.h"
00040 #include "POV3DisplayDevice.h"
00041 #include "PSDisplayDevice.h"
00042 #include "R3dDisplayDevice.h"
00043 #include "RayShadeDisplayDevice.h"
00044 #include "RadianceDisplayDevice.h"
00045 #include "RenderManDisplayDevice.h"
00046 #include "SnapshotDisplayDevice.h"
00047 #include "STLDisplayDevice.h"
00048 #include "TachyonDisplayDevice.h"
00049 #include "VrmlDisplayDevice.h"
00050 #include "Vrml2DisplayDevice.h"
00051 #include "WavefrontDisplayDevice.h"
00052
00053 #if defined(VMDLIBTACHYON)
00054 #include "LibTachyonDisplayDevice.h"
00055 #endif
00056 #if defined(VMDLIBGELATO)
00057 #include "LibGelatoDisplayDevice.h"
00058 #endif
00059
00060
00061 FileRenderList::FileRenderList(VMDApp *vmdapp) : app(vmdapp) {
00062 add(new SnapshotDisplayDevice(app->display));
00063 #if defined(VMDLIBTACHYON)
00064 add(new LibTachyonDisplayDevice());
00065 #endif
00066 #if defined(VMDLIBGELATO)
00067
00068
00069
00070
00071
00072
00073 if (getenv("GELATOHOME") != NULL) {
00074 add(new LibGelatoDisplayDevice());
00075 }
00076 #endif
00077 add(new TachyonDisplayDevice());
00078 add(new POV3DisplayDevice());
00079 add(new Vrml2DisplayDevice());
00080 add(new RenderManDisplayDevice());
00081 add(new GelatoDisplayDevice());
00082 add(new STLDisplayDevice());
00083 add(new ArtDisplayDevice());
00084 add(new PSDisplayDevice());
00085 add(new RayShadeDisplayDevice());
00086 add(new RadianceDisplayDevice());
00087 add(new R3dDisplayDevice());
00088 add(new VrmlDisplayDevice());
00089 add(new WavefrontDisplayDevice());
00090 }
00091
00092
00093 FileRenderList::~FileRenderList(void) {
00094 for (int i=0;i<renderList.num();i++)
00095 delete renderList.data(i);
00096 }
00097
00098
00099 void FileRenderList::add(FileRenderer *newRenderer) {
00100 if(newRenderer)
00101 renderList.add_name(newRenderer->name, newRenderer);
00102 }
00103
00104
00105 int FileRenderList::num(void) {
00106 return renderList.num();
00107 }
00108
00109
00110 const char *FileRenderList::name(int i) {
00111 if(i>=0 && i < renderList.num()) {
00112 return renderList.name(i);
00113 }
00114 return NULL;
00115 }
00116
00117
00118 FileRenderer *FileRenderList::find(const char *rname) {
00119 int indx = renderList.typecode(rname);
00120
00121 if(indx >= 0)
00122 return renderList.data(indx);
00123 else
00124 return NULL;
00125 }
00126
00127 int FileRenderList::render(const char *filename, const char *method,
00128 const char *extcmd) {
00129 msgInfo << "Rendering current scene to '" << filename << "' ..." << sendmsg;
00130
00131 FileRenderer *render = find(method);
00132 if (!render) {
00133 msgErr << "Invalid render method '" << method << sendmsg;
00134 return FALSE;
00135 }
00136
00137
00138
00139 if (!strcmp(method, "snapshot")) app->display->update(TRUE);
00140 int retval = app->scene->filedraw(render, filename, app->display);
00141 if (!strcmp(method, "snapshot")) app->display->update(TRUE);
00142
00143
00144 if (retval && extcmd && *extcmd != '\0') {
00145 JString strbuf(extcmd);
00146 strbuf.gsub("%s", filename);
00147
00148 int w=100, h=100;
00149 char buf[32];
00150 app->display_get_size(&w, &h);
00151 sprintf(buf, "%d", w);
00152 strbuf.gsub("%w", buf);
00153 sprintf(buf, "%d", h);
00154 strbuf.gsub("%h", buf);
00155 msgInfo << "Executing post-render cmd '" << (const char *)strbuf << "' ..." << sendmsg;
00156 vmd_system(strbuf);
00157 }
00158
00159
00160 msgInfo << "Rendering complete." << sendmsg;
00161 return retval;
00162 }
00163
00164 int FileRenderList::set_render_option(const char *method, const char *option) {
00165 FileRenderer *ren;
00166 ren = find(method);
00167 if (!ren) {
00168 msgErr << "No rendering method '" << method << "' available." << sendmsg;
00169 return FALSE;
00170 }
00171 ren->set_exec_string(option);
00172 return TRUE;
00173 }
00174
00175 int FileRenderList::has_antialiasing(const char *method) {
00176 FileRenderer *ren = find(method);
00177 if (ren) return ren->has_antialiasing();
00178 return 0;
00179 }
00180
00181 int FileRenderList::aalevel(const char *method, int aalevel) {
00182 FileRenderer *ren = find(method);
00183 if (ren) return ren->set_aalevel(aalevel);
00184 return -1;
00185 }
00186
00187 int FileRenderList::imagesize(const char *method, int *w, int *h) {
00188 FileRenderer *ren = find(method);
00189 if (!ren) return FALSE;
00190 return ren->set_imagesize(w, h);
00191 }
00192
00193 int FileRenderList::has_imagesize(const char *method) {
00194 FileRenderer *ren = find(method);
00195 if (!ren) return FALSE;
00196 return ren->has_imagesize();
00197 }
00198
00199 int FileRenderList::aspectratio(const char *method, float *aspect) {
00200 FileRenderer *ren = find(method);
00201 if (!ren) return FALSE;
00202 *aspect = ren->set_aspectratio(*aspect);
00203 return TRUE;
00204 }
00205
00206 int FileRenderList::numformats(const char *method) {
00207 FileRenderer *ren = find(method);
00208 if (!ren) return 0;
00209 return ren->numformats();
00210 }
00211
00212 const char *FileRenderList::format(const char *method, int i) {
00213 FileRenderer *ren = find(method);
00214 if (!ren) return NULL;
00215 if (i < 0) return ren->format();
00216 return ren->format(i);
00217 }
00218
00219 int FileRenderList::set_format(const char *method, const char *format) {
00220 FileRenderer *ren = find(method);
00221 if (!ren) return FALSE;
00222 return ren->set_format(format);
00223 }
00224