home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / freedraft.tar.gz / freedraft.tar / FREEdraft-050298 / DRAWABLES / drawablearc.cpp < prev    next >
C/C++ Source or Header  |  1998-04-23  |  2KB  |  64 lines

  1. // drawablearc.cpp
  2.  
  3. // Copyright (C) 1997  Cliff Johnson                                       //
  4. //                                                                         //
  5. // This program is free software; you can redistribute it and/or           //
  6. // modify it under the terms of the GNU  General Public                    //
  7. // License as published by the Free Software Foundation; either            //
  8. // version 2 of the License, or (at your option) any later version.        //
  9. //                                                                         //
  10. // This software is distributed in the hope that it will be useful,        //
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       //
  13. // General Public License for more details.                                //
  14. //                                                                         //
  15. // You should have received a copy of the GNU General Public License       //
  16. // along with this software (see COPYING); if not, write to the        //
  17. // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
  18.  
  19. #include <geom_enum.h>
  20. #include <drawablearc.h>
  21. #include <GL/gl.h>
  22. #include <GL/glu.h>
  23. #include <point.h>
  24. #include <arc.h>
  25.  
  26. DrawableArc::DrawableArc(): DrawableGeom(ARC) {}
  27.  
  28. void DrawableArc::Draw(const Geom* geom,const float& scale) const
  29. {
  30.     if(DrawableGeom::Type()!=ARC)return;
  31.  
  32.     Arc c = Arc(*(reinterpret_cast<const Arc* >(geom) ) );
  33.  
  34.         glBegin(GL_LINE_STRIP);
  35.         Point p;    
  36.         double u,du;
  37.         du  = 1./37.;
  38.         for(int i=0; i<=37; i++){
  39.             u = du * i;
  40.             p = c.U(u);
  41.                     glVertex2f(p[0],p[1]);
  42.         }
  43.         glEnd();
  44. }
  45.  
  46. void DrawableArc::Select(const Geom* geom,const Handle& h,const float& scale) const
  47. {
  48.     if(DrawableGeom::Type()!=ARC)return;
  49.  
  50.     glLoadName(h.Value());
  51.  
  52.     Arc c = Arc(*(reinterpret_cast<const Arc* >(geom) ) );
  53.         glBegin(GL_LINE_STRIP);
  54.         Point p;    
  55.         double u,du;
  56.         du  = 1./37.;
  57.         for(int i=0; i<=37; i++){
  58.             u = du * i;
  59.             p = c.U(u);
  60.                     glVertex2f(p[0],p[1]);
  61.         }
  62.         glEnd();
  63. }
  64.