Files Classes Functions Hierarchy
00001 #include <cassert> 00002 #include <set> 00003 using namespace std; 00004 00005 #include <pathlinesegdraw.h> 00006 #include <pointsdisplay.h> 00007 #include <print.h> 00008 00009 00010 void pathlinesegdraw::defaultgraphics() 00011 { 00012 pointsdraw=false; 00013 pointsnumber=true; 00014 curvepointsdraw=true; 00015 controldraw=true; 00016 segsdraw=true; 00017 } 00018 00019 void pathlinesegdraw::update() 00020 { 00021 if (ps==0) 00022 return; 00023 // Changing displaying control points, 00024 // segments, segment end points. 00025 nuke(); 00026 00027 push(new gobjglPushAttrib("GL_CURRENT_BIT")); 00028 push(new gobjglPushAttrib("GL_LIGHTING_BIT")); 00029 00030 push(new gobjglColor3f(0.0,0.0,1.0)); 00031 push(new gobjglDisable(GL_LIGHTING)); 00032 00033 00034 double radius=0.01; 00035 00036 typedef point2<double> pt2; 00037 00038 pointsdisplay2D< pt2 > pd(*this,ps->pts,pointsdraw,pointsnumber); 00039 if (pd.gq ) 00040 { pd.gq->radius=radius; } 00041 00042 push(new gobjglColor3f(0.0,1.0,0.0)); 00043 00044 // Problems with compiler??? Using explicit std 00045 { 00046 std::set< uint > segpts( 00047 ps->segments.begin(), 00048 ps->segments.end()); 00049 vector< pt2 > si; 00050 for (std::set< uint >::iterator k=segpts.begin(); 00051 k!= segpts.end(); ++k) 00052 { si.push_back( ps->pts[*k] ); } 00053 cout << SHOW(si.size()) << endl; 00054 cout << printvecfunc(&si[0],si.size()) << endl; 00055 00056 00057 pointsdisplay2D< pt2 > pd2(*this,si,curvepointsdraw,false,false); 00058 if (pd2.gq) 00059 pd2.gq->radius=radius; 00060 } 00061 00062 // Draw control points. 00063 vector< pt2 > vc; 00064 uint imax=ps->control.size(); 00065 uint ptssize=ps->pts.size(); 00066 for (uint i=0; i<imax; ++i) 00067 { 00068 assert(ps->control[i]<ptssize); 00069 cout << SHOW(ps->control[i]) << " "; 00070 vc.push_back( ps->pts[ps->control[i]] ); 00071 } 00072 cout << endl; 00073 cout << printvecfunc(vc.begin(),vc.size()) << endl; 00074 00075 push(new gobjglColor3ub(153,50,204)); 00076 pointsdisplay2D< pt2 > pc(*this,vc,controldraw,false,false); 00077 if (pc.gq) 00078 pc.gq->radius=radius*2.0; 00079 00080 00081 push(new gobjglColor3ub(255,0,0)); 00082 push(new gobjglBegin("GL_LINES")); 00083 00084 imax=ps->segments.size(); 00085 for (uint i=0; i<imax; ++i ) 00086 { 00087 point2<double>& px(ps->pts[ps->segments[i]]); 00088 push(new gobjglVertex2f(px.x,px.y)); 00089 } 00090 00091 push(new gobjglEnd()); 00092 push(new gobjglPopAttrib()); 00093 push(new gobjglPopAttrib()); 00094 } 00095 00096 void pathlinesegdraw::draw() 00097 { 00098 if (ps==0) 00099 return; 00100 00101 gobjContainer::draw(); 00102 } 00103 00104 pathlinesegdraw::pathlinesegdraw(boolc mem_) 00105 : ps(0), mem(mem_) 00106 { 00107 defaultgraphics(); 00108 } 00109 00110 pathlinesegdraw::pathlinesegdraw(pathlineseg* ps_, boolc mem_) 00111 : ps(ps_), mem(mem_) 00112 { 00113 defaultgraphics(); 00114 assert(ps!=0); 00115 if (ps==0) 00116 return; 00117 update(); 00118 } 00119 00120 pathlinesegdraw::~pathlinesegdraw() 00121 { 00122 if (mem) 00123 delete ps; 00124 ps=0; 00125 } 00126 00127
1.5.8