home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / freedraft.tar.gz / freedraft.tar / FREEdraft-050298 / VIEWPORT / canvasglstate.h < prev    next >
C/C++ Source or Header  |  1998-04-29  |  3KB  |  72 lines

  1. //canvasglstate.h
  2.  
  3.  
  4. // Copyright (C) 1997  Cliff Johnson                                       //
  5. //                                                                         //
  6. // This program is free software; you can redistribute it and/or           //
  7. // modify it under the terms of the GNU  General Public                    //
  8. // License as published by the Free Software Foundation; either            //
  9. // version 2 of the License, or (at your option) any later version.        //
  10. //                                                                         //
  11. // This software is distributed in the hope that it will be useful,        //
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       //
  14. // General Public License for more details.                                //
  15. //                                                                         //
  16. // You should have received a copy of the GNU General Public License       //
  17. // along with this software (see COPYING); if not, write to the        //
  18. // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
  19. // 
  20. // 
  21. // 
  22. // 
  23. // 
  24. // ppmm, or pixels per millimeter of screen, should be set as best you can
  25. // figure in the constructor by the owner object, most likely the vdglcanvas. 
  26. // my monitor is about 3.8 ppmm. 
  27. // 
  28. // scale is defined as millimeters of screen per millimeter of object drawn. 
  29. // So at scale = 1 an object is drawn true size. At scale 2 twice as much screen
  30. // is used etc. 
  31. // 
  32.  
  33. #ifndef CANVASGLSTATE_H
  34. #define CANVASGLSTATE_H
  35.  
  36. #include <point.h>    //HASA
  37.  
  38. //++++++++++++++++++++++++ CanvasGLState +++++++++++++++++++++
  39. class CanvasGLState
  40. {
  41.     enum {MAXZOOMFACTOR = 8,         // max change in zoom
  42.           MAXVIEWDIMENSION = 10000 };    // max view dimension
  43.  
  44. private:
  45.     Point viewCenter;
  46.     float viewScale;
  47.     float pixelsPerMillimeter;    // pixels per millimeter at viewScale = 1.0 
  48.  
  49. //public: ***everyfuckingthing is private***
  50.  
  51.     CanvasGLState(const Point& center, float scale, float ppmm);
  52.     void SetOrtho2D(int w, int h);
  53.  
  54.     void SetScale(float s);
  55.     void SetPPMM(float ppmm);
  56.     void SetCenter(const Point& p);
  57.  
  58.     float GetScale() const { return viewScale; }
  59.     float GetPPMM() const { return pixelsPerMillimeter; }
  60.     Point GetCenter() const { return viewCenter;}
  61.  
  62.     friend class VDGLCanvas;    // directly manipulable by VDGLCanvas
  63.     Point GetCoord(int x, int y, int w, int h); // return the real world 
  64.                             //coordinates  at screen x,y
  65. // adjust view for zoom in/out on extreme points
  66.     void ZoomIn(const Point& p1, const Point& p2, int w, int h); 
  67.     void ZoomOut(const Point& p1, const Point& p2, int w, int h);
  68.  
  69. };
  70.  
  71. #endif
  72.