HeightWin.h

Go to the documentation of this file.
00001 //HeightWin.h
00002 
00003 /*************************************************************/
00004 //
00005 // HeightWinDialog
00006 //
00007 // Window for displaying the 3D heightmap
00008 //
00009 //-------------------------------------------------------------
00010 //
00011 // v 1.4 - 2007/03/31 - Changes to drawing options
00012 // v 1.3 - 2007/02/17 - Improved data output
00013 // v 1.2 - 2006/08/27 - Using near-zero rounding text output
00014 // v 1.1 - 2006/07/07 - Maximum number of grid lines
00015 // v 1.0 - 2006/04/19 - Initial release
00016 //
00017 // See LICENSE.txt for distribution and usage restrictions
00018 // Copyright (c) 2006-2007 Simon Chorley
00019 // www.mylaboratory.co.uk - greylab@mylaboratory.co.uk
00020 //
00021 /*************************************************************/
00022 
00023 
00024 ///HeightMap window (Definition)
00025 /**
00026  * Provides HeightWinDialog class to draw the heightmap graph.
00027  * @file HeightWin.h
00028  * @version 1.4 - 2007/03/31
00029  */
00030 
00031 
00032 #ifndef _HEIGHTWIN_H_
00033 #define _HEIGHTWIN_H_
00034 
00035 #include <fx.h>
00036 #include <fx3d.h>
00037 #include <GL/gl.h>
00038 #include <GL/glu.h>
00039 #include "Vector.h"
00040 #include "GraphFont.h"
00041 
00042 
00043 ///HeightMap window class
00044 /**
00045  * Manages the heightmap window and renders the graph.
00046  */
00047 class HeightWinDialog : public FXDialogBox
00048 {
00049         FXDECLARE(HeightWinDialog)
00050 protected:
00051         FXGLVisual *GLVisual;   ///<OpenGL visual target
00052         FXGLCanvas *GLCanvas;   ///<OpenGL canvas
00053 
00054 private:
00055         HeightWinDialog(){}
00056 
00057         ///Canvas camera settings structure
00058         struct canvassets
00059         {
00060                 float fov;              ///<Field of view
00061                 float vp[2];    ///<Viewport size
00062                 CVector eye;    ///<Eye position
00063                 CVector look;   ///<Look direction
00064                 CVector up;             ///<Up direction
00065         } canvasSettings;       ///<Canvas camera settings
00066         
00067         FXCursor *crosshair;    ///<Cursor crosshair icon
00068 
00069         CGraphFont *fnt;        ///<Font object
00070 
00071         GLUquadricObj* sphereQuadric;   ///<Sphere for light positioning
00072         
00073         ///Mouse state structure
00074         struct
00075         {
00076                 bool state;             ///<Button status
00077                 int x;                  ///<x position
00078                 int y;                  ///<y position
00079         } mouseData[3];         ///<Mouse state
00080 
00081 public:
00082         long onGLExpose(FXObject*, FXSelector, void*);          //window uncovered
00083         long onGLConfigure(FXObject*, FXSelector, void*);       //window created
00084         long onGLSelect(FXObject*, FXSelector, void*);
00085         long onGLMouseMotion(FXObject*, FXSelector, void*);
00086         long onGLMouseDown(FXObject*, FXSelector, void*);
00087         long onGLMouseUp(FXObject*, FXSelector, void*);
00088         long onGLMouseWheel(FXObject*, FXSelector, void*);
00089 
00090         enum { ID_CANVAS = FXMainWindow::ID_LAST };
00091 
00092         //Variables from the GUI
00093         bool drawlabels;                                ///<Draw axis labels?
00094         bool perspective;                               ///<Draw with perspective correction?
00095         int box;                                                ///<Draw surrouding box (style)
00096         bool plate;                                             ///<Draw ground plate
00097         unsigned char boxcolour[3];             ///<Box colour
00098         unsigned char platecolour[3];   ///<Plate colour
00099         float diffusecolour[4];                 ///<Light diffuse colour
00100         float specularcolour[4];                ///<Light specular colour
00101         float lightpos[4];                              ///<Light position
00102         float shininess;                                ///<Surface shininess
00103         bool motiontype;                                ///<Camera or light motion
00104         int drawmode;                                   ///<Draw triangles/lines/points
00105         bool switchdir;                                 ///<Switch rendering direction (x to y)
00106         bool zbackgrid;                                 ///<Draw z axis grid behind data?
00107 
00108         ///Grid settings structure
00109         struct grid
00110         {
00111                 FXColor colour; ///<Grid line colour
00112                 float start;    ///<Axis start value
00113                 float delta;    ///<Spacing between lines
00114                 bool on;                ///<Display grid?
00115         } xmaj, xmin, ymaj, ymin, zmaj, zmin;   ///<Grid parameters
00116 
00117         FXString labels[5];     ///<Labels: title, sub-title, x, y, z
00118         FXString axes[6];       ///<Axis limit strings: xmin, xmax, ymin, ymax, zmin, zmax
00119         int txtpos[4];  ///<Positions of axes labels (title, x, y, z)
00120         
00121         ///The heightmap data structure
00122         struct datapoint
00123         {
00124                 unsigned char colour[3];        ///<Vertex colour
00125                 float position[3];                      ///<Vertex position
00126                 float normal[3];        ///<Vertex normal
00127         } *hmdata;                      ///<Heightmap data
00128         unsigned int xdatapts;  ///<Number of x datapoints
00129         unsigned int ydatapts;  ///<Number of y datapoints
00130         unsigned int xdatadisplay;      ///<Number of points to display (to allow speeding up)
00131 
00132         void onGLRefresh();     //draw graph
00133         unsigned char* getImage(int &width, int &height);       //return a bitmap of the graph
00134 
00135         HeightWinDialog(FXApp *app, FXWindow *win, CGraphFont *ft);
00136         virtual ~HeightWinDialog();
00137 };
00138 
00139 #endif

Generated on Mon Mar 10 13:55:45 2008 for GreyLab by  doxygen 1.5.3