proj home

Files   Classes   Functions   Hierarchy  

plotpolartest.cpp

Go to the documentation of this file.
00001 #include <GL/glut.h>
00002 #include <GL/gl.h>
00003 
00004 #include <gobj.h>
00005 #include <graphmisc.h>
00006 #include <plotpolartest.h>
00007 #include <zpr.h>
00008 
00009 
00010 void plotpolartest::keyboard01
00011 (
00012   unsigned char key, 
00013   int x, 
00014   int y
00015 )
00016 {
00017   switch (key)
00018   {
00019     case 27: exit(0); break;
00020   }
00021 }
00022 
00023 
00024 void plotpolartest::display01()
00025 { 
00026   myglPushMatrixMode temp;
00027   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00028 
00029   assert(gobj::global!=0);
00030   gobj::global->draw();
00031 
00032   glerrordisplay();
00033   
00034   glutSwapBuffers();
00035 }
00036 
00037 
00038 int plotpolartest::test01(int argc, char** & argv)
00039 {
00040   glutInit(&argc,argv);
00041   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00042   uintc wx=800;
00043   uintc wy=800;
00044 
00045   glutInitWindowSize(wx,wy);
00046 
00047   glutCreateWindow("");
00048 
00049   glutDisplayFunc(display01);
00050   glutKeyboardFunc(keyboard01);
00051 
00052   OpenGLinitialisation();
00053 
00054   glEnable(GL_DEPTH_TEST);
00055   glEnable(GL_CULL_FACE);
00056 
00057   xGraphics.set();
00058 
00059 
00060   //  Create the heart plot of points.
00061 
00062   vector< point2<double> > v;
00063  
00064   uintc n=50;
00065   // The degrees are converted to radians.
00066   double dt = PI * 2.0 / n;
00067 
00068   for (uint i=0; i<n; ++i)
00069   {
00070     v.push_back( point2<double>(1.0+cos(dt*i),dt*i) );
00071     //v.push_back( point2<double>(1.0,dt*i) );
00072   }
00073 
00074   plotpolar * plt = new plotpolar();
00075   plt->adddatapointsinPolarRadians(v);
00076   //plt->addpoints(255,0,0);
00077   plt->addcrosses(0,255,0,0.05);
00078   xGraphics.push(plt);
00079 
00080   protractor * prot = new protractor(2.5);
00081   prot->addAxes(8);
00082   prot->addCircles(5);
00083 
00084   stringc nms[] = 
00085   { 
00086     "0", "45", "90", "135", "180", 
00087     "225", "270", "315" 
00088   };
00089   vector<string> ang(nms,nms+8);
00090 
00091   prot->addCirclesText(ang);
00092 
00093   prot->addRadiusRuler(0.15, 0.1, 0.05);
00094 
00095   prot->addAngleRuler(0.15, 0.1, 0.05);
00096   
00097   
00098   xGraphics.push(prot);
00099 
00100   zpr zz;
00101 
00102   zz.update();
00103   glutMainLoop();
00104 
00105 
00106   
00107   return 0; 
00108 }
00109 
00110 

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