Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Vrml.cxx

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/gui/src/Vrml.cxx,v 1.1.1.1 2001/01/04 01:01:11 burnett Exp $
00002 //  Author: T. Burnett
00003 
00004 
00005 #include "Vrml.h"
00006 #include "gui/DisplayRep.h"
00007 
00008 
00009 namespace gui {
00010 
00011 static GraphicsVector currentPoint; // use below to keep track of current point.
00012 
00013 static const  char * setup_string = 
00014 "#VRML V1.0 ascii\n"
00015 "DEF BackgroundColor Info {  string  \"0.8 0.8 0.8\"  }\n"
00016 "FontStyle { size 3}\n"
00017 "Material { emissiveColor  0.5  0.5  0.5  ambientColor 0 0 0  }\n";
00018 
00019 
00020 
00021 Vrml::Vrml(std::ostream& c)
00022 :  _out(c)
00023 ,  _ncoord(0)
00024 {
00025     _out << setup_string;
00026     ViewPort::detail(0);  //should prevent detail check
00027 }
00028 Vrml::~Vrml(){_out.flush();}
00029 
00030 
00031 //-----------------------------------------------------------------------------
00032 //                     drawing
00033 void Vrml::set_quad(int /*quad*/, int /*selected*/)
00034 {
00035     
00036 }
00037 void Vrml::beginSeparator(){   _out << "Separator {\n";}
00038 void Vrml::endSeparator()  {   _out << "}\n"; _ncoord=0; }
00039 
00040 void Vrml::coordinate3(const GraphicsVector* v,int n)
00041 {
00042     _out << "Coordinate3 { point [ \n " ;
00043     for( int i=0; i<n; i++){
00044         _out << v[i].x()<< ' ' << v[i].y()<< ' '<< v[i].z() ;
00045         if( i< n-1 ) _out <<",\n"       ;
00046     }
00047     _out << "] }\n";
00048     _ncoord=n;
00049     currentPoint = v[n-1];
00050 }
00051 void Vrml::indexedLineSet(const int ia[], int n)
00052 {
00053     _out << "IndexedLineSet{ coordIndex[\n";
00054     for(int i=0; i<n; i++){ 
00055         _out << ia[i] ;
00056         if( i< n-1 ) _out << ",";
00057     }
00058     _out << "] }\n";
00059 }
00060 
00061 void Vrml::indexedFaceSet(const int  *ia,int n)
00062 {
00063     _out << "IndexedFaceSet{ coordIndex[\n";
00064     for(int i=0; i<n; i++){ 
00065         _out << ia[i] ;
00066         if( i< n-1 ) _out << ",";
00067     }
00068     _out << "] }\n";
00069 }
00070 void Vrml::lineSet( int n)
00071 {
00072     _out << "IndexedLineSet{ coordIndex[\n";
00073     for(int i=0; i<n; i++) 
00074         _out << i << ',';
00075     _out << -1 << "] }\n";
00076 }
00077 
00078 void Vrml::drawPL(const GraphicsVector* v,int n)
00079 {  
00080     coordinate3(v,n);
00081     lineSet(n);
00082 }
00083 
00084 void Vrml::drawText(const char *text, const GraphicsVector& pnt, int /*ht*/)
00085 {
00086     beginSeparator();
00087     _out << "Transform { translation "
00088         << pnt.x() << ' '<< pnt.y() << ' ' << pnt.z() << "}\n";
00089     _out << "AsciiText { string \"" << text << "\"} \n";
00090     endSeparator();
00091 }
00092 void Vrml::drawText(const char* text)
00093 {
00094     drawText(text, currentPoint);
00095     
00096 }
00097 
00098 
00099 void Vrml::draw_markers(const GraphicsVector* v,int n)
00100 { 
00101     coordinate3(v,n);
00102     _out << "PointSet { startIndex 0 numPoints " << n << "}\n";
00103     
00104 }
00105 // draw markers (points) at the specified points
00106 
00107 void Vrml::flush(){
00108     _out.flush();
00109 }
00110 // flush accumulated drawing commands
00111 
00112 
00113 //-----------------------------------------------------------------------
00114 //  functions for setting drawing attributes
00115 
00116 void Vrml::set_rgb( float r, float g, float b )
00117 {
00118     _out << "Material { emissiveColor "<< r << ' '<< g <<' '<< b << "}\n";
00119 }
00120 void Vrml::set_col_index(int index)
00121 {
00122     DisplayRep::ColorInfo& cinfo = DisplayRep::pallete[index];
00123     set_rgb(cinfo.r/255., cinfo.g/255., cinfo.b/255.);
00124 }
00125 
00126 void Vrml::set_marker_size(float ){}
00127 void Vrml::set_line_width( float  ){}
00128 
00129 void Vrml::set_line_style( int ){}
00130 
00131 void Vrml::set_cap_style(int ){}
00132 void Vrml::setJoinStyle(int ){}
00133 
00134 void Vrml::setBkColIndex(int ){}
00135 void Vrml::set_enhanced(int){}
00136 
00137 //-----------------------------------------------------------------------------
00138 //             stuff associated with projection
00139 /*
00140 void Vrml::setProjection()
00141 {
00142 glMatrixMode(GL_PROJECTION);
00143 float projection[]=
00144 {zoomFactor,0,   0,   0
00145 ,0,   zoomFactor*aspectRatio,0,   0
00146 ,0,   0,   -zoomFactor, -zoomFactor*perspective
00147 ,0,   0,   0,   1};
00148 
00149   glLoadMatrixf(projection);
00150   
00151     glMultMatrixf(R);
00152     
00153       glScalef(1/scale,1/scale,1/scale);     // overall scale
00154       glTranslatef(-center->x(),-center->y(),-center->z()); // negative of origin  
00155       glMatrixMode(GL_MODELVIEW);
00156       }
00157 */
00158 } // namespace gui
00159 
00160 
00161 
00162 

Generated at Wed Nov 21 12:20:55 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000