home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / Venus 3.5 / ImageViews.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-10  |  3.7 KB  |  110 lines  |  [TEXT/CWIE]

  1. /*
  2.  ***********************************************************************
  3.  *
  4.  *                            Full-color (full-gray)
  5.  *                (Sub)windows displaying an image in 2D/3D        
  6.  *
  7.  * These subwindow create an image view in a OffScreen buffer, which has to
  8.  * be bound later to something on-screen (a window, a dialog user item, etc)
  9.  * 
  10.  ***********************************************************************
  11.  */
  12. #pragma once
  13.  
  14. #include "ElevationMap.h"
  15. #include "window.h"
  16.  
  17.  
  18. struct ViewerPosition
  19. {
  20.   int xe, ye;                                        // Location of an observation point
  21.   int gx, gy;                                        // Gaze vector (of size |g|=1<<14)
  22.   enum { g_unit = 1<<14 };                            // |g|, size of the gaze vector
  23.   ViewerPosition(const int _xe, const int _ye, const int _gx, const int _gy)
  24.     : xe(_xe), ye(_ye), gx(_gx), gy(_gy)
  25.     {   assert( gx*gx + gy*gy == g_unit*g_unit );            // Just to test our assumptions
  26.     }
  27.   void dump(void) const;                            // Dump the contents of it
  28. };
  29.  
  30. struct ProjectionParameters
  31. {
  32.   int ze;                                        // Elevation of the view point
  33.   int beta;                                        // Local coordinates scaling factor
  34.   const int u_sup, v_sup;                        // Define the view port dimensions
  35.   int Ou, Ov;                                    // Origin of the local coordinate ref Pt
  36.  
  37.   ProjectionParameters(const ScreenRect& bounds, const int _ze, const int _beta);
  38.   ScreenRect q_view_rect(void) const        { return ScreenRect(v_sup,u_sup); }
  39.   int q_width(void) const                    { return u_sup; }
  40.   int q_height(void) const                    { return v_sup; }
  41.   void dump(void) const;                            // Dump the contents of it
  42. };
  43.  
  44.                                     // Picture view in 2d
  45. class ImageView : public OffScreenBuffer
  46. {
  47.   ImageView(const ImageView&);                    // Left unimplemented: copying/cloning of
  48.   ImageView& operator = (const ImageView&);        // ImageView is not allowed
  49. public:
  50.   ImageView(const ElevationMap& elev_image);
  51. };
  52.  
  53.  
  54.                                     // Picture view in 3d
  55. class ThreeDViewBase : public OffScreenBuffer
  56. {
  57. protected:
  58.   const ElevationMap& map;                        // Image to view
  59.   const ViewerPosition& viewer_pos;        // To get the view parameters from
  60.   const ProjectionParameters& projection_parms;
  61.  
  62.   ThreeDViewBase(const ThreeDViewBase&);                    // Left unimplemented: copying/cloning of
  63.   ThreeDViewBase& operator = (const ThreeDViewBase&);        // ThreeDViewBase is not allowed
  64.  
  65.  
  66.                                 // A class to handle one scanline of the view plane
  67.   class OneViewScanline
  68.   {
  69.     friend class ScanLineAccess;        // needed for a member function kludge
  70.     
  71.       OneViewScanline(const OneViewScanline&);                // Left unimplemented: copying/cloning of
  72.       OneViewScanline& operator = (const OneViewScanline&);    // OneViewScanline is not allowed
  73.  
  74.   public:
  75.     struct ScanPoint {                    // A scan point at some given u
  76.       int v;                            // visible elevation (note, PowerPC prefers ints to short)
  77.       int color;                        // color of a point (taken off the map)
  78.     };
  79.   
  80.     OneViewScanline(const int _width);
  81.     ~OneViewScanline(void);    
  82.  
  83.     int q_width(void) const                { return width; }
  84.     void print(const card i=0) const;                // print a scanline point
  85.  
  86.   private:
  87.     const int width;                        // width of a scanline
  88.     ScanPoint * const scan_points;            // scanpoints of a scanline
  89.         
  90.   };
  91.   
  92.   OneViewScanline scanline1, scanline2;        // Two working scanlines
  93.  
  94.   virtual void prepaint(void);                // Prepare the buffer (eg, clean it) 
  95. public:
  96.   ThreeDViewBase(const ElevationMap& image_map, const ViewerPosition& viewer_pos,
  97.                const ProjectionParameters& projection_parms);
  98.   void dump(const char title [] = "") const;
  99. };
  100.  
  101. template <class LineProjector> class ThreeDView : public ThreeDViewBase
  102. {
  103. public:
  104.   ThreeDView(const ElevationMap& image_map, const ViewerPosition& viewer_pos,
  105.                const ProjectionParameters& projection_parms);
  106.   void project(void);                    // Draw a projection in an offscreen
  107.                                         // world
  108. };
  109.  
  110.