proj home

Files   Classes   Functions   Hierarchy  

arcdraw.cpp

Go to the documentation of this file.
00001 #include <arcdraw.h>
00002 #include <graphmisc.h>
00003 
00004 #define SHOW(x) #x << '=' << (x)
00005 
00006 
00007 arcdraw::arcdraw(arc const & ac_)
00008 {
00009   init(ac_);
00010 }
00011 
00012 void arcdraw::init(arc const & ac_)
00013 {
00014   ac = & ac_;
00015   enableCenter=true;
00016   enableEndPoints=true;
00017   enableArc=true;
00018 
00019   update();
00020 }
00021 
00022 void arcdraw::update()
00023 {
00024   assert(ac!=0);
00025 
00026   gobjContainer & g(graphicsdeffered);
00027   g.nuke();
00028 
00029   if (ac->isStraightLine())
00030   {
00031     g.push( new gobjglColor3f(1.0,0.0,0.0) );
00032     g.push( new gobjglBegin(GL_LINE) );
00033 
00034     g.push( new gobjglVertex3f(ac->p0) );
00035     g.push( new gobjglVertex3f(ac->p1) );
00036 
00037     g.push( new gobjglEnd() );
00038     return;
00039   }
00040 
00041   gobjQuadric * q = new gobjQuadric();
00042   q->radius=.02;
00043   g.push(q);
00044 
00045   if (enableCenter)
00046   {
00047     g.push( new gobjglColor3f(0.0,1.0,0.0) );
00048     g.push( new gobjMySphereDraw(ac->center,q) );
00049 
00050     // Two lines from the center to the end points.
00051     static bool togglecolor=false;
00052 
00053     if (togglecolor)
00054       g.push( new gobjglColor3ub(34,139,34) );
00055     else
00056       g.push( new gobjglColor3ub(139,0,139) );
00057     togglecolor = !togglecolor;
00058       
00059     g.push( new gobjglEnable(GL_LINE_STIPPLE) );
00060     g.push( new gobjglLineStipple(1,0x0101) );
00061     g.push( new gobjglBegin(GL_LINE) );
00062 
00063     g.push( new gobjglVertex3f(ac->center) );
00064     g.push( new gobjglVertex3f(ac->p0) );
00065     g.push( new gobjglVertex3f(ac->center) );
00066     g.push( new gobjglVertex3f(ac->p1) );
00067 
00068     g.push( new gobjglEnd() );
00069     g.push( new gobjglDisable(GL_LINE_STIPPLE) );
00070 
00071   }
00072 
00073   if (enableArc)
00074   {
00075 //    g.push( new gobjglPushAttrib(GL_CURRENT_BIT) );
00076 //    g.push( new gobjglPushAttrib(GL_LIGHTING_BIT) );
00077     g.push( new gobjglDisable(GL_LIGHTING) );
00078     g.push( new gobjglColor3f(1.0,0.0,0.0) );
00079 
00080 //cout << SHOW(ac) << endl;
00081 //cout << SHOW(ac->center) << endl;
00082 //cout << SHOW (ac->phi0()*180.0/PI) << endl;
00083 //cout << SHOW (ac->phi1()*180.0/PI) << endl;
00084     double theta0 = ac->phi0;
00085     double theta1 = ac->phi1;
00086 /*
00087     if (theta0>theta1)
00088     {
00089       double temp = theta0;
00090       theta0 = theta1;
00091       theta1 = temp;
00092     }
00093 */
00094 //cout << SHOW (theta0*180.0/PI) << endl;
00095 //cout << SHOW (theta1*180.0/PI) << endl;
00096 
00097     gobjMyCircle * c2;
00098     if (ac->isAntiClockwise())
00099       c2=new gobjMyCircle(theta0,theta1,abs(ac->radius));
00100     else
00101       c2=new gobjMyCircle(theta1,theta0,abs(ac->radius));
00102 
00103     g.push( new gobjMyCircleDraw(ac->center,*c2) );
00104 
00105 //    g.push( new gobjglPopAttrib() );
00106 //    g.push( new gobjglPopAttrib() );
00107   }
00108 
00109   if (enableEndPoints)
00110   {
00111 //    g.push( new gobjglEnable(GL_LIGHTING) );
00112     g.push( new gobjglColor3f(0.0,0.0,1.0) );
00113     g.push( new gobjMySphereDraw(ac->p0,q) );
00114     g.push( new gobjMySphereDraw(ac->p1,q) );
00115   }
00116 }
00117 
00118 void arcdraw::draw()
00119 {
00120   graphicsdeffered.draw();
00121 }
00122 

Generated on Fri Mar 4 00:49:25 2011 for Chelton Evans Source by  doxygen 1.5.8