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 #if defined(VMDLIBTACHYON)
00041 #include "LibTachyonDisplayDevice.h"
00042 #endif
00043 #if defined(VMDLIBGELATO)
00044 #include "LibGelatoDisplayDevice.h"
00045 #endif
00046 #include "MayaDisplayDevice.h"
00047 #include "POV3DisplayDevice.h"
00048 #include "PSDisplayDevice.h"
00049 #include "R3dDisplayDevice.h"
00050 #include "RadianceDisplayDevice.h"
00051 #include "RayShadeDisplayDevice.h"
00052 #include "RenderManDisplayDevice.h"
00053 #include "SnapshotDisplayDevice.h"
00054 #include "STLDisplayDevice.h"
00055 #include "TachyonDisplayDevice.h"
00056 #include "VrmlDisplayDevice.h"
00057 #include "Vrml2DisplayDevice.h"
00058 #include "WavefrontDisplayDevice.h"
00059 #include "X3DDisplayDevice.h"
00060
00061
00062
00063 FileRenderList::FileRenderList(VMDApp *vmdapp) : app(vmdapp) {
00064 add(new ArtDisplayDevice());
00065 add(new GelatoDisplayDevice());
00066 #if defined(VMDLIBGELATO)
00067
00068
00069
00070
00071
00072
00073 if (getenv("GELATOHOME") != NULL) {
00074 add(new LibGelatoDisplayDevice());
00075 }
00076 #endif
00077
00078
00079 if (getenv("VMDENABLEMAYA") != NULL) {
00080 add(new MayaDisplayDevice());
00081 }
00082 add(new PSDisplayDevice());
00083 add(new R3dDisplayDevice());
00084 add(new RadianceDisplayDevice());
00085 add(new RayShadeDisplayDevice());
00086 add(new RenderManDisplayDevice());
00087 add(new SnapshotDisplayDevice(app->display));
00088 add(new STLDisplayDevice());
00089 add(new TachyonDisplayDevice());
00090 #if defined(VMDLIBTACHYON)
00091 add(new LibTachyonDisplayDevice());
00092 #endif
00093 add(new POV3DisplayDevice());
00094 add(new VrmlDisplayDevice());
00095 add(new Vrml2DisplayDevice());
00096 add(new WavefrontDisplayDevice());
00097 add(new X3DDisplayDevice());
00098 add(new X3DOMDisplayDevice());
00099 }
00100
00101
00102 FileRenderList::~FileRenderList(void) {
00103 for (int i=0;i<renderList.num();i++)
00104 delete renderList.data(i);
00105 }
00106
00107
00108 void FileRenderList::add(FileRenderer *newRenderer) {
00109 if (newRenderer)
00110 renderList.add_name(newRenderer->name, newRenderer);
00111 }
00112
00113
00114 int FileRenderList::num(void) {
00115 return renderList.num();
00116 }
00117
00118
00119 const char *FileRenderList::name(int i) {
00120 if (i>=0 && i < renderList.num()) {
00121 return renderList.name(i);
00122 }
00123 return NULL;
00124 }
00125
00126
00127
00128 const char *FileRenderList::pretty_name(int i) {
00129 if (i>=0 && i < renderList.num()) {
00130 const FileRenderer * fr = renderList.data(i);
00131 return fr->pretty_name();
00132 }
00133 return NULL;
00134 }
00135
00136
00137 FileRenderer *FileRenderList::find(const char *rname) {
00138 int indx = renderList.typecode(rname);
00139
00140 if (indx >= 0)
00141 return renderList.data(indx);
00142 else
00143 return NULL;
00144 }
00145
00146
00147 FileRenderer *FileRenderList::find_pretty_name(const char *pretty) {
00148 int i;
00149 for (i=0; i<renderList.num(); i++) {
00150 if (!strcmp(pretty_name(i), pretty)) {
00151 return renderList.data(i);
00152 }
00153 }
00154 return NULL;
00155 }
00156
00157
00158 const char *FileRenderList::find_short_name_from_pretty_name(const char *pretty) {
00159 const FileRenderer *fr = find_pretty_name(pretty);
00160 if (fr)
00161 return fr->visible_name();
00162 return NULL;
00163 }
00164
00165 int FileRenderList::render(const char *filename, const char *method,
00166 const char *extcmd) {
00167 msgInfo << "Rendering current scene to '" << filename << "' ..." << sendmsg;
00168
00169 FileRenderer *render = find(method);
00170 if (!render) {
00171 msgErr << "Invalid render method '" << method << sendmsg;
00172 return FALSE;
00173 }
00174
00175
00176
00177 if (!strcmp(method, "snapshot")) app->display->update(TRUE);
00178 int retval = app->scene->filedraw(render, filename, app->display);
00179 if (!strcmp(method, "snapshot")) app->display->update(TRUE);
00180
00181
00182 if (retval && extcmd && *extcmd != '\0') {
00183 JString strbuf(extcmd);
00184 strbuf.gsub("%s", filename);
00185
00186 int w=100, h=100;
00187 char buf[32];
00188 app->display_get_size(&w, &h);
00189 sprintf(buf, "%d", w);
00190 strbuf.gsub("%w", buf);
00191 sprintf(buf, "%d", h);
00192 strbuf.gsub("%h", buf);
00193 msgInfo << "Executing post-render cmd '" << (const char *)strbuf << "' ..." << sendmsg;
00194 vmd_system(strbuf);
00195 }
00196
00197
00198 msgInfo << "Rendering complete." << sendmsg;
00199 return retval;
00200 }
00201
00202 int FileRenderList::set_render_option(const char *method, const char *option) {
00203 FileRenderer *ren;
00204 ren = find(method);
00205 if (!ren) {
00206 msgErr << "No rendering method '" << method << "' available." << sendmsg;
00207 return FALSE;
00208 }
00209 ren->set_exec_string(option);
00210 return TRUE;
00211 }
00212
00213 int FileRenderList::has_antialiasing(const char *method) {
00214 FileRenderer *ren = find(method);
00215 if (ren) return ren->has_antialiasing();
00216 return 0;
00217 }
00218
00219 int FileRenderList::aasamples(const char *method, int aasamples) {
00220 FileRenderer *ren = find(method);
00221 if (ren) return ren->set_aasamples(aasamples);
00222 return -1;
00223 }
00224
00225 int FileRenderList::aosamples(const char *method, int aosamples) {
00226 FileRenderer *ren = find(method);
00227 if (ren) return ren->set_aosamples(aosamples);
00228 return -1;
00229 }
00230
00231 int FileRenderList::imagesize(const char *method, int *w, int *h) {
00232 FileRenderer *ren = find(method);
00233 if (!ren) return FALSE;
00234 return ren->set_imagesize(w, h);
00235 }
00236
00237 int FileRenderList::has_imagesize(const char *method) {
00238 FileRenderer *ren = find(method);
00239 if (!ren) return FALSE;
00240 return ren->has_imagesize();
00241 }
00242
00243 int FileRenderList::aspectratio(const char *method, float *aspect) {
00244 FileRenderer *ren = find(method);
00245 if (!ren) return FALSE;
00246 *aspect = ren->set_aspectratio(*aspect);
00247 return TRUE;
00248 }
00249
00250 int FileRenderList::numformats(const char *method) {
00251 FileRenderer *ren = find(method);
00252 if (!ren) return 0;
00253 return ren->numformats();
00254 }
00255
00256 const char *FileRenderList::format(const char *method, int i) {
00257 FileRenderer *ren = find(method);
00258 if (!ren) return NULL;
00259 if (i < 0) return ren->format();
00260 return ren->format(i);
00261 }
00262
00263 int FileRenderList::set_format(const char *method, const char *format) {
00264 FileRenderer *ren = find(method);
00265 if (!ren) return FALSE;
00266 return ren->set_format(format);
00267 }
00268