Public Member Functions | |
ClipperCircle () | |
void | Begin (Map &map, tCoord const &e1, tCoord const &e2) |
void | End () |
Static Public Member Functions | |
static Clipper * | create () |
Private Member Functions | |
void | Clip (int i, tCoord const &u, tCoord const &v) |
Private Attributes | |
int | m_edges |
Definition at line 107 of file cMap.h.
cWidget::Map::ClipperCircle::ClipperCircle | ( | ) |
Definition at line 104 of file cMap.cpp.
References a, tCoord::x, and tCoord::y.
Referenced by Begin().
00104 { 00105 //glBegin(GL_LINES); 00106 //Color(1,0,0); 00107 //Vertex(u.x, u.y); 00108 //Color(0,1,0); 00109 //Vertex(v.x, v.y); 00110 //glEnd(); 00111 if(u.x == v.x) { 00112 GLdouble factor = (u.y>v.y) ? 1 : -1; 00113 GLdouble pl[4] = {factor*1.0, 0.0, 0.0, -factor*v.x }; 00114 glClipPlane(GL_CLIP_PLANE0+i, pl); 00115 glEnable(GL_CLIP_PLANE0+i); 00116 } else { 00117 GLdouble factor = (u.x<v.x) ? -1 : 1; 00118 GLdouble a = (v.y-u.y)/(v.x-u.x); 00119 GLdouble pl[4] = { 00120 factor*-a, 00121 factor, 00122 0., 00123 factor*-(u.y-a*u.x) 00124 }; 00125 glClipPlane(GL_CLIP_PLANE0+i, pl); 00126 glEnable(GL_CLIP_PLANE0+i); 00127 } 00128 }
static Clipper* cWidget::Map::ClipperCircle::create | ( | ) | [inline, static] |
Definition at line 111 of file cMap.h.
Referenced by cWidget::Map::Mode::Mode().
00111 {return new ClipperCircle;}
void cWidget::Map::ClipperCircle::Begin | ( | Map & | map, | |
tCoord const & | e1, | |||
tCoord const & | e2 | |||
) | [virtual] |
Implements cWidget::Map::Clipper.
Definition at line 129 of file cMap.cpp.
References ab, rGradient::BeginDraw(), Clip(), cos(), rGradient::DrawPoint(), glBegin, glEnd, cWidget::WithBackground::m_background, m_edges, cWidget::WithForeground::m_foreground, M_PI, rGradient::SetGradientEdges(), sin(), tCoord::x, and tCoord::y.
00129 { 00130 tCoord centre = .5*(e1+e2); 00131 tCoord ab = .5*(e2-e1); 00132 ab.x = fabs(ab.x); ab.y = fabs(ab.y); 00133 float stepsize=M_PI*2/m_edges; 00134 00135 map.m_background.BeginDraw(); 00136 map.m_background.SetGradientEdges(centre - ab, centre + ab); 00137 glBegin(GL_POLYGON); 00138 for(int i = 0; i < m_edges; ++i) { 00139 float t = (i+1)*stepsize; 00140 tCoord next(centre.x+ab.x*cos(t), centre.y-ab.y*sin(t)); 00141 map.m_background.DrawPoint(next); 00142 } 00143 glEnd(); 00144 glDisable(GL_TEXTURE_2D); 00145 tCoord last = centre + tCoord(ab.x, 0); 00146 map.m_foreground.SetGradientEdges(centre - ab, centre + ab); 00147 map.m_foreground.BeginDraw(); 00148 for(int i = 0; i < m_edges; ++i) { 00149 float t = (i+1)*stepsize; 00150 tCoord next(centre.x+ab.x*cos(t), centre.y-ab.y*sin(t)); 00151 glBegin(GL_LINES); 00152 glVertex2f(next.x, next.y); 00153 glVertex2f(last.x, last.y); 00154 map.m_foreground.DrawPoint(next); 00155 map.m_foreground.DrawPoint(last); 00156 glEnd(); 00157 Clip(i, last, next); 00158 last = next; 00159 } 00160 glDisable(GL_TEXTURE_2D); 00161 }
void cWidget::Map::ClipperCircle::End | ( | void | ) | [virtual] |
Implements cWidget::Map::Clipper.
Definition at line 162 of file cMap.cpp.
References m_edges.
00162 { 00163 for(int i = 0; i < m_edges; ++i) { 00164 glDisable(GL_CLIP_PLANE0 + i); //according to the documentation you're allowed to do that 00165 } 00166 }
int cWidget::Map::ClipperCircle::m_edges [private] |