proj home

Files   Classes   Functions   Hierarchy  

arcdraw Class Reference

Arc drawer. More...

#include <arcdraw.h>

Inheritance diagram for arcdraw:
Collaboration diagram for arcdraw:

List of all members.

Public Member Functions

 arcdraw (arc const &ac_)
 The arc's display is enabled by default.
void init (arc const &ac_)
 Associate this arc with this arc drawer.
void draw ()
 Draw the arc.
void update ()
 If the arcs parameters changed update() needs to be called before the arc is redrawn else the changes will not be displayed.

Public Attributes

bool enableCenter
 Toggle the center display of the circle.
bool enableEndPoints
 Toggle the endpoints.
bool enableArc
 Toggle the arc.


Detailed Description

Arc drawer.

This class uses an existing arc as a reference and displays it. If this arc is destroyed it is the clients responsibility to no longer use the associated arcdrawer (dangling pointer problem).

Definition at line 17 of file arcdraw.h.


Constructor & Destructor Documentation

arcdraw::arcdraw ( arc const &  ac_  ) 

The arc's display is enabled by default.

Definition at line 7 of file arcdraw.cpp.

References init().

00008 {
00009   init(ac_);
00010 }


Member Function Documentation

void arcdraw::draw (  )  [virtual]

Draw the arc.

Implements gobj.

Definition at line 118 of file arcdraw.cpp.

References gobjContainer::draw().

00119 {
00120   graphicsdeffered.draw();
00121 }

void arcdraw::init ( arc const &  ac_  ) 

Associate this arc with this arc drawer.

Definition at line 12 of file arcdraw.cpp.

References enableArc, enableCenter, enableEndPoints, and update().

Referenced by arcdraw().

00013 {
00014   ac = & ac_;
00015   enableCenter=true;
00016   enableEndPoints=true;
00017   enableArc=true;
00018 
00019   update();
00020 }

void arcdraw::update (  ) 

If the arcs parameters changed update() needs to be called before the arc is redrawn else the changes will not be displayed.

Definition at line 22 of file arcdraw.cpp.

References arc::center, enableArc, enableCenter, enableEndPoints, arc::isAntiClockwise(), arc::isStraightLine(), gobjContainer::nuke(), arc::p0, arc::p1, arc::phi0, arc::phi1, gobjContainer::push(), arc::radius, and gobjQuadric::radius.

Referenced by init().

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 }


Member Data Documentation

Toggle the arc.

Definition at line 31 of file arcdraw.h.

Referenced by init(), and update().

Toggle the center display of the circle.

Definition at line 27 of file arcdraw.h.

Referenced by init(), and update().

Toggle the endpoints.

Definition at line 29 of file arcdraw.h.

Referenced by init(), and update().


The documentation for this class was generated from the following files:

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