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

  1. // drawablesegment.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 <drawablesegment.h>
  21. #include <GL/gl.h>
  22. #include <GL/glu.h>
  23. #include <point.h>
  24. #include <segment.h>
  25.  
  26. DrawableSegment::DrawableSegment(): DrawableGeom(SEGMENT) {}
  27.  
  28. void DrawableSegment::Draw(const Geom* geom,const float& scale) const
  29. {
  30.     if(DrawableGeom::Type()!=SEGMENT)return;
  31.  
  32.     Segment l = Segment(*(reinterpret_cast<const Segment* >(geom) ) );
  33.         Point p0 = l.Origin();
  34.         Point p1 = l.Endpoint();
  35.  
  36.         glBegin(GL_LINES);
  37.                 glVertex2f(p0[0],p0[1]);
  38.                 glVertex2f(p1[0],p1[1]);
  39.         glEnd();
  40. }
  41.  
  42. void DrawableSegment::Select(const Geom* geom,const Handle& h,const float& scale) const
  43. {
  44.     if(DrawableGeom::Type()!=SEGMENT)return;
  45.  
  46.     glLoadName(h.Value());
  47.  
  48.     Segment l = Segment(*(reinterpret_cast<const Segment* >(geom) ) );
  49.         Point p0 = l.Origin();
  50.         Point p1 = l.Endpoint();
  51.         glBegin(GL_LINES);
  52.                 glVertex2f(p0[0],p0[1]);
  53.                 glVertex2f(p1[0],p1[1]);
  54.         glEnd();
  55. }
  56.