/* -*- C++ -*- * Copyright ©2004 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #include "mdisplay.h" #include "magellan/parsertools.h" #include "magellan/configuration.h" #include "plugininfo_display.h" PluginInfo* MDisplay::getmodules(int i) { if(i == 0) { PluginInfo_Display* di = new PluginInfo_Display(); di->name = "Display Builtin"; di->author = "Hugo Mills"; di->version = 0x10000; di->parser = MDisplay::parse; return di; } else return NULL; } MDisplay* MDisplay::parse( ConfigLexer* lex, const std::string& type, const std::string& subtype ) { if(type != "") return NULL; std::string vpt, orb, cnt, prj; while(!lex->eos()) { if(readkeyedvalue(lex, "viewport", &vpt) || readkeyedvalue(lex, "orbit", &orb) || readkeyedvalue(lex, "content", &cnt) || readkeyedvalue(lex, "projection", &prj) ) ; else throw(UnknownConfigToken(lex)); } return new MDisplay(vpt, prj, orb, cnt); } MDisplay::~MDisplay() { delete sphere; } Plugin* MDisplay::bind(Configuration* conf) { if(viewport == NULL) { viewport = conf->getviewport(viewport_name); if(viewport == NULL) return NULL; } if(projection == NULL) { projection = conf->getprojection(projection_name); if(projection == NULL) return NULL; } if(orbit == NULL) { orbit = conf->getorbit(orbit_name); if(orbit == NULL) return NULL; } if(content == NULL) { content = conf->getcontent(content_name); if(content == NULL) return NULL; } sphere = new XfSphere(); return this; } bool MDisplay::isbound() const { return viewport != NULL && projection != NULL && orbit != NULL && content != NULL; } void MDisplay::plot(Output* output, XfView* realview) { if(isbound()) { content->plot(output, realview, projection, orbit, sphere); } else { std::cerr << "Attempt to plot an unbound MDisplay. Ignoring." << std::endl; } }